sys_dictionary_detail.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. package system
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "lc-base-frame/model/common/response"
  6. "lc-base-frame/model/system"
  7. "lc-base-frame/model/system/request"
  8. "lc-base-frame/utils"
  9. )
  10. type DictionaryDetailApi struct{}
  11. // CreateSysDictionaryDetail
  12. // @Tags SysDictionaryDetail
  13. // @Summary 创建SysDictionaryDetail
  14. // @Security ApiKeyAuth
  15. // @accept application/json
  16. // @Produce application/json
  17. // @Param data body system.SysDictionaryDetail true "SysDictionaryDetail模型"
  18. // @Success 200 {object} response.Response{msg=string} "创建SysDictionaryDetail"
  19. // @Router /sysDictionaryDetail/createSysDictionaryDetail [post]
  20. func (s *DictionaryDetailApi) CreateSysDictionaryDetail(c *gin.Context) {
  21. var detail system.SysDictionaryDetail
  22. err := c.ShouldBindJSON(&detail)
  23. if err != nil {
  24. response.FailWithMessage(err.Error(), c)
  25. return
  26. }
  27. err = dictionaryDetailService.CreateSysDictionaryDetail(detail)
  28. if err != nil {
  29. logrus.Error("创建失败!", err)
  30. response.FailWithMessage("创建失败", c)
  31. return
  32. }
  33. response.OkWithMessage("创建成功", c)
  34. }
  35. // DeleteSysDictionaryDetail
  36. // @Tags SysDictionaryDetail
  37. // @Summary 删除SysDictionaryDetail
  38. // @Security ApiKeyAuth
  39. // @accept application/json
  40. // @Produce application/json
  41. // @Param data body system.SysDictionaryDetail true "SysDictionaryDetail模型"
  42. // @Success 200 {object} response.Response{msg=string} "删除SysDictionaryDetail"
  43. // @Router /sysDictionaryDetail/deleteSysDictionaryDetail [delete]
  44. func (s *DictionaryDetailApi) DeleteSysDictionaryDetail(c *gin.Context) {
  45. var detail system.SysDictionaryDetail
  46. err := c.ShouldBindJSON(&detail)
  47. if err != nil {
  48. response.FailWithMessage(err.Error(), c)
  49. return
  50. }
  51. err = dictionaryDetailService.DeleteSysDictionaryDetail(detail)
  52. if err != nil {
  53. logrus.Error("删除失败!", err)
  54. response.FailWithMessage("删除失败", c)
  55. return
  56. }
  57. response.OkWithMessage("删除成功", c)
  58. }
  59. // UpdateSysDictionaryDetail
  60. // @Tags SysDictionaryDetail
  61. // @Summary 更新SysDictionaryDetail
  62. // @Security ApiKeyAuth
  63. // @accept application/json
  64. // @Produce application/json
  65. // @Param data body system.SysDictionaryDetail true "更新SysDictionaryDetail"
  66. // @Success 200 {object} response.Response{msg=string} "更新SysDictionaryDetail"
  67. // @Router /sysDictionaryDetail/updateSysDictionaryDetail [put]
  68. func (s *DictionaryDetailApi) UpdateSysDictionaryDetail(c *gin.Context) {
  69. var detail system.SysDictionaryDetail
  70. err := c.ShouldBindJSON(&detail)
  71. if err != nil {
  72. response.FailWithMessage(err.Error(), c)
  73. return
  74. }
  75. err = dictionaryDetailService.UpdateSysDictionaryDetail(&detail)
  76. if err != nil {
  77. logrus.Error("更新失败!", err)
  78. response.FailWithMessage("更新失败", c)
  79. return
  80. }
  81. response.OkWithMessage("更新成功", c)
  82. }
  83. // FindSysDictionaryDetail
  84. // @Tags SysDictionaryDetail
  85. // @Summary 用id查询SysDictionaryDetail
  86. // @Security ApiKeyAuth
  87. // @accept application/json
  88. // @Produce application/json
  89. // @Param data query system.SysDictionaryDetail true "用id查询SysDictionaryDetail"
  90. // @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "用id查询SysDictionaryDetail"
  91. // @Router /sysDictionaryDetail/findSysDictionaryDetail [get]
  92. func (s *DictionaryDetailApi) FindSysDictionaryDetail(c *gin.Context) {
  93. var detail system.SysDictionaryDetail
  94. err := c.ShouldBindQuery(&detail)
  95. if err != nil {
  96. response.FailWithMessage(err.Error(), c)
  97. return
  98. }
  99. err = utils.Verify(detail, utils.IdVerify)
  100. if err != nil {
  101. response.FailWithMessage(err.Error(), c)
  102. return
  103. }
  104. reSysDictionaryDetail, err := dictionaryDetailService.GetSysDictionaryDetail(detail.ID)
  105. if err != nil {
  106. logrus.Error("查询失败!", err)
  107. response.FailWithMessage("查询失败", c)
  108. return
  109. }
  110. response.OkWithDetailed(gin.H{"reSysDictionaryDetail": reSysDictionaryDetail}, "查询成功", c)
  111. }
  112. // GetSysDictionaryDetailList
  113. // @Tags SysDictionaryDetail
  114. // @Summary 分页获取SysDictionaryDetail列表
  115. // @Security ApiKeyAuth
  116. // @accept application/json
  117. // @Produce application/json
  118. // @Param data query request.SysDictionaryDetailSearch true "页码, 每页大小, 搜索条件"
  119. // @Success 200 {object} response.Response{data=response.PageResult,msg=string} "分页获取SysDictionaryDetail列表,返回包括列表,总数,页码,每页数量"
  120. // @Router /sysDictionaryDetail/getSysDictionaryDetailList [get]
  121. func (s *DictionaryDetailApi) GetSysDictionaryDetailList(c *gin.Context) {
  122. var pageInfo request.SysDictionaryDetailSearch
  123. err := c.ShouldBindQuery(&pageInfo)
  124. if err != nil {
  125. response.FailWithMessage(err.Error(), c)
  126. return
  127. }
  128. list, total, err := dictionaryDetailService.GetSysDictionaryDetailInfoList(pageInfo)
  129. if err != nil {
  130. logrus.Error("获取失败!", err)
  131. response.FailWithMessage("获取失败", c)
  132. return
  133. }
  134. response.OkWithDetailed(response.PageResult{
  135. List: list,
  136. Total: total,
  137. Page: pageInfo.Page,
  138. PageSize: pageInfo.PageSize,
  139. }, "获取成功", c)
  140. }