package model import ( "cu-helper/cus-eng-con-sys/config" "cu-helper/cus-eng-con-sys/cryptokit" "reflect" ) /* /zjgd/frm/projectServiceResultController/getProjectSurplseInvestmentByProjectId.action */ /* 用途:方案确认中判断子项投资是否够 */ //projectId = 8895163 //remandId = ba2cdfe2-d4b3-43ed-8462-bdf9626e374c //attr1 = CMA25CD0000060.3301 //attr3 = 0 //prov = 3301 //city = 3302 //isEpc = 0 //isService = 0 //buildMode = 1 //specC = MAC //buildAttr = PT //ranstr = tN9CXTDIX5mi6Af9lutJdDwBUbcRod //timestamp = 1766383093673 type GetProjInvest struct { ProjectId string `map:"projectId"` RemandId string `map:"remandId"` Attr1 string `map:"attr1"` Attr3 string `map:"attr3"` Prov string `map:"prov"` City string `map:"city"` IsEpc string `map:"isEpc"` IsService string `map:"isService"` BuildMode string `map:"buildMode"` SpecC string `map:"specC"` BuildAttr string `map:"buildAttr"` Ranstr string `map:"ranstr"` Timestamp string `map:"timestamp"` } func NewGetProjInvest(projId, remandId, processDefKey, projCode string) *GetProjInvest { getProjInvest := new(GetProjInvest) getProjInvest.ProjectId = projId getProjInvest.RemandId = remandId getProjInvest.Attr1 = projCode getProjInvest.Attr3 = "0" getProjInvest.Prov = "3301" getProjInvest.City = "3302" getProjInvest.IsEpc = "0" getProjInvest.IsService = "0" getProjInvest.BuildMode = "1" if processDefKey == config.ProcessLX { getProjInvest.SpecC = "NAA" } if processDefKey == config.ProcessHouse { getProjInvest.SpecC = "MAC" } getProjInvest.BuildAttr = "PT" getProjInvest.Ranstr = cryptokit.RandomStr(true, 10, 32) getProjInvest.Timestamp = cryptokit.GetTimeStamp() return getProjInvest } // GenReqParam 返回加密后的请求参数 func (th *GetProjInvest) GenReqParam() map[string]string { th.encrypt() return th.structToMap() } func (th *GetProjInvest) 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 *GetProjInvest) 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())) } } }