package pack import ( "github.com/tidwall/gjson" "youngee_b_api/model/http_model" "github.com/issue9/conv" ) func MGormProjectTalentToHttpProjectTaskPreview(gormProjectTalentInfos []*http_model.ProjectTalentInfo) []*http_model.ProjectTalentPreview { var httpProjectPreviews []*http_model.ProjectTalentPreview for _, gormProjectTalentInfo := range gormProjectTalentInfos { httpProjectTalentPreview := GormFullProjectToHttpProjectTalentPreview(gormProjectTalentInfo) httpProjectPreviews = append(httpProjectPreviews, httpProjectTalentPreview) } return httpProjectPreviews } func GormFullProjectToHttpProjectTalentPreview(projectTalentInfo *http_model.ProjectTalentInfo) *http_model.ProjectTalentPreview { deliveryTime := conv.MustString(projectTalentInfo.DeliveryTime) deliveryTime = deliveryTime[0:19] return &http_model.ProjectTalentPreview{ TaskID: conv.MustString(projectTalentInfo.TaskID), PlatformNickname: conv.MustString(projectTalentInfo.PlatformNickname), FansCount: conv.MustString(projectTalentInfo.FansCount), StrategyID: conv.MustString(projectTalentInfo.StrategyID), DetailAddr: conv.MustString(projectTalentInfo.DetailAddr), CompanyName: conv.MustString(projectTalentInfo.CompanyName), LogisticsNumber: conv.MustString(projectTalentInfo.LogisticsNumber), DeliveryTime: deliveryTime, ExplorestorePeriod: conv.MustString(projectTalentInfo.ExplorestorePeriod), } } func TalentAccountToTaskInfo(talentAccounts []*http_model.TalentAccount) []*http_model.ProjectTalentInfo { var projectTalents []*http_model.ProjectTalentInfo for _, talentAccount := range talentAccounts { projectTalent := GetTalentInfoStruct(talentAccount) projectTalents = append(projectTalents, projectTalent) } return projectTalents } func GetTalentInfoStruct(talentAccount *http_model.TalentAccount) *http_model.ProjectTalentInfo { TalentPlatformInfoSnap := talentAccount.Talent.TalentPlatformInfoSnap TalentPostAddrSnap := talentAccount.Talent.TalentPostAddrSnap return &http_model.ProjectTalentInfo{ TaskID: talentAccount.Talent.TaskID, PlatformNickname: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "PlatformInfo.platform_name")), FansCount: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "fans_count")), StrategyID: talentAccount.Talent.StrategyID, DetailAddr: conv.MustString(gjson.Get(TalentPostAddrSnap, "detail_addr")), CompanyName: talentAccount.Logistics.CompanyName, LogisticsNumber: talentAccount.Logistics.LogisticsNumber, DeliveryTime: talentAccount.Logistics.DeliveryTime, ExplorestorePeriod: talentAccount.Logistics.ExplorestorePeriod, } }