package pack import ( "github.com/tidwall/gjson" "strconv" "youngee_b_api/model/gorm_model" "youngee_b_api/model/http_model" "github.com/caixw/lib.go/conv" ) func GormSecTaskListToHttpSecTaskList(secTaskList []*gorm_model.YounggeeSecTaskInfo) []*http_model.SecTaskInfo { var resTaskTaskList []*http_model.SecTaskInfo for _, secTask := range secTaskList { secTaskH := GormSecTaskToHttpSecTask(secTask) resTaskTaskList = append(resTaskTaskList, secTaskH) } return resTaskTaskList } func GormSecTaskToHttpSecTask(secTask *gorm_model.YounggeeSecTaskInfo) *http_model.SecTaskInfo { TalentPlatformInfoSnap := secTask.TalentPlatformInfoSnap regionCode, _ := strconv.Atoi(conv.MustString(gjson.Get(secTask.TalentPostAddrSnap, "region_code"), "")) return &http_model.SecTaskInfo{ SecTaskId: secTask.TaskID, PlatformNickname: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "platform_nickname"), ""), FansCount: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "fans_count"), ""), HomePageCaptureUrl: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "home_page_capture_url"), ""), HomePageUrl: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "home_page_url"), ""), RegionCode: regionCode, DetailAddr: conv.MustString(gjson.Get(secTask.TalentPostAddrSnap, "detail_addr"), "") + " " + conv.MustString(gjson.Get(secTask.TalentPostAddrSnap, "receiver_name"), "") + " " + conv.MustString(gjson.Get(secTask.TalentPostAddrSnap, "phone_number"), ""), CreateDate: conv.MustString(secTask.CreateDate, ""), SelectDate: conv.MustString(secTask.SelectDate, ""), DeliveryDate: conv.MustString(secTask.DeliveryDate, ""), CompleteDate: conv.MustString(secTask.CompleteDate, ""), IsPayReward: secTask.IsPayReward, IsPayPayment: secTask.IsPayPayment, SignedTime: conv.MustString(secTask.SignedTime, "0000"), SaleNum: secTask.SaleNum, FreeStrategyId: secTask.FreeStrategyId, TalentId: secTask.TalentID, ProductId: secTask.ProductId, } } /* type T struct { DoorNum int `json:"door_num"` TalentId string `json:"talent_id"` AddressId int `json:"address_id"` DefaultTag int `json:"default_tag"` DetailAddr string `json:"detail_addr"` RegionCode int `json:"region_code"` PhoneNumber string `json:"phone_number"` ReceiverName string `json:"receiver_name"` } */