client_test.go 3.1 KB

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