1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- package controllers
- import (
- "hongze/hz_crm_api/models"
- "hongze/hz_crm_api/models/company"
- "hongze/hz_crm_api/utils"
- )
- // 行业管理
- type CompanyIndustryController struct {
- BaseAuthController
- }
- // @Title 根据客户类型获取行业列表
- // @Description 根据客户类型获取行业列表接口
- // @Param Classify query string true "客户类型:ficc,合作伙伴,权益"
- // @Success 200 {object} models.CompanyIndustryResp
- // @router /industry/list [get]
- func (this *CompanyIndustryController) List() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- roleCodeType := sysUser.RoleTypeCode
- classify := this.GetString("Classify")
- if classify == "" {
- if roleCodeType == utils.ROLE_TYPE_CODE_FICC_ADMIN || roleCodeType == utils.ROLE_TYPE_CODE_FICC_SELLER {
- classify = utils.COMPANY_CLASSIFY_FICC
- } else if roleCodeType == utils.ROLE_TYPE_CODE_RAI_SELLER || roleCodeType == utils.ROLE_TYPE_CODE_RAI_ADMIN {
- classify = utils.COMPANY_CLASSIFY_RAI
- }
- }
- list, err := company.GetCompanyIndustry(classify)
- if err != nil {
- br.Msg = "获取行业数据失败"
- br.ErrMsg = "获取行业数据失败,Err:" + err.Error()
- return
- }
- lenList := len(list)
- for i := 0; i < lenList; i++ {
- child, err := company.GetCompanyIndustryChildren(classify, list[i].IndustryId)
- if err != nil {
- br.Msg = "获取行业数据失败"
- br.ErrMsg = "获取行业数据失败,Err:" + err.Error()
- return
- }
- list[i].Children = child
- }
- if lenList <= 0 {
- list = make([]*company.CompanyIndustryItem, 0)
- }
- resp := new(company.CompanyIndustryResp)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|