classify.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. package report
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "hongze/hongze_yb/controller/response"
  5. "hongze/hongze_yb/models/request"
  6. "hongze/hongze_yb/models/tables/rddp/classify_menu"
  7. reportService "hongze/hongze_yb/services/report"
  8. userService "hongze/hongze_yb/services/user"
  9. "hongze/hongze_yb/utils"
  10. "strconv"
  11. )
  12. // ClassifyList 专栏列表
  13. func ClassifyList(c *gin.Context) {
  14. reqClassifyIdFirst := c.DefaultQuery("classify_id_first", "")
  15. if reqClassifyIdFirst == "" {
  16. response.Fail("请输入二级分类标识", c)
  17. return
  18. }
  19. classifyIdFirst, err := strconv.Atoi(reqClassifyIdFirst)
  20. if err != nil {
  21. response.Fail("请输入正确的二级分类标识", c)
  22. return
  23. }
  24. userinfo := userService.GetInfoByClaims(c)
  25. classList, err := reportService.GetClassListByClassifyId(userinfo, classifyIdFirst)
  26. if err != nil {
  27. response.Fail(err.Error(), c)
  28. return
  29. }
  30. response.OkData("查询成功", classList, c)
  31. return
  32. }
  33. // ClassifyDetail 专栏详情
  34. func ClassifyDetail(c *gin.Context) {
  35. reqClassifyIdSecond := c.DefaultQuery("classify_id_second", "")
  36. if reqClassifyIdSecond == "" {
  37. response.Fail("请输入二级分类标识", c)
  38. return
  39. }
  40. classifyIdSecond, err := strconv.Atoi(reqClassifyIdSecond)
  41. if err != nil {
  42. response.Fail("请输入正确的二级分类标识", c)
  43. return
  44. }
  45. userinfo := userService.GetInfoByClaims(c)
  46. detail, err := reportService.GetClassifyDetail(userinfo, classifyIdSecond)
  47. if err != nil {
  48. response.Fail(err.Error(), c)
  49. return
  50. }
  51. response.OkData("查询成功", detail, c)
  52. return
  53. }
  54. // ClassifyDetailReports 专栏目录列表
  55. func ClassifyDetailReports(c *gin.Context) {
  56. reqClassifyIdSecond := c.DefaultQuery("classify_id_second", "")
  57. reqPageIndex := c.DefaultQuery("current_index", "1")
  58. reqPageSize := c.DefaultQuery("page_size", strconv.Itoa(utils.PageSize20))
  59. pageIndex, err := strconv.Atoi(reqPageIndex)
  60. if err != nil {
  61. response.Fail("请输入正确的条数限制", c)
  62. return
  63. }
  64. pageSize, err := strconv.Atoi(reqPageSize)
  65. if err != nil {
  66. response.Fail("请输入正确的页码", c)
  67. return
  68. }
  69. if reqClassifyIdSecond == "" {
  70. response.Fail("请输入二级分类标识", c)
  71. return
  72. }
  73. classifyIdSecond, err := strconv.Atoi(reqClassifyIdSecond)
  74. if err != nil {
  75. response.Fail("请输入正确的二级分类标识", c)
  76. return
  77. }
  78. userinfo := userService.GetInfoByClaims(c)
  79. detail, err := reportService.GetClassifyReportList(userinfo, classifyIdSecond, pageIndex, pageSize)
  80. if err != nil {
  81. response.Fail(err.Error(), c)
  82. return
  83. }
  84. response.OkData("查询成功", detail, c)
  85. return
  86. }
  87. // ClassifySimpleList 简单查询二级分类名称列表
  88. func ClassifySimpleList(c *gin.Context) {
  89. reqClassifyIdFirst := c.DefaultQuery("classify_id_first", "")
  90. if reqClassifyIdFirst == "" {
  91. response.Fail("请输入分类ID", c)
  92. return
  93. }
  94. classifyIdFirst, err := strconv.Atoi(reqClassifyIdFirst)
  95. if err != nil {
  96. response.Fail("分类ID格式错误", c)
  97. return
  98. }
  99. userinfo := userService.GetInfoByClaims(c)
  100. classList, err := reportService.GetClassifySecondSimpleList(userinfo, classifyIdFirst)
  101. if err != nil {
  102. response.Fail(err.Error(), c)
  103. return
  104. }
  105. response.OkData("查询成功", classList, c)
  106. return
  107. }
  108. // ClassifyFirstList Ficc 菜单
  109. func ClassifyFirstList(c *gin.Context) {
  110. userinfo := userService.GetInfoByClaims(c)
  111. classList, err := reportService.GetClassifyFirstList(userinfo)
  112. if err != nil {
  113. response.Fail(err.Error(), c)
  114. return
  115. }
  116. response.OkData("查询成功", classList, c)
  117. return
  118. }
  119. // ClassifyMenuList 一级分类-子目录列表
  120. func ClassifyMenuList(c *gin.Context) {
  121. var req request.ClassifyMenuReq
  122. if err := c.Bind(&req); err != nil {
  123. response.Fail("参数有误", c)
  124. return
  125. }
  126. if req.ClassifyId <= 0 {
  127. response.Fail("参数有误", c)
  128. return
  129. }
  130. list, e := classify_menu.GetMenuListByClassifyId(req.ClassifyId)
  131. if e != nil {
  132. response.FailMsg("获取失败", "获取一级分类子目录列表失败, Err: "+e.Error(), c)
  133. return
  134. }
  135. response.OkData("获取成功", list, c)
  136. }