You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.1 KiB
Go

package model
import (
"cu-helper/cus-eng-con-sys/cryptokit"
"reflect"
)
/*
/zjgd/frm/acceptanceComfirmController/jfPushProcess
*/
/*
用途:验收交付确认
*/
type JFPushProcess struct {
ProcessInstanceId string `map:"processInstanceId"`
TaskId string `map:"taskId"`
DeliveryId string `map:"deliveryId"`
TaskDefinitionKey string `map:"taskDefinitionKey"`
Assignee string `map:"assignee"`
Comment string `map:"comment"`
HandleType string `map:"handleType"`
BusinessKey string `map:"businessKey"`
Withdraw string `map:"withdraw"`
Ranstr string `map:"ranstr"`
Timestamp string `map:"timestamp"`
}
func NewJFPushProcess(processInsId, taskId, deliveryId, businessKey string) *JFPushProcess {
jfPushProcess := new(JFPushProcess)
jfPushProcess.ProcessInstanceId = processInsId
jfPushProcess.TaskId = taskId
jfPushProcess.DeliveryId = deliveryId
jfPushProcess.TaskDefinitionKey = "JFQR"
jfPushProcess.Assignee = "3072887" //todo 每个人都是这个吗
jfPushProcess.Comment = "请确认"
jfPushProcess.HandleType = "1"
jfPushProcess.BusinessKey = businessKey
jfPushProcess.Withdraw = "0"
jfPushProcess.Ranstr = cryptokit.RandomStr(true, 10, 32)
jfPushProcess.Timestamp = cryptokit.GetTimeStamp()
return jfPushProcess
}
// GenReqParam 返回加密后的请求参数
func (th *JFPushProcess) GenReqParam() map[string]string {
th.encrypt()
return th.structToMap()
}
func (th *JFPushProcess) structToMap() map[string]string {
result := make(map[string]string)
t := reflect.TypeOf(*th)
v := reflect.ValueOf(*th)
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
value := v.Field(i)
// Use the tag value as the key in the map, if it exists; otherwise, use the field name.
tag := field.Tag.Get("map")
if tag == "" {
tag = field.Name
}
result[tag] = value.String()
}
return result
}
func (th *JFPushProcess) encrypt() {
v := reflect.ValueOf(th).Elem()
for i := 0; i < v.NumField(); i++ {
field := v.Field(i)
if field.CanSet() {
field.SetString(cryptokit.Encrypt(field.String()))
}
}
}