package company import "github.com/beego/beego/v2/client/orm" type CompanyIndustry struct { IndustryId int `description:"行业id"` IndustryName string `description:"行业名称"` ParentId int `description:"父级id"` Classify string `description:"分类"` } type CompanyIndustryItem struct { IndustryId int `description:"行业id"` IndustryName string `description:"行业名称"` Classify string `description:"分类"` Children []*CompanyIndustryItemSub `json:"children"` } type CompanyIndustryItemSub struct { IndustryId int `description:"行业id"` IndustryName string `description:"行业名称"` Classify string `description:"分类"` } type CompanyIndustryResp struct { List []*CompanyIndustryItem } func GetCompanyIndustry(productName string) (items []*CompanyIndustryItem, err error) { o := orm.NewOrm() sql := `SELECT * FROM company_industry WHERE product_name=? AND parent_id=0 ORDER BY industry_id ASC` _, err = o.Raw(sql, productName).QueryRows(&items) return } func GetCompanyIndustryChildren(classify string, parentId int) (items []*CompanyIndustryItemSub, err error) { o := orm.NewOrm() sql := `SELECT * FROM company_industry WHERE product_name=? AND parent_id=? ORDER BY industry_id ASC` _, err = o.Raw(sql, classify, parentId).QueryRows(&items) return } func GetCompanyIndustryById(industryId int) (items *CompanyIndustry, err error) { o := orm.NewOrm() sql := `SELECT * FROM company_industry WHERE industry_id=? ` err = o.Raw(sql, industryId).QueryRow(&items) return }