package officialWebsiteser import "91porn-server/models/v/officialWebsitemod" type BusinessListReq struct{} type BusinessListResp struct { Total int64 `json:"total"` ADPlacement []BusinessInfo `json:"adPlacement"` ContentProduction []BusinessInfo `json:"contentProduction"` SubRevenue []BusinessInfo `json:"subRevenue"` } type BusinessInfo struct { Title string `json:"title"` Description string `json:"description"` Type string `json:"type"` // 业务类型,如"adPlacement", "contentProduction", "subRevenue" ServiceOverview string `json:"serviceOverview"` CollaborationProcess string `json:"collaborationProcess"` CaseStudies string `json:"caseStudies"` } func BusinessList(req *BusinessListReq) (resp BusinessListResp, err error) { data, err := (&officialWebsitemod.BusinessData{}).FindMany(nil) if err != nil { return } resp = BusinessListResp{ Total: int64(len(data)), ADPlacement: make([]BusinessInfo, 0), ContentProduction: make([]BusinessInfo, 0), SubRevenue: make([]BusinessInfo, 0), } for _, v := range data { switch v.Type { case "adPlacement": resp.ADPlacement = append(resp.ADPlacement, BusinessInfo{ Title: v.Title, Description: v.Description, Type: v.Type, ServiceOverview: v.ServiceOverview, CollaborationProcess: v.CollaborationProcess, CaseStudies: v.CaseStudies, }) case "contentProduction": resp.ContentProduction = append(resp.ContentProduction, BusinessInfo{ Title: v.Title, Description: v.Description, Type: v.Type, ServiceOverview: v.ServiceOverview, CollaborationProcess: v.CollaborationProcess, CaseStudies: v.CaseStudies, }) case "subRevenue": resp.SubRevenue = append(resp.SubRevenue, BusinessInfo{ Title: v.Title, Description: v.Description, Type: v.Type, ServiceOverview: v.ServiceOverview, CollaborationProcess: v.CollaborationProcess, CaseStudies: v.CaseStudies, }) } } return resp, nil }