server/api/v1层代码swagger备注错误修改及代码优化
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gin-vue-admin/global/response"
|
||||
"gin-vue-admin/global"
|
||||
"gin-vue-admin/model"
|
||||
"gin-vue-admin/model/request"
|
||||
resp "gin-vue-admin/model/response"
|
||||
"gin-vue-admin/model/response"
|
||||
"gin-vue-admin/service"
|
||||
"gin-vue-admin/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// @Tags SysDictionary
|
||||
@@ -15,15 +16,15 @@ import (
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body model.SysDictionary true "创建SysDictionary"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Param data body model.SysDictionary true "SysDictionary模型"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
|
||||
// @Router /sysDictionary/createSysDictionary [post]
|
||||
func CreateSysDictionary(c *gin.Context) {
|
||||
var sysDictionary model.SysDictionary
|
||||
_ = c.ShouldBindJSON(&sysDictionary)
|
||||
err := service.CreateSysDictionary(sysDictionary)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
|
||||
var dictionary model.SysDictionary
|
||||
_ = c.ShouldBindJSON(&dictionary)
|
||||
if err := service.CreateSysDictionary(dictionary); err != nil {
|
||||
global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
|
||||
response.FailWithMessage("创建失败", c)
|
||||
} else {
|
||||
response.OkWithMessage("创建成功", c)
|
||||
}
|
||||
@@ -34,15 +35,15 @@ func CreateSysDictionary(c *gin.Context) {
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body model.SysDictionary true "删除SysDictionary"
|
||||
// @Param data body model.SysDictionary true "SysDictionary模型"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
||||
// @Router /sysDictionary/deleteSysDictionary [delete]
|
||||
func DeleteSysDictionary(c *gin.Context) {
|
||||
var sysDictionary model.SysDictionary
|
||||
_ = c.ShouldBindJSON(&sysDictionary)
|
||||
err := service.DeleteSysDictionary(sysDictionary)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
|
||||
var dictionary model.SysDictionary
|
||||
_ = c.ShouldBindJSON(&dictionary)
|
||||
if err := service.DeleteSysDictionary(dictionary); err != nil {
|
||||
global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
|
||||
response.FailWithMessage("删除失败", c)
|
||||
} else {
|
||||
response.OkWithMessage("删除成功", c)
|
||||
}
|
||||
@@ -53,15 +54,15 @@ func DeleteSysDictionary(c *gin.Context) {
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body model.SysDictionary true "更新SysDictionary"
|
||||
// @Param data body model.SysDictionary true "SysDictionary模型"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
|
||||
// @Router /sysDictionary/updateSysDictionary [put]
|
||||
func UpdateSysDictionary(c *gin.Context) {
|
||||
var sysDictionary model.SysDictionary
|
||||
_ = c.ShouldBindJSON(&sysDictionary)
|
||||
err := service.UpdateSysDictionary(&sysDictionary)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c)
|
||||
var dictionary model.SysDictionary
|
||||
_ = c.ShouldBindJSON(&dictionary)
|
||||
if err := service.UpdateSysDictionary(&dictionary); err != nil {
|
||||
global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
|
||||
response.FailWithMessage("更新失败", c)
|
||||
} else {
|
||||
response.OkWithMessage("更新成功", c)
|
||||
}
|
||||
@@ -72,17 +73,21 @@ func UpdateSysDictionary(c *gin.Context) {
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body model.SysDictionary true "用id查询SysDictionary"
|
||||
// @Param data body model.SysDictionary true "ID或字典英名"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
|
||||
// @Router /sysDictionary/findSysDictionary [get]
|
||||
func FindSysDictionary(c *gin.Context) {
|
||||
var sysDictionary model.SysDictionary
|
||||
_ = c.ShouldBindQuery(&sysDictionary)
|
||||
err, resysDictionary := service.GetSysDictionary(sysDictionary.Type, sysDictionary.ID)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c)
|
||||
var dictionary model.SysDictionary
|
||||
_ = c.ShouldBindQuery(&dictionary)
|
||||
if err := utils.Verify(dictionary, utils.DictionaryVerify); err != nil {
|
||||
response.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
if err, sysDictionary := service.GetSysDictionary(dictionary.Type, dictionary.ID); err != nil {
|
||||
global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
|
||||
response.FailWithMessage("查询失败", c)
|
||||
} else {
|
||||
response.OkWithData(gin.H{"resysDictionary": resysDictionary}, c)
|
||||
response.OkWithDetailed(gin.H{"resysDictionary": sysDictionary}, "查询成功", c)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,21 +96,25 @@ func FindSysDictionary(c *gin.Context) {
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body request.SysDictionarySearch true "分页获取SysDictionary列表"
|
||||
// @Param data body request.SysDictionarySearch true "页码, 每页大小, 搜索条件"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /sysDictionary/getSysDictionaryList [get]
|
||||
func GetSysDictionaryList(c *gin.Context) {
|
||||
var pageInfo request.SysDictionarySearch
|
||||
_ = c.ShouldBindQuery(&pageInfo)
|
||||
err, list, total := service.GetSysDictionaryInfoList(pageInfo)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
|
||||
if err := utils.Verify(pageInfo.PageInfo, utils.PageInfoVerify); err != nil {
|
||||
response.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
if err, list, total := service.GetSysDictionaryInfoList(pageInfo); err != nil {
|
||||
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
|
||||
response.FailWithMessage("获取失败", c)
|
||||
} else {
|
||||
response.OkWithData(resp.PageResult{
|
||||
response.OkWithDetailed(response.PageResult{
|
||||
List: list,
|
||||
Total: total,
|
||||
Page: pageInfo.Page,
|
||||
PageSize: pageInfo.PageSize,
|
||||
}, c)
|
||||
}, "获取成功", c)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user