client_test.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package dingtalk
  2. import (
  3. "dashoo.cn/opms_libary/plugin/dingtalk/workflow"
  4. "dashoo.cn/opms_libary/utils"
  5. "encoding/json"
  6. "fmt"
  7. "github.com/gogf/gf/util/gconv"
  8. "testing"
  9. )
  10. func TestQuerySchemaByProcessCode(t *testing.T) {
  11. client := NewClient()
  12. w := client.GetWorkflow()
  13. // s, _ := w.QuerySchemaByProcessCode("PROC-E5A8B695-A6AF-49CF-9909-9A31C33A1211")
  14. s, _ := w.QuerySchemaByProcessCode("PROC-33514974-4E38-430F-A852-D5694944F20B")
  15. // s, _ := w.QuerySchemaByProcessCode("PROC-9494B87D-DE96-49EE-B676-D3913911BE21")
  16. fmt.Println(gconv.String(s))
  17. }
  18. func TestSign(t *testing.T) {
  19. //client := NewClient()
  20. //s := client.GetStorage()
  21. //resp, _ := s.QueryFileUploadInfo("21042518430", "fHJtftdpHZXwvsdOfg8skgiEiE")
  22. //code, _ := s.UploadFile(resp.HeaderSignatureInfo.ResourceUrls[0], resp.HeaderSignatureInfo.Headers, "/Users/chengjian/Downloads/引物导入模板.xlsx")
  23. //if code == 200 {
  24. // s.CommitFile(resp.UploadKey, "引物导入模板-1.xlsx", "21042518430", "0", "fHJtftdpHZXwvsdOfg8skgiEiE")
  25. //}
  26. //
  27. //fmt.Println(resp)
  28. }
  29. func TestCommitFile(t *testing.T) {
  30. client := NewClient()
  31. s := client.GetStorage()
  32. resp, err := s.UploadFile("21042518430", "8xljy04PZiS9iPxp5PhDnUzQiEiE", "引物导入模板-000000.xlsx", "/Users/chengjian/Downloads/引物导入模板.xlsx")
  33. fmt.Println(json.Marshal(resp))
  34. fmt.Println(err.Error())
  35. }
  36. func TestStartProcessInstance(t *testing.T) {
  37. client := NewClient()
  38. w := client.GetWorkflow()
  39. TextField_1QEXO83G7GDC0 := &workflow.StartProcessInstanceRequestFormComponentValues{
  40. Id: utils.String("TextField_1QEXO83G7GDC0"),
  41. Name: utils.String("客户编码"),
  42. Value: utils.String("CT00001"),
  43. }
  44. TextField_13MDZ97RV16K0 := &workflow.StartProcessInstanceRequestFormComponentValues{
  45. Id: utils.String("TextField_13MDZ97RV16K0"),
  46. Name: utils.String("客户名称"),
  47. Value: utils.String("测试客户"),
  48. }
  49. TextField_1ZY48VZY6WG00 := &workflow.StartProcessInstanceRequestFormComponentValues{
  50. Id: utils.String("TextField_1ZY48VZY6WG00"),
  51. Name: utils.String("申请人"),
  52. Value: utils.String("系统管理员"),
  53. }
  54. TextareaField_5U6VKA6N1VK0 := &workflow.StartProcessInstanceRequestFormComponentValues{
  55. Id: utils.String("TextareaField_5U6VKA6N1VK0"),
  56. Name: utils.String("申请说明"),
  57. Value: utils.String("申请说明"),
  58. }
  59. //DDAttachment_17PC5KQBVEM80 := &workflow.StartProcessInstanceRequestFormComponentValues{
  60. // Id: tea.String("DDAttachment_17PC5KQBVEM80"),
  61. // Name: tea.String("附件"),
  62. // Value: tea.String("123xxxxxxxx"),
  63. //}
  64. startProcessInstanceRequest := &workflow.StartProcessInstanceRequest{
  65. OriginatorUserId: utils.String("47073111989114"),
  66. ProcessCode: utils.String("PROC-FE42B2D1-6097-4DE8-8AC5-23541B7D5C8A"),
  67. DeptId: utils.Int64(435711466),
  68. FormComponentValues: []*workflow.StartProcessInstanceRequestFormComponentValues{TextField_1QEXO83G7GDC0, TextField_13MDZ97RV16K0, TextField_1ZY48VZY6WG00, TextareaField_5U6VKA6N1VK0},
  69. }
  70. //w.StartProcessInstance("47073111989114", "PROC-7A5F6215-A8CF-4DD1-AB2C-5B1AB84C4E19", 435711466) 8xljy04PZiS9iPxp5PhDnUzQiEiE
  71. resp, _ := w.StartProcessInstance(startProcessInstanceRequest)
  72. fmt.Println(resp)
  73. }
  74. func TestQueryUserInfoByPhone(t *testing.T) {
  75. client := NewClient()
  76. c := client.GetContact()
  77. resp1 := c.QueryUserIdByPhone("18653295560")
  78. resp2 := c.QueryUserInfoByUserId(resp1.Result.Userid)
  79. fmt.Println(resp2)
  80. }