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.

76 lines
1.7 KiB
Go

package model
import (
"cu-helper/cus-eng-con-sys/cryptokit"
"reflect"
)
/*
/zjgd/frm/workflow/taskToDo.action
*/
/*
用途
1、获取待办任务
*/
type TaskTodo struct {
Start string `map:"start"`
Length string `map:"length"`
Title string `map:"title"`
LinkName string `map:"linkName"`
CreateTimeStart string `map:"createTimeStart"`
CreateTimeEnd string `map:"createTimeEnd"`
DbStartFlag string `map:"dbStartFlag"`
Ranstr string `map:"ranstr"`
Timestamp string `map:"timestamp"`
}
func NewTaskTodo(process string) *TaskTodo {
taskTodo := new(TaskTodo)
taskTodo.Start = "1"
taskTodo.Length = "9999"
taskTodo.Title = ""
taskTodo.LinkName = process
taskTodo.CreateTimeStart = ""
taskTodo.CreateTimeEnd = ""
taskTodo.DbStartFlag = ""
taskTodo.Ranstr = cryptokit.RandomStr(true, 10, 32)
taskTodo.Timestamp = cryptokit.GetTimeStamp()
return taskTodo
}
// GenReqParam 返回加密后的请求参数
func (th *TaskTodo) GenReqParam() map[string]string {
th.encrypt()
return th.structToMap()
}
func (th *TaskTodo) 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 *TaskTodo) 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()))
}
}
}