CreateFlowByTemplateDirectly.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package essapi
  2. import (
  3. "mtp2_if/utils"
  4. essbasic "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/essbasic/v20210526"
  5. )
  6. // CreateFlowByTemplateDirectly 通过合同名和模板Id直接发起签署流程
  7. // 本接口是对于发起合同几个接口的封装,详细参数需要根据自身业务进行调整
  8. // CreateFlowsByTemplates--CreateSignUrls
  9. func CreateFlowByTemplateDirectly(flowName, templateId string, flowApproverInfos []*essbasic.FlowApproverInfo) (resp map[string][]*string, err error) {
  10. agent := utils.SetAgent()
  11. resp = make(map[string][]*string)
  12. // 创建签署流程
  13. var flowInfos []*essbasic.FlowInfo
  14. flowInfos = append(flowInfos, utils.FillFlowInfo(templateId, flowName, flowApproverInfos))
  15. // 构建内容控件填充结构(根据自己需求使用)
  16. // flowInfos[i].FormFields = []*v20210526.FormField{utils.BuildFormField("姓名", "张三")}
  17. // 发起签署
  18. flowResponse, err := CreateFlowsByTemplates(agent, flowInfos)
  19. if err != nil {
  20. return
  21. }
  22. flowIds := flowResponse.Response.FlowIds
  23. resp["flowIds"] = flowIds
  24. // 获取签署链接
  25. createSignUrlsResp, err := CreateSignUrls(flowIds, agent)
  26. if err != nil {
  27. return
  28. }
  29. if len(createSignUrlsResp.Response.SignUrlInfos) != 0 {
  30. var urls []*string
  31. urls = append(urls, createSignUrlsResp.Response.SignUrlInfos[0].SignUrl)
  32. resp["urls"] = urls
  33. }
  34. return
  35. }