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.

111 lines
3.6 KiB

  1. package v1
  2. import (
  3. "fmt"
  4. "gin-vue-admin/global/response"
  5. "gin-vue-admin/model"
  6. "gin-vue-admin/model/request"
  7. resp "gin-vue-admin/model/response"
  8. "gin-vue-admin/service"
  9. "github.com/gin-gonic/gin"
  10. )
  11. // @Tags SysDictionary
  12. // @Summary 创建SysDictionary
  13. // @Security ApiKeyAuth
  14. // @accept application/json
  15. // @Produce application/json
  16. // @Param data body model.SysDictionary true "创建SysDictionary"
  17. // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
  18. // @Router /sysDictionary/createSysDictionary [post]
  19. func CreateSysDictionary(c *gin.Context) {
  20. var sysDictionary model.SysDictionary
  21. _ = c.ShouldBindJSON(&sysDictionary)
  22. err := service.CreateSysDictionary(sysDictionary)
  23. if err != nil {
  24. response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
  25. } else {
  26. response.OkWithMessage("创建成功", c)
  27. }
  28. }
  29. // @Tags SysDictionary
  30. // @Summary 删除SysDictionary
  31. // @Security ApiKeyAuth
  32. // @accept application/json
  33. // @Produce application/json
  34. // @Param data body model.SysDictionary true "删除SysDictionary"
  35. // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
  36. // @Router /sysDictionary/deleteSysDictionary [delete]
  37. func DeleteSysDictionary(c *gin.Context) {
  38. var sysDictionary model.SysDictionary
  39. _ = c.ShouldBindJSON(&sysDictionary)
  40. err := service.DeleteSysDictionary(sysDictionary)
  41. if err != nil {
  42. response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
  43. } else {
  44. response.OkWithMessage("删除成功", c)
  45. }
  46. }
  47. // @Tags SysDictionary
  48. // @Summary 更新SysDictionary
  49. // @Security ApiKeyAuth
  50. // @accept application/json
  51. // @Produce application/json
  52. // @Param data body model.SysDictionary true "更新SysDictionary"
  53. // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
  54. // @Router /sysDictionary/updateSysDictionary [put]
  55. func UpdateSysDictionary(c *gin.Context) {
  56. var sysDictionary model.SysDictionary
  57. _ = c.ShouldBindJSON(&sysDictionary)
  58. err := service.UpdateSysDictionary(&sysDictionary)
  59. if err != nil {
  60. response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c)
  61. } else {
  62. response.OkWithMessage("更新成功", c)
  63. }
  64. }
  65. // @Tags SysDictionary
  66. // @Summary 用id查询SysDictionary
  67. // @Security ApiKeyAuth
  68. // @accept application/json
  69. // @Produce application/json
  70. // @Param data body model.SysDictionary true "用id查询SysDictionary"
  71. // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
  72. // @Router /sysDictionary/findSysDictionary [get]
  73. func FindSysDictionary(c *gin.Context) {
  74. var sysDictionary model.SysDictionary
  75. _ = c.ShouldBindQuery(&sysDictionary)
  76. err, resysDictionary := service.GetSysDictionary(sysDictionary.Type, sysDictionary.ID)
  77. if err != nil {
  78. response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c)
  79. } else {
  80. response.OkWithData(gin.H{"resysDictionary": resysDictionary}, c)
  81. }
  82. }
  83. // @Tags SysDictionary
  84. // @Summary 分页获取SysDictionary列表
  85. // @Security ApiKeyAuth
  86. // @accept application/json
  87. // @Produce application/json
  88. // @Param data body request.SysDictionarySearch true "分页获取SysDictionary列表"
  89. // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
  90. // @Router /sysDictionary/getSysDictionaryList [get]
  91. func GetSysDictionaryList(c *gin.Context) {
  92. var pageInfo request.SysDictionarySearch
  93. _ = c.ShouldBindQuery(&pageInfo)
  94. err, list, total := service.GetSysDictionaryInfoList(pageInfo)
  95. if err != nil {
  96. response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
  97. } else {
  98. response.OkWithData(resp.PageResult{
  99. List: list,
  100. Total: total,
  101. Page: pageInfo.Page,
  102. PageSize: pageInfo.PageSize,
  103. }, c)
  104. }
  105. }