sys_dictionary_detail.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package system
  2. import (
  3. "github.com/flipped-aurora/gin-vue-admin/server/global"
  4. "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
  5. "github.com/flipped-aurora/gin-vue-admin/server/model/system"
  6. "github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
  7. "github.com/flipped-aurora/gin-vue-admin/server/utils"
  8. "github.com/gin-gonic/gin"
  9. "go.uber.org/zap"
  10. )
  11. type DictionaryDetailApi struct {
  12. }
  13. // @Tags SysDictionaryDetail
  14. // @Summary 创建SysDictionaryDetail
  15. // @Security ApiKeyAuth
  16. // @accept application/json
  17. // @Produce application/json
  18. // @Param data body system.SysDictionaryDetail true "SysDictionaryDetail模型"
  19. // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
  20. // @Router /sysDictionaryDetail/createSysDictionaryDetail [post]
  21. func (s *DictionaryDetailApi) CreateSysDictionaryDetail(c *gin.Context) {
  22. var detail system.SysDictionaryDetail
  23. _ = c.ShouldBindJSON(&detail)
  24. if err := dictionaryDetailService.CreateSysDictionaryDetail(detail); err != nil {
  25. global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
  26. response.FailWithMessage("创建失败", c)
  27. } else {
  28. response.OkWithMessage("创建成功", c)
  29. }
  30. }
  31. // @Tags SysDictionaryDetail
  32. // @Summary 删除SysDictionaryDetail
  33. // @Security ApiKeyAuth
  34. // @accept application/json
  35. // @Produce application/json
  36. // @Param data body system.SysDictionaryDetail true "SysDictionaryDetail模型"
  37. // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
  38. // @Router /sysDictionaryDetail/deleteSysDictionaryDetail [delete]
  39. func (s *DictionaryDetailApi) DeleteSysDictionaryDetail(c *gin.Context) {
  40. var detail system.SysDictionaryDetail
  41. _ = c.ShouldBindJSON(&detail)
  42. if err := dictionaryDetailService.DeleteSysDictionaryDetail(detail); err != nil {
  43. global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
  44. response.FailWithMessage("删除失败", c)
  45. } else {
  46. response.OkWithMessage("删除成功", c)
  47. }
  48. }
  49. // @Tags SysDictionaryDetail
  50. // @Summary 更新SysDictionaryDetail
  51. // @Security ApiKeyAuth
  52. // @accept application/json
  53. // @Produce application/json
  54. // @Param data body system.SysDictionaryDetail true "更新SysDictionaryDetail"
  55. // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
  56. // @Router /sysDictionaryDetail/updateSysDictionaryDetail [put]
  57. func (s *DictionaryDetailApi) UpdateSysDictionaryDetail(c *gin.Context) {
  58. var detail system.SysDictionaryDetail
  59. _ = c.ShouldBindJSON(&detail)
  60. if err := dictionaryDetailService.UpdateSysDictionaryDetail(&detail); err != nil {
  61. global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
  62. response.FailWithMessage("更新失败", c)
  63. } else {
  64. response.OkWithMessage("更新成功", c)
  65. }
  66. }
  67. // @Tags SysDictionaryDetail
  68. // @Summary 用id查询SysDictionaryDetail
  69. // @Security ApiKeyAuth
  70. // @accept application/json
  71. // @Produce application/json
  72. // @Param data query system.SysDictionaryDetail true "用id查询SysDictionaryDetail"
  73. // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
  74. // @Router /sysDictionaryDetail/findSysDictionaryDetail [get]
  75. func (s *DictionaryDetailApi) FindSysDictionaryDetail(c *gin.Context) {
  76. var detail system.SysDictionaryDetail
  77. _ = c.ShouldBindQuery(&detail)
  78. if err := utils.Verify(detail, utils.IdVerify); err != nil {
  79. response.FailWithMessage(err.Error(), c)
  80. return
  81. }
  82. if err, resysDictionaryDetail := dictionaryDetailService.GetSysDictionaryDetail(detail.ID); err != nil {
  83. global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
  84. response.FailWithMessage("查询失败", c)
  85. } else {
  86. response.OkWithDetailed(gin.H{"resysDictionaryDetail": resysDictionaryDetail}, "查询成功", c)
  87. }
  88. }
  89. // @Tags SysDictionaryDetail
  90. // @Summary 分页获取SysDictionaryDetail列表
  91. // @Security ApiKeyAuth
  92. // @accept application/json
  93. // @Produce application/json
  94. // @Param data query request.SysDictionaryDetailSearch true "页码, 每页大小, 搜索条件"
  95. // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
  96. // @Router /sysDictionaryDetail/getSysDictionaryDetailList [get]
  97. func (s *DictionaryDetailApi) GetSysDictionaryDetailList(c *gin.Context) {
  98. var pageInfo request.SysDictionaryDetailSearch
  99. _ = c.ShouldBindQuery(&pageInfo)
  100. if err, list, total := dictionaryDetailService.GetSysDictionaryDetailInfoList(pageInfo); err != nil {
  101. global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
  102. response.FailWithMessage("获取失败", c)
  103. } else {
  104. response.OkWithDetailed(response.PageResult{
  105. List: list,
  106. Total: total,
  107. Page: pageInfo.Page,
  108. PageSize: pageInfo.PageSize,
  109. }, "获取成功", c)
  110. }
  111. }