research_group.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package controllers
  2. import (
  3. "eta/eta_api/models"
  4. "eta/eta_api/services"
  5. "eta/eta_api/utils"
  6. )
  7. type ResearchGroupController struct {
  8. BaseAuthController
  9. }
  10. // GetResearchGroupList
  11. // @Title 获取研究方向分组列表
  12. // @Description 获取研究方向分组列表
  13. // @Success 200 {object} services.ResearchGroupItem 获取成功
  14. // @router /research_group/list [get]
  15. func (this *ResearchGroupController) GetResearchGroupList() {
  16. br := new(models.BaseResponse).Init()
  17. defer func() {
  18. this.Data["json"] = br
  19. this.ServeJSON()
  20. }()
  21. if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox && utils.BusinessCode != utils.BusinessCodeDebug {
  22. br.Ret = 200
  23. br.Success = true
  24. br.Msg = "操作成功"
  25. return
  26. }
  27. include, _ := this.GetInt("Include")
  28. list, err := services.GetResearchGroupTree(include)
  29. if err != nil {
  30. br.Msg = "获取分组失败"
  31. br.ErrMsg = "GetResearchGroupList ErrMsg:" + err.Error()
  32. return
  33. }
  34. br.Ret = 200
  35. br.Success = true
  36. br.Msg = "获取成功"
  37. br.Data = list
  38. }
  39. // GetAdminResearchGroup
  40. // @Title 获取研究员研究方向
  41. // @Description 获取研究员研究方向
  42. // @Param AdminId query int true "研究员ID"
  43. // @Success 200 {object} models.ResearchGroupRelation 获取成功
  44. // @router /research_group/admin_group [get]
  45. func (this *ResearchGroupController) GetAdminResearchGroup() {
  46. br := new(models.BaseResponse).Init()
  47. defer func() {
  48. this.Data["json"] = br
  49. this.ServeJSON()
  50. }()
  51. adminId, _ := this.GetInt("AdminId")
  52. if adminId == 0 {
  53. br.Msg = "参数有误"
  54. return
  55. }
  56. if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox && utils.BusinessCode != utils.BusinessCodeDebug {
  57. br.Ret = 200
  58. br.Success = true
  59. br.Msg = "获取成功"
  60. return
  61. }
  62. //list, err := system.ResearchGroupRelationListByAdminId(adminId)
  63. list, err := models.ResearchTagRelationListByAdminId(adminId)
  64. if err != nil {
  65. br.Msg = "获取研究方向失败"
  66. br.ErrMsg = "GetAdminResearchGroup ErrMsg:" + err.Error()
  67. return
  68. }
  69. br.Ret = 200
  70. br.Success = true
  71. br.Msg = "获取成功"
  72. br.Data = list
  73. }