package pack import ( "youngee_b_api/model/http_model" "github.com/tidwall/gjson" "github.com/issue9/conv" ) func MGormTaskLogisticsInfoListToHttpTaskLogisticsPreviewList(gormTaskLogisticsInfos []*http_model.TaskLogisticsInfo) []*http_model.TaskLogisticsPreview { var httpProjectPreviews []*http_model.TaskLogisticsPreview for _, gormTaskLogisticsInfo := range gormTaskLogisticsInfos { httpTaskLogisticsPreview := MGormTaskLogisticsInfoToHttpTaskLogisticsPreview(gormTaskLogisticsInfo) httpProjectPreviews = append(httpProjectPreviews, httpTaskLogisticsPreview) } return httpProjectPreviews } func MGormTaskLogisticsInfoToHttpTaskLogisticsPreview(TaskLogisticsInfo *http_model.TaskLogisticsInfo) *http_model.TaskLogisticsPreview { deliveryTime := conv.MustString(TaskLogisticsInfo.DeliveryTime)[0:19] signedTime := conv.MustString(TaskLogisticsInfo.SignedTime)[0:19] return &http_model.TaskLogisticsPreview{ TaskID: TaskLogisticsInfo.TaskID, PlatformNickname: conv.MustString(TaskLogisticsInfo.PlatformNickname), FansCount: conv.MustString(TaskLogisticsInfo.FansCount), RecruitStrategyID: conv.MustString(TaskLogisticsInfo.RecruitStrategyID), StrategyID: conv.MustString(TaskLogisticsInfo.StrategyID), DetailAddr: conv.MustString(TaskLogisticsInfo.DetailAddr), CompanyName: conv.MustString(TaskLogisticsInfo.CompanyName), LogisticsNumber: conv.MustString(TaskLogisticsInfo.LogisticsNumber), DeliveryTime: deliveryTime, SignedTime: signedTime, ExplorestoreStarttime: TaskLogisticsInfo.ExplorestoreStarttime, ExplorestoreEndtime: TaskLogisticsInfo.ExplorestoreEndtime, ExplorestorePeriod: conv.MustString(TaskLogisticsInfo.ExplorestorePeriod), CouponCode: conv.MustString(TaskLogisticsInfo.CouponCode), } } func TaskLogisticsToTaskInfo(TaskLogisticss []*http_model.TaskLogistics) []*http_model.TaskLogisticsInfo { var TaskLogisticsInfos []*http_model.TaskLogisticsInfo for _, TaskLogistics := range TaskLogisticss { TaskLogistics := GetTalentInfoStruct(TaskLogistics) TaskLogisticsInfos = append(TaskLogisticsInfos, TaskLogistics) } return TaskLogisticsInfos } func GetTalentInfoStruct(TaskLogistics *http_model.TaskLogistics) *http_model.TaskLogisticsInfo { TalentPlatformInfoSnap := TaskLogistics.Talent.TalentPlatformInfoSnap TalentPostAddrSnap := TaskLogistics.Talent.TalentPostAddrSnap return &http_model.TaskLogisticsInfo{ TaskID: TaskLogistics.Talent.TaskID, PlatformNickname: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "platform_nickname")), FansCount: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "fans_count")), StrategyID: TaskLogistics.Talent.StrategyID, DetailAddr: conv.MustString(gjson.Get(TalentPostAddrSnap, "detail_addr")), CompanyName: TaskLogistics.Logistics.CompanyName, LogisticsNumber: TaskLogistics.Logistics.LogisticsNumber, DeliveryTime: conv.MustString(TaskLogistics.Logistics.DeliveryTime), SignedTime: conv.MustString(TaskLogistics.Logistics.SignedTime), ExplorestoreStarttime: TaskLogistics.Logistics.ExplorestoreStarttime, ExplorestoreEndtime: TaskLogistics.Logistics.ExplorestoreEndtime, ExplorestorePeriod: TaskLogistics.Logistics.ExplorestorePeriod, CouponCode: TaskLogistics.Logistics.CouponCodeInformation, } }