client_test.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. fmt.Println(gconv.String(s))
  15. }
  16. func TestSign(t *testing.T) {
  17. //client := NewClient()
  18. //s := client.GetStorage()
  19. //resp, _ := s.QueryFileUploadInfo("21042518430", "fHJtftdpHZXwvsdOfg8skgiEiE")
  20. //code, _ := s.UploadFile(resp.HeaderSignatureInfo.ResourceUrls[0], resp.HeaderSignatureInfo.Headers, "/Users/chengjian/Downloads/引物导入模板.xlsx")
  21. //if code == 200 {
  22. // s.CommitFile(resp.UploadKey, "引物导入模板-1.xlsx", "21042518430", "0", "fHJtftdpHZXwvsdOfg8skgiEiE")
  23. //}
  24. //
  25. //fmt.Println(resp)
  26. }
  27. func TestCommitFile(t *testing.T) {
  28. client := NewClient()
  29. s := client.GetStorage()
  30. resp, err := s.UploadFile("21042518430", "8xljy04PZiS9iPxp5PhDnUzQiEiE", "引物导入模板-000000.xlsx", "/Users/chengjian/Downloads/引物导入模板.xlsx")
  31. fmt.Println(json.Marshal(resp))
  32. fmt.Println(err.Error())
  33. }
  34. func TestStartProcessInstance(t *testing.T) {
  35. client := NewClient()
  36. w := client.GetWorkflow()
  37. TextField_1QEXO83G7GDC0 := &workflow.StartProcessInstanceRequestFormComponentValues{
  38. Id: utils.String("TextField_1QEXO83G7GDC0"),
  39. Name: utils.String("客户编码"),
  40. Value: utils.String("CT00001"),
  41. }
  42. TextField_13MDZ97RV16K0 := &workflow.StartProcessInstanceRequestFormComponentValues{
  43. Id: utils.String("TextField_13MDZ97RV16K0"),
  44. Name: utils.String("客户名称"),
  45. Value: utils.String("测试客户"),
  46. }
  47. TextField_1ZY48VZY6WG00 := &workflow.StartProcessInstanceRequestFormComponentValues{
  48. Id: utils.String("TextField_1ZY48VZY6WG00"),
  49. Name: utils.String("申请人"),
  50. Value: utils.String("系统管理员"),
  51. }
  52. TextareaField_5U6VKA6N1VK0 := &workflow.StartProcessInstanceRequestFormComponentValues{
  53. Id: utils.String("TextareaField_5U6VKA6N1VK0"),
  54. Name: utils.String("申请说明"),
  55. Value: utils.String("申请说明"),
  56. }
  57. //DDAttachment_17PC5KQBVEM80 := &workflow.StartProcessInstanceRequestFormComponentValues{
  58. // Id: tea.String("DDAttachment_17PC5KQBVEM80"),
  59. // Name: tea.String("附件"),
  60. // Value: tea.String("123xxxxxxxx"),
  61. //}
  62. startProcessInstanceRequest := &workflow.StartProcessInstanceRequest{
  63. OriginatorUserId: utils.String("47073111989114"),
  64. ProcessCode: utils.String("PROC-FE42B2D1-6097-4DE8-8AC5-23541B7D5C8A"),
  65. DeptId: utils.Int64(435711466),
  66. FormComponentValues: []*workflow.StartProcessInstanceRequestFormComponentValues{TextField_1QEXO83G7GDC0, TextField_13MDZ97RV16K0, TextField_1ZY48VZY6WG00, TextareaField_5U6VKA6N1VK0},
  67. }
  68. //w.StartProcessInstance("47073111989114", "PROC-7A5F6215-A8CF-4DD1-AB2C-5B1AB84C4E19", 435711466) 8xljy04PZiS9iPxp5PhDnUzQiEiE
  69. resp, _ := w.StartProcessInstance(startProcessInstanceRequest)
  70. fmt.Println(resp)
  71. }
  72. func TestQueryUserInfoByPhone(t *testing.T) {
  73. client := NewClient()
  74. c := client.GetContact()
  75. resp1 := c.QueryUserIdByPhone("18653295560")
  76. resp2 := c.QueryUserInfoByUserId(resp1.Result.Userid)
  77. fmt.Println(resp2)
  78. }