callback_info.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package ng_cws_client
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. )
  6. const (
  7. EventTypeNodeAgree = iota + 1 // 节点同意事件
  8. EventTypeNodeReject // 节点退回事件
  9. EventTypeRecall // 撤回事件
  10. EventTypeOverTime // 超时事件
  11. EventTypeNodeNotice // 节点提醒事件
  12. EventTypeWorkflowAgree //流程同意事件
  13. EventTypeWorkflowReject //流程退回事件
  14. EventTypeNodeEnter //节点进入事件
  15. EventTypeWorkflowRevoke //流程撤回事件
  16. EventTypeWorkflowLaunch //流程发起事件
  17. )
  18. type (
  19. WorkflowEventDataProcess struct {
  20. DataProcess
  21. Event int `json:"event"`
  22. EventName string `json:"eventName"`
  23. }
  24. CloudEvent struct {
  25. SpecVersion string `json:"specversion"`
  26. ID string `json:"id"`
  27. Type string `json:"type"`
  28. Source string `json:"source"`
  29. DataContentType string `json:"datacontenttype"`
  30. Time string `json:"time"`
  31. Data []byte `json:"data"`
  32. }
  33. DataProcess struct {
  34. WorkflowID string `json:"workflowId"`
  35. TenantID string `json:"tenantId"`
  36. LaunchTime string `json:"launchTime"`
  37. LaunchUserID string `json:"launchUserId"`
  38. LaunchUserName string `json:"launchUserName"`
  39. ApproveUserID string `json:"approveUserID"` // 审批人id
  40. ApproveUserName string `json:"approveUserName"` // 审批人姓名
  41. BusinessEntityInstance string `json:"businessEntityInstance"`
  42. WorkflowContext string `json:"workflowContext"`
  43. NodeContext string `json:"nodeContext"`
  44. }
  45. )
  46. func (ce CloudEvent) GetDataProcess() (*WorkflowEventDataProcess, error) {
  47. dataProcess := new(WorkflowEventDataProcess)
  48. err := json.Unmarshal(ce.Data, dataProcess)
  49. if err != nil {
  50. fmt.Println("流程回调转化json失败:", err)
  51. return nil, err
  52. }
  53. return dataProcess, nil
  54. }
  55. func (dp *DataProcess) GenBusinessEntity(businessEntity any) error {
  56. err := json.Unmarshal([]byte(dp.BusinessEntityInstance), businessEntity)
  57. if err != nil {
  58. return err
  59. }
  60. return nil
  61. }