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.
73 lines
1.8 KiB
Go
73 lines
1.8 KiB
Go
package model
|
|
|
|
import (
|
|
"cu-helper/cus-eng-con-sys/cryptokit"
|
|
"reflect"
|
|
)
|
|
|
|
/*
|
|
/zjgd/frm/projectServiceResultController/modifyRemandProjectIdByRemandId.action
|
|
*/
|
|
|
|
/*
|
|
用途:方案确认中绑定需求至项目
|
|
*/
|
|
|
|
//remandId = ba2cdfe2-d4b3-43ed-8462-bdf9626e374c
|
|
//projectId = 8895163
|
|
//repleyInvestment = 2200
|
|
//ranstr = 7L598nbqEF
|
|
//timestamp = 1766385977423
|
|
|
|
type ModifyRemandProj struct {
|
|
RemandId string `map:"remandId"`
|
|
ProjectId string `map:"projectId"`
|
|
RepleyInvestment string `map:"repleyInvestment"`
|
|
Ranstr string `map:"ranstr"`
|
|
Timestamp string `map:"timestamp"`
|
|
}
|
|
|
|
func NewModifyRemandProj(remandId, projectId, repleyInvestment string) *ModifyRemandProj {
|
|
modifyRemandProj := new(ModifyRemandProj)
|
|
modifyRemandProj.RemandId = remandId
|
|
modifyRemandProj.ProjectId = projectId
|
|
modifyRemandProj.RepleyInvestment = repleyInvestment
|
|
modifyRemandProj.Ranstr = cryptokit.RandomStr(true, 10, 32)
|
|
modifyRemandProj.Timestamp = cryptokit.GetTimeStamp()
|
|
return modifyRemandProj
|
|
}
|
|
|
|
// GenReqParam 返回加密后的请求参数
|
|
func (th *ModifyRemandProj) GenReqParam() map[string]string {
|
|
th.encrypt()
|
|
return th.structToMap()
|
|
}
|
|
|
|
func (th *ModifyRemandProj) 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 *ModifyRemandProj) 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()))
|
|
}
|
|
}
|
|
}
|