package ng_cws_client import ( "encoding/json" "fmt" ) const ( EventTypeNodeAgree = iota + 1 // 节点同意事件 EventTypeNodeReject // 节点退回事件 EventTypeRecall // 撤回事件 EventTypeOverTime // 超时事件 EventTypeNodeNotice // 节点提醒事件 EventTypeWorkflowAgree //流程同意事件 EventTypeWorkflowReject //流程退回事件 EventTypeNodeEnter //节点进入事件 EventTypeWorkflowRevoke //流程撤回事件 ) type ( WorkflowEventDataProcess struct { DataProcess Event int `json:"event"` EventName string `json:"eventName"` } CloudEvent struct { SpecVersion string `json:"specversion"` ID string `json:"id"` Type string `json:"type"` Source string `json:"source"` DataContentType string `json:"datacontenttype"` Time string `json:"time"` Data []byte `json:"data"` } DataProcess struct { WorkflowID string `json:"workflowId"` TenantID string `json:"tenantId"` LaunchTime string `json:"launchTime"` LaunchUserID string `json:"launchUserId"` LaunchUserName string `json:"launchUserName"` ApproveUserID string `json:"approveUserID"` // 审批人id ApproveUserName string `json:"approveUserName"` // 审批人姓名 BusinessEntityInstance string `json:"businessEntityInstance"` WorkflowContext string `json:"workflowContext"` NodeContext string `json:"nodeContext"` } ) func (ce CloudEvent) GetDataProcess() (*WorkflowEventDataProcess, error) { dataProcess := new(WorkflowEventDataProcess) err := json.Unmarshal(ce.Data, dataProcess) if err != nil { fmt.Println("流程回调转化json失败:", err) return nil, err } return dataProcess, nil } func (dp *DataProcess) GenBusinessEntity(businessEntity any) error { err := json.Unmarshal([]byte(dp.BusinessEntityInstance), businessEntity) if err != nil { return err } return nil }