callback_info.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. )
  17. type (
  18. WorkflowEventDataProcess struct {
  19. DataProcess
  20. Event int `json:"event"`
  21. EventName string `json:"eventName"`
  22. }
  23. CloudEvent struct {
  24. SpecVersion string `json:"specversion"`
  25. ID string `json:"id"`
  26. Type string `json:"type"`
  27. Source string `json:"source"`
  28. DataContentType string `json:"datacontenttype"`
  29. Time string `json:"time"`
  30. Data []byte `json:"data"`
  31. }
  32. DataProcess struct {
  33. WorkflowID string `json:"workflowId"`
  34. TenantID string `json:"tenantId"`
  35. LaunchTime string `json:"launchTime"`
  36. LaunchUserID string `json:"launchUserId"`
  37. LaunchUserName string `json:"launchUserName"`
  38. ApproveUserID string `json:"approveUserID"` // 审批人id
  39. ApproveUserName string `json:"approveUserName"` // 审批人姓名
  40. BusinessEntityInstance string `json:"businessEntityInstance"`
  41. WorkflowContext string `json:"workflowContext"`
  42. NodeContext string `json:"nodeContext"`
  43. }
  44. )
  45. func (ce CloudEvent) GetDataProcess() (*WorkflowEventDataProcess, error) {
  46. dataProcess := new(WorkflowEventDataProcess)
  47. err := json.Unmarshal(ce.Data, dataProcess)
  48. if err != nil {
  49. fmt.Println("流程回调转化json失败:", err)
  50. return nil, err
  51. }
  52. return dataProcess, nil
  53. }