company_industry.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package controllers
  2. import (
  3. "hongze/hz_crm_api/models"
  4. "hongze/hz_crm_api/models/company"
  5. "hongze/hz_crm_api/utils"
  6. )
  7. // 行业管理
  8. type CompanyIndustryController struct {
  9. BaseAuthController
  10. }
  11. // @Title 根据客户类型获取行业列表
  12. // @Description 根据客户类型获取行业列表接口
  13. // @Param Classify query string true "客户类型:ficc,合作伙伴,权益"
  14. // @Success 200 {object} models.CompanyIndustryResp
  15. // @router /industry/list [get]
  16. func (this *CompanyIndustryController) List() {
  17. br := new(models.BaseResponse).Init()
  18. defer func() {
  19. this.Data["json"] = br
  20. this.ServeJSON()
  21. }()
  22. sysUser := this.SysUser
  23. if sysUser == nil {
  24. br.Msg = "请登录"
  25. br.ErrMsg = "请登录,SysUser Is Empty"
  26. br.Ret = 408
  27. return
  28. }
  29. roleCodeType := sysUser.RoleTypeCode
  30. classify := this.GetString("Classify")
  31. if classify == "" {
  32. if roleCodeType == utils.ROLE_TYPE_CODE_FICC_ADMIN || roleCodeType == utils.ROLE_TYPE_CODE_FICC_SELLER {
  33. classify = utils.COMPANY_CLASSIFY_FICC
  34. } else if roleCodeType == utils.ROLE_TYPE_CODE_RAI_SELLER || roleCodeType == utils.ROLE_TYPE_CODE_RAI_ADMIN {
  35. classify = utils.COMPANY_CLASSIFY_RAI
  36. }
  37. }
  38. list, err := company.GetCompanyIndustry(classify)
  39. if err != nil {
  40. br.Msg = "获取行业数据失败"
  41. br.ErrMsg = "获取行业数据失败,Err:" + err.Error()
  42. return
  43. }
  44. lenList := len(list)
  45. for i := 0; i < lenList; i++ {
  46. child, err := company.GetCompanyIndustryChildren(classify, list[i].IndustryId)
  47. if err != nil {
  48. br.Msg = "获取行业数据失败"
  49. br.ErrMsg = "获取行业数据失败,Err:" + err.Error()
  50. return
  51. }
  52. list[i].Children = child
  53. }
  54. if lenList <= 0 {
  55. list = make([]*company.CompanyIndustryItem, 0)
  56. }
  57. resp := new(company.CompanyIndustryResp)
  58. resp.List = list
  59. br.Ret = 200
  60. br.Success = true
  61. br.Msg = "获取成功"
  62. br.Data = resp
  63. }