package logic import ( "app.yhyue.com/moapp/jyInfo/rpc/common/commoninfo" "app.yhyue.com/moapp/jyInfo/rpc/common/internal/svc" md "app.yhyue.com/moapp/jyInfo/rpc/model" mc "app.yhyue.com/moapp/jybase/common" "context" "github.com/zeromicro/go-zero/core/logx" ) type IndustryInfoLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewIndustryInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *IndustryInfoLogic { return &IndustryInfoLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } // 获取行业信息 func (l *IndustryInfoLogic) IndustryInfo(in *commoninfo.ProjectReq) (*commoninfo.IndustryResp, error) { var resp commoninfo.IndustryResp data := *md.Mysql.Find("infotype", map[string]interface{}{}, "", "", -1, 0) var rData commoninfo.Idata var industrys []*commoninfo.Industry var supplys []*commoninfo.Supply var infotype []*commoninfo.Infotype infotypes := []map[string]interface{}{} for _, v := range data { if mc.Int64All(v["type"]) == 4 { var industry commoninfo.Industry industry.Name = mc.InterfaceToStr(v["name"]) industrys = append(industrys, &industry) } else if mc.Int64All(v["type"]) == 3 { var supply commoninfo.Supply supply.Name = mc.InterfaceToStr(v["name"]) supplys = append(supplys, &supply) } else if mc.Int64All(v["type"]) == 1 { var info commoninfo.Infotype info.Id = mc.Int64All(v["id"]) info.Name = mc.InterfaceToStr(v["name"]) infotype = append(infotype, &info) } else { infotypes = append(infotypes, v) } } for _, info := range infotype { var childs []*commoninfo.IndustryChildsResp for _, i := range infotypes { if i["pid"] == info.Id { var child commoninfo.IndustryChildsResp child.Name = mc.InterfaceToStr(i["name"]) childs = append(childs, &child) } } info.Childs = childs } rData.Industry = industrys rData.Buyerclass = supplys rData.Infotype = infotype resp.Data = &rData return &resp, nil }