You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
4.4 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. package system
  2. import (
  3. "gin-vue-admin/global"
  4. "gin-vue-admin/model/common/response"
  5. "gin-vue-admin/model/system"
  6. "gin-vue-admin/model/system/request"
  7. "gin-vue-admin/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 model.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 model.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 model.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 body model.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 body 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. }