package logic import ( "app.yhyue.com/moapp/jyInfo/rpc/common/common" "app.yhyue.com/moapp/jyInfo/rpc/common/internal/svc" md "app.yhyue.com/moapp/jyInfo/rpc/model" common2 "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 *common.ProjectReq) (*common.IndustryResp, error) { var resp common.IndustryResp data := *md.Mysql.Find("infotype", map[string]interface{}{}, "", "", -1, 0) var rData common.Idata var industrys []*common.Industry var supplys []*common.Supply var infotype []*common.Infotype infotypes := []map[string]interface{}{} for _, v := range data { if common2.Int64All(v["type"]) == 4 { var industry common.Industry industry.Name = common2.InterfaceToStr(v["name"]) industrys = append(industrys, &industry) } else if common2.Int64All(v["type"]) == 3 { var supply common.Supply supply.Name = common2.InterfaceToStr(v["name"]) supplys = append(supplys, &supply) } else if common2.Int64All(v["type"]) == 1 { var info common.Infotype info.Id = common2.Int64All(v["id"]) info.Name = common2.InterfaceToStr(v["name"]) infotype = append(infotype, &info) } else { infotypes = append(infotypes, v) } } for _, info := range infotype { var childs []*common.IndustryChildsResp for _, i := range infotypes { if i["pid"] == info.Id { var child common.IndustryChildsResp child.Name = common2.InterfaceToStr(i["name"]) childs = append(childs, &child) } } info.Childs = childs } rData.Industry = industrys rData.Supply = supplys rData.Infotype = infotype resp.Data = &rData return &resp, nil }