Prechádzať zdrojové kódy

server/api/v1层代码swagger备注错误修改及代码优化

SliverHorn 4 rokov pred
rodič
commit
34b1370415

+ 27 - 18
server/api/v1/exa_breakpoint_continue.go

@@ -1,12 +1,12 @@
 package v1
 
 import (
-	"fmt"
-	"gin-vue-admin/global/response"
-	resp "gin-vue-admin/model/response"
+	"gin-vue-admin/global"
+	"gin-vue-admin/model/response"
 	"gin-vue-admin/service"
 	"gin-vue-admin/utils"
 	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
 	"io/ioutil"
 	"strconv"
 )
@@ -17,7 +17,7 @@ import (
 // @accept multipart/form-data
 // @Produce  application/json
 // @Param file formData file true "an example for breakpoint resume, 断点续传示例"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"上传成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"切片创建成功"}"
 // @Router /fileUploadAndDownload/breakpointContinue [post]
 func BreakpointContinue(c *gin.Context) {
 	fileMd5 := c.Request.FormValue("fileMd5")
@@ -27,33 +27,39 @@ func BreakpointContinue(c *gin.Context) {
 	chunkTotal, _ := strconv.Atoi(c.Request.FormValue("chunkTotal"))
 	_, FileHeader, err := c.Request.FormFile("file")
 	if err != nil {
-		response.FailWithMessage(err.Error(), c)
+		global.GVA_LOG.Error("接收文件失败!", zap.Any("err", err))
+		response.FailWithMessage("接收文件失败", c)
 		return
 	}
 	f, err := FileHeader.Open()
 	if err != nil {
-		response.FailWithMessage(err.Error(), c)
+		global.GVA_LOG.Error("文件读取失败!", zap.Any("err", err))
+		response.FailWithMessage("文件读取失败", c)
 		return
 	}
 	defer f.Close()
 	cen, _ := ioutil.ReadAll(f)
-	if flag := utils.CheckMd5(cen, chunkMd5); !flag {
-		response.FailWithMessage(err.Error(), c)
+	if !utils.CheckMd5(cen, chunkMd5) {
+		global.GVA_LOG.Error("检查md5失败!", zap.Any("err", err))
+		response.FailWithMessage("检查md5失败", c)
 		return
 	}
 	err, file := service.FindOrCreateFile(fileMd5, fileName, chunkTotal)
 	if err != nil {
-		response.FailWithMessage(err.Error(), c)
+		global.GVA_LOG.Error("查找或创建记录失败!", zap.Any("err", err))
+		response.FailWithMessage("查找或创建记录失败", c)
 		return
 	}
 	err, pathc := utils.BreakPointContinue(cen, fileName, chunkNumber, chunkTotal, fileMd5)
 	if err != nil {
-		response.FailWithMessage(err.Error(), c)
+		global.GVA_LOG.Error("断点续传失败!", zap.Any("err", err))
+		response.FailWithMessage("断点续传失败", c)
 		return
 	}
 
 	if err = service.CreateFileChunk(file.ID, pathc, chunkNumber); err != nil {
-		response.FailWithMessage(err.Error(), c)
+		global.GVA_LOG.Error("创建文件记录失败!", zap.Any("err", err))
+		response.FailWithMessage("创建文件记录失败", c)
 		return
 	}
 	response.OkWithMessage("切片创建成功", c)
@@ -73,14 +79,15 @@ func FindFile(c *gin.Context) {
 	chunkTotal, _ := strconv.Atoi(c.Query("chunkTotal"))
 	err, file := service.FindOrCreateFile(fileMd5, fileName, chunkTotal)
 	if err != nil {
+		global.GVA_LOG.Error("查找失败!", zap.Any("err", err))
 		response.FailWithMessage("查找失败", c)
 	} else {
-		response.OkWithData(resp.FileResponse{File: file}, c)
+		response.OkWithDetailed(response.FileResponse{File: file},"查找成功", c)
 	}
 }
 
 // @Tags ExaFileUploadAndDownload
-// @Summary 查找文件
+// @Summary 创建文件
 // @Security ApiKeyAuth
 // @accept multipart/form-data
 // @Produce  application/json
@@ -92,9 +99,10 @@ func BreakpointContinueFinish(c *gin.Context) {
 	fileName := c.Query("fileName")
 	err, filePath := utils.MakeFile(fileName, fileMd5)
 	if err != nil {
-		response.FailWithDetailed(response.ERROR, resp.FilePathResponse{FilePath: filePath}, fmt.Sprintf("文件创建失败:%v", err), c)
+		global.GVA_LOG.Error("文件创建失败!", zap.Any("err", err))
+		response.FailWithDetailed(response.FilePathResponse{FilePath: filePath}, "文件创建失败", c)
 	} else {
-		response.OkDetailed(resp.FilePathResponse{FilePath: filePath}, "文件创建成功", c)
+		response.OkWithDetailed(response.FilePathResponse{FilePath: filePath}, "文件创建成功", c)
 	}
 }
 
@@ -104,7 +112,7 @@ func BreakpointContinueFinish(c *gin.Context) {
 // @accept multipart/form-data
 // @Produce  application/json
 // @Param file formData file true "删除缓存切片"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"查找成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"缓存切片删除成功"}"
 // @Router /fileUploadAndDownload/removeChunk [post]
 func RemoveChunk(c *gin.Context) {
 	fileMd5 := c.Query("fileMd5")
@@ -113,8 +121,9 @@ func RemoveChunk(c *gin.Context) {
 	err := utils.RemoveChunk(fileMd5)
 	err = service.DeleteFileChunk(fileMd5, fileName, filePath)
 	if err != nil {
-		response.FailWithDetailed(response.ERROR, resp.FilePathResponse{FilePath: filePath}, fmt.Sprintf("缓存切片删除失败:%v", err), c)
+		global.GVA_LOG.Error("缓存切片删除失败!", zap.Any("err", err))
+		response.FailWithDetailed(response.FilePathResponse{FilePath: filePath},"缓存切片删除失败", c)
 	} else {
-		response.OkDetailed(resp.FilePathResponse{FilePath: filePath}, "缓存切片删除成功", c)
+		response.OkWithDetailed(response.FilePathResponse{FilePath: filePath}, "缓存切片删除成功", c)
 	}
 }

+ 44 - 46
server/api/v1/exa_customer.go

@@ -2,13 +2,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 ExaCustomer
@@ -20,20 +21,17 @@ import (
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
 // @Router /customer/customer [post]
 func CreateExaCustomer(c *gin.Context) {
-	var cu model.ExaCustomer
-	_ = c.ShouldBindJSON(&cu)
-	CustomerVerify := utils.Rules{
-		"CustomerName":      {utils.NotEmpty()},
-		"CustomerPhoneData": {utils.NotEmpty()},
-	}
-	if CustomerVerifyErr := utils.Verify(cu, CustomerVerify); CustomerVerifyErr != nil {
-		response.FailWithMessage(CustomerVerifyErr.Error(), c)
+	var customer model.ExaCustomer
+	_ = c.ShouldBindJSON(&customer)
+	if err := utils.Verify(customer, utils.CustomerVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	cu.SysUserID = getUserID(c)
-	cu.SysUserAuthorityID = getUserAuthorityId(c)
-	if err := service.CreateExaCustomer(cu); err != nil {
-		response.FailWithMessage(fmt.Sprintf("删除失败:%v", err), c)
+	customer.SysUserID = getUserID(c)
+	customer.SysUserAuthorityID = getUserAuthorityId(c)
+	if err := service.CreateExaCustomer(customer); err != nil {
+		global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
+		response.FailWithMessage("创建失败", c)
 	} else {
 		response.OkWithMessage("创建成功", c)
 	}
@@ -48,14 +46,15 @@ func CreateExaCustomer(c *gin.Context) {
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
 // @Router /customer/customer [delete]
 func DeleteExaCustomer(c *gin.Context) {
-	var cu model.ExaCustomer
-	_ = c.ShouldBindJSON(&cu)
-	if CustomerVerifyErr := utils.Verify(cu.GVA_MODEL, utils.Rules{"ID": {utils.NotEmpty()}}); CustomerVerifyErr != nil {
-		response.FailWithMessage(CustomerVerifyErr.Error(), c)
+	var customer model.ExaCustomer
+	_ = c.ShouldBindJSON(&customer)
+	if err := utils.Verify(customer.GVA_MODEL, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	if err := service.DeleteExaCustomer(cu); err != nil {
-		response.FailWithMessage(fmt.Sprintf("删除失败:%v", err), c)
+	if err := service.DeleteExaCustomer(customer); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
+		response.FailWithMessage("删除失败", c)
 	} else {
 		response.OkWithMessage("删除成功", c)
 	}
@@ -70,22 +69,19 @@ func DeleteExaCustomer(c *gin.Context) {
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
 // @Router /customer/customer [put]
 func UpdateExaCustomer(c *gin.Context) {
-	var cu model.ExaCustomer
-	_ = c.ShouldBindJSON(&cu)
-	if IdCustomerVerifyErr := utils.Verify(cu.GVA_MODEL, utils.Rules{"ID": {utils.NotEmpty()}}); IdCustomerVerifyErr != nil {
-		response.FailWithMessage(IdCustomerVerifyErr.Error(), c)
+	var customer model.ExaCustomer
+	_ = c.ShouldBindJSON(&customer)
+	if err := utils.Verify(customer.GVA_MODEL, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	CustomerVerify := utils.Rules{
-		"CustomerName":      {utils.NotEmpty()},
-		"CustomerPhoneData": {utils.NotEmpty()},
-	}
-	if CustomerVerifyErr := utils.Verify(cu, CustomerVerify); CustomerVerifyErr != nil {
-		response.FailWithMessage(CustomerVerifyErr.Error(), c)
+	if err := utils.Verify(customer, utils.CustomerVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	if err := service.UpdateExaCustomer(&cu); err != nil {
-		response.FailWithMessage(fmt.Sprintf("更新失败:%v", err), c)
+	if err := service.UpdateExaCustomer(&customer); err != nil {
+		global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
+		response.FailWithMessage("更新失败!", c)
 	} else {
 		response.OkWithMessage("更新成功", c)
 	}
@@ -97,47 +93,49 @@ func UpdateExaCustomer(c *gin.Context) {
 // @accept application/json
 // @Produce application/json
 // @Param data body model.ExaCustomer true "客户ID"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /customer/customer [get]
 func GetExaCustomer(c *gin.Context) {
-	var cu model.ExaCustomer
-	_ = c.ShouldBindQuery(&cu)
-	if IdCustomerVerifyErr := utils.Verify(cu.GVA_MODEL, utils.Rules{"ID": {utils.NotEmpty()}}); IdCustomerVerifyErr != nil {
-		response.FailWithMessage(IdCustomerVerifyErr.Error(), c)
+	var customer model.ExaCustomer
+	_ = c.ShouldBindQuery(&customer)
+	if err := utils.Verify(customer.GVA_MODEL, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err, customer := service.GetExaCustomer(cu.ID)
+	err, data := service.GetExaCustomer(customer.ID)
 	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取失败:%v", err), c)
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
 	} else {
-		response.OkWithData(resp.ExaCustomerResponse{Customer: customer}, c)
+		response.OkWithDetailed(response.ExaCustomerResponse{Customer: data}, "获取成功", c)
 	}
 }
 
 // @Tags ExaCustomer
-// @Summary 获取权限客户列表
+// @Summary 分页获取权限客户列表
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
 // @Param data body request.PageInfo true "页码, 每页大小"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /customer/customerList [get]
 func GetExaCustomerList(c *gin.Context) {
 	var pageInfo request.PageInfo
 	_ = c.ShouldBindQuery(&pageInfo)
-	if PageVerifyErr := utils.Verify(pageInfo, utils.CustomizeMap["PageVerify"]); PageVerifyErr != nil {
-		response.FailWithMessage(PageVerifyErr.Error(), c)
+	if err := utils.Verify(pageInfo, utils.PageInfoVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
 	err, customerList, total := service.GetCustomerInfoList(getUserAuthorityId(c), pageInfo)
 	if err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
 		response.FailWithMessage(fmt.Sprintf("获取失败:%v", err), c)
 	} else {
-		response.OkWithData(resp.PageResult{
+		response.OkWithDetailed(response.PageResult{
 			List:     customerList,
 			Total:    total,
 			Page:     pageInfo.Page,
 			PageSize: pageInfo.PageSize,
-		}, c)
+		}, "获取成功", c)
 	}
 }

+ 16 - 12
server/api/v1/exa_file_upload_download.go

@@ -1,13 +1,13 @@
 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"
 	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
 )
 
 // @Tags ExaFileUploadAndDownload
@@ -23,15 +23,17 @@ func UploadFile(c *gin.Context) {
 	noSave := c.DefaultQuery("noSave", "0")
 	_, header, err := c.Request.FormFile("file")
 	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("上传文件失败,%v", err), c)
+		global.GVA_LOG.Error("接收文件失败!", zap.Any("err", err))
+		response.FailWithMessage("接收文件失败", c)
 		return
 	}
 	err, file = service.UploadFile(header, noSave) // 文件上传后拿到文件路径
 	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("修改数据库链接失败,%v", err), c)
+		global.GVA_LOG.Error("修改数据库链接失败!", zap.Any("err", err))
+		response.FailWithMessage("修改数据库链接失败", c)
 		return
 	}
-	response.OkDetailed(resp.ExaFileResponse{File: file}, "上传成功", c)
+	response.OkWithDetailed(response.ExaFileResponse{File: file}, "上传成功", c)
 }
 
 // @Tags ExaFileUploadAndDownload
@@ -39,13 +41,14 @@ func UploadFile(c *gin.Context) {
 // @Security ApiKeyAuth
 // @Produce  application/json
 // @Param data body model.ExaFileUploadAndDownload true "传入文件里面id即可"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
 // @Router /fileUploadAndDownload/deleteFile [post]
 func DeleteFile(c *gin.Context) {
 	var file model.ExaFileUploadAndDownload
 	_ = c.ShouldBindJSON(&file)
 	if err := service.DeleteFile(file); err != nil {
-		response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
+		global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
+		response.FailWithMessage("删除失败", c)
 		return
 	}
 	response.OkWithMessage("删除成功", c)
@@ -56,7 +59,7 @@ func DeleteFile(c *gin.Context) {
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body request.PageInfo true "分页获取文件户列表"
+// @Param data body request.PageInfo true "页码, 每页大小"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /fileUploadAndDownload/getFileList [post]
 func GetFileList(c *gin.Context) {
@@ -64,13 +67,14 @@ func GetFileList(c *gin.Context) {
 	_ = c.ShouldBindJSON(&pageInfo)
 	err, list, total := service.GetFileRecordInfoList(pageInfo)
 	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
+		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)
 	}
 }

+ 22 - 16
server/api/v1/exa_simple_uploader.go

@@ -1,12 +1,13 @@
 package v1
 
 import (
-	"fmt"
-	"gin-vue-admin/global/response"
+	"gin-vue-admin/global"
 	"gin-vue-admin/model"
+	"gin-vue-admin/model/response"
 	"gin-vue-admin/service"
 	"gin-vue-admin/utils"
 	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
 )
 
 // @Tags SimpleUploader
@@ -14,8 +15,8 @@ import (
 // @Security ApiKeyAuth
 // @accept multipart/form-data
 // @Produce  application/json
-// @Param file formData file true "断点续传插件版示例"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"上传成功"}"
+// TODO @Param file formData file true "断点续传插件版示例"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"切片创建成功"}"
 // @Router /simpleUploader/upload [post]
 func SimpleUploaderUpload(c *gin.Context) {
 	var chunk model.ExaSimpleUploader
@@ -29,42 +30,46 @@ func SimpleUploaderUpload(c *gin.Context) {
 	var chunkDir = "./chunk/" + chunk.Identifier + "/"
 	hasDir, _ := utils.PathExists(chunkDir)
 	if !hasDir {
-		utils.CreateDir(chunkDir)
+		if err := utils.CreateDir(chunkDir); err != nil {
+			global.GVA_LOG.Error("创建目录失败!", zap.Any("err", err))
+		}
 	}
 	chunkPath := chunkDir + chunk.Filename + chunk.ChunkNumber
 	err = c.SaveUploadedFile(header, chunkPath)
 	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("切片创建失败,%v", err), c)
+		global.GVA_LOG.Error("切片创建失败!", zap.Any("err", err))
+		response.FailWithMessage("切片创建失败", c)
 		return
 	}
 	chunk.CurrentChunkPath = chunkPath
 	err = service.SaveChunk(chunk)
 	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("切片创建失败,%v", err), c)
+		global.GVA_LOG.Error("切片创建失败!", zap.Any("err", err))
+		response.FailWithMessage("切片创建失败", c)
 		return
 	} else {
-		response.Ok(c)
+		response.OkWithMessage("切片创建成功", c)
 	}
 }
 
 // @Tags SimpleUploader
 // @Summary 断点续传插件版示例
 // @Security ApiKeyAuth
-
 // @Produce  application/json
-// @Param md5 query string true "测试文件是否已经存在和判断已经上传过的切片"
+// @Param md5 query string true "md5"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
 // @Router /simpleUploader/checkFileMd5 [get]
 func CheckFileMd5(c *gin.Context) {
 	md5 := c.Query("md5")
 	err, chunks, isDone := service.CheckFileMd5(md5)
 	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("md5读取失败,%v", err), c)
+		global.GVA_LOG.Error("md5读取失败!", zap.Any("err", err))
+		response.FailWithMessage("md5读取失败", c)
 	} else {
-		response.OkWithData(gin.H{
+		response.OkWithDetailed(gin.H{
 			"chunks": chunks,
 			"isDone": isDone,
-		}, c)
+		},"查询成功", c)
 	}
 }
 
@@ -72,7 +77,7 @@ func CheckFileMd5(c *gin.Context) {
 // @Summary 合并文件
 // @Security ApiKeyAuth
 // @Produce  application/json
-// @Param md5 query string true "合并文件"
+// @Param md5 query string true "md5"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"合并成功"}"
 // @Router /simpleUploader/mergeFileMd5 [get]
 func MergeFileMd5(c *gin.Context) {
@@ -80,8 +85,9 @@ func MergeFileMd5(c *gin.Context) {
 	fileName := c.Query("fileName")
 	err := service.MergeFileMd5(md5, fileName)
 	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("md5读取失败,%v", err), c)
+		global.GVA_LOG.Error("md5读取失败!", zap.Any("err", err))
+		response.FailWithMessage("md5读取失败", c)
 	} else {
-		response.OkWithData(gin.H{}, c)
+		response.OkWithMessage("合并成功", c)
 	}
 }

+ 48 - 70
server/api/v1/sys_api.go

@@ -1,14 +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 SysApi
@@ -16,60 +16,47 @@ import (
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.SysApi true "创建api"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Param data body model.SysApi true "api路径, api中文描述, api组, 方法"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
 // @Router /api/createApi [post]
 func CreateApi(c *gin.Context) {
 	var api model.SysApi
 	_ = c.ShouldBindJSON(&api)
-	ApiVerify := utils.Rules{
-		"Path":        {utils.NotEmpty()},
-		"Description": {utils.NotEmpty()},
-		"ApiGroup":    {utils.NotEmpty()},
-		"Method":      {utils.NotEmpty()},
-	}
-	ApiVerifyErr := utils.Verify(api, ApiVerify)
-	if ApiVerifyErr != nil {
-		response.FailWithMessage(ApiVerifyErr.Error(), c)
+	if err := utils.Verify(api, utils.ApiVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err := service.CreateApi(api)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
+	if err := service.CreateApi(api); err != nil {
+		global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
+		response.FailWithMessage("创建失败", c)
 	} else {
 		response.OkWithMessage("创建成功", c)
 	}
 }
 
 // @Tags SysApi
-// @Summary 删除指定api
+// @Summary 删除api
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.SysApi true "删除api"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Param data body model.SysApi true "ID"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
 // @Router /api/deleteApi [post]
 func DeleteApi(c *gin.Context) {
-	var a model.SysApi
-	_ = c.ShouldBindJSON(&a)
-	ApiVerify := utils.Rules{
-		"ID": {utils.NotEmpty()},
-	}
-	ApiVerifyErr := utils.Verify(a.GVA_MODEL, ApiVerify)
-	if ApiVerifyErr != nil {
-		response.FailWithMessage(ApiVerifyErr.Error(), c)
+	var api model.SysApi
+	_ = c.ShouldBindJSON(&api)
+	if err := utils.Verify(api.GVA_MODEL, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err := service.DeleteApi(a)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
+	if err := service.DeleteApi(api); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
+		response.FailWithMessage("删除失败", c)
 	} else {
 		response.OkWithMessage("删除成功", c)
 	}
 }
 
-// 条件搜索后端看此api
-
 // @Tags SysApi
 // @Summary 分页获取API列表
 // @Security ApiKeyAuth
@@ -79,24 +66,22 @@ func DeleteApi(c *gin.Context) {
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /api/getApiList [post]
 func GetApiList(c *gin.Context) {
-	// 此结构体仅本方法使用
-	var sp request.SearchApiParams
-	_ = c.ShouldBindJSON(&sp)
-	PageVerifyErr := utils.Verify(sp.PageInfo, utils.CustomizeMap["PageVerify"])
-	if PageVerifyErr != nil {
-		response.FailWithMessage(PageVerifyErr.Error(), c)
+	var pageInfo request.SearchApiParams
+	_ = c.ShouldBindJSON(&pageInfo)
+	if err := utils.Verify(pageInfo.PageInfo, utils.PageInfoVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err, list, total := service.GetAPIInfoList(sp.SysApi, sp.PageInfo, sp.OrderKey, sp.Desc)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
+	if err, list, total := service.GetAPIInfoList(pageInfo.SysApi, pageInfo.PageInfo, pageInfo.OrderKey, pageInfo.Desc); 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:     sp.PageInfo.Page,
-			PageSize: sp.PageInfo.PageSize,
-		}, c)
+			Page:     pageInfo.Page,
+			PageSize: pageInfo.PageSize,
+		}, "获取成功", c)
 	}
 }
 
@@ -111,16 +96,16 @@ func GetApiList(c *gin.Context) {
 func GetApiById(c *gin.Context) {
 	var idInfo request.GetById
 	_ = c.ShouldBindJSON(&idInfo)
-	IdVerifyErr := utils.Verify(idInfo, utils.CustomizeMap["IdVerify"])
-	if IdVerifyErr != nil {
-		response.FailWithMessage(IdVerifyErr.Error(), c)
+	if err := utils.Verify(idInfo, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
 	err, api := service.GetApiById(idInfo.Id)
 	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
+		global.GVA_LOG.Error("获取数据失败!", zap.Any("err", err))
+		response.FailWithMessage("获取数据失败", c)
 	} else {
-		response.OkWithData(resp.SysAPIResponse{Api: api}, c)
+		response.OkWithData(response.SysAPIResponse{Api: api}, c)
 	}
 }
 
@@ -129,28 +114,21 @@ func GetApiById(c *gin.Context) {
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.SysApi true "创建api"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Param data body model.SysApi true "api路径, api中文描述, api组, 方法"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
 // @Router /api/updateApi [post]
 func UpdateApi(c *gin.Context) {
 	var api model.SysApi
 	_ = c.ShouldBindJSON(&api)
-	ApiVerify := utils.Rules{
-		"Path":        {utils.NotEmpty()},
-		"Description": {utils.NotEmpty()},
-		"ApiGroup":    {utils.NotEmpty()},
-		"Method":      {utils.NotEmpty()},
-	}
-	ApiVerifyErr := utils.Verify(api, ApiVerify)
-	if ApiVerifyErr != nil {
-		response.FailWithMessage(ApiVerifyErr.Error(), c)
+	if err := utils.Verify(api, utils.ApiVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err := service.UpdateApi(api)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("修改数据失败,%v", err), c)
+	if err := service.UpdateApi(api); err != nil {
+		global.GVA_LOG.Error("修改失败!", zap.Any("err", err))
+		response.FailWithMessage("修改失败", c)
 	} else {
-		response.OkWithMessage("修改数据成功", c)
+		response.OkWithMessage("修改成功", c)
 	}
 }
 
@@ -162,10 +140,10 @@ func UpdateApi(c *gin.Context) {
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /api/getAllApis [post]
 func GetAllApis(c *gin.Context) {
-	err, apis := service.GetAllApis()
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
+	if err, apis := service.GetAllApis(); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
 	} else {
-		response.OkWithData(resp.SysAPIListResponse{Apis: apis}, c)
+		response.OkWithDetailed(response.SysAPIListResponse{Apis: apis}, "获取成功", c)
 	}
 }

+ 54 - 80
server/api/v1/sys_authority.go

@@ -1,14 +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 authority
@@ -16,27 +16,21 @@ import (
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.SysAuthority true "创建角色"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Param data body model.SysAuthority true "权限id, 权限名, 父角色id"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
 // @Router /authority/createAuthority [post]
 func CreateAuthority(c *gin.Context) {
-	var auth model.SysAuthority
-	_ = c.ShouldBindJSON(&auth)
-	AuthorityVerify := utils.Rules{
-		"AuthorityId":   {utils.NotEmpty()},
-		"AuthorityName": {utils.NotEmpty()},
-		"ParentId":      {utils.NotEmpty()},
-	}
-	AuthorityVerifyErr := utils.Verify(auth, AuthorityVerify)
-	if AuthorityVerifyErr != nil {
-		response.FailWithMessage(AuthorityVerifyErr.Error(), c)
+	var authority model.SysAuthority
+	_ = c.ShouldBindJSON(&authority)
+	if err := utils.Verify(authority, utils.AuthorityVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err, authBack := service.CreateAuthority(auth)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
+	if err, authBack := service.CreateAuthority(authority); err != nil {
+		global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
+		response.FailWithMessage("创建失败", c)
 	} else {
-		response.OkWithData(resp.SysAuthorityResponse{Authority: authBack}, c)
+		response.OkWithDetailed(response.SysAuthorityResponse{Authority: authBack}, "创建成功", c)
 	}
 }
 
@@ -45,35 +39,25 @@ func CreateAuthority(c *gin.Context) {
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body response.SysAuthorityCopyResponse true "拷贝角色"
+// @Param data body response.SysAuthorityCopyResponse true "旧角色id, 新权限id, 新权限名, 新父角色id"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"拷贝成功"}"
 // @Router /authority/copyAuthority [post]
 func CopyAuthority(c *gin.Context) {
-	var copyInfo resp.SysAuthorityCopyResponse
+	var copyInfo response.SysAuthorityCopyResponse
 	_ = c.ShouldBindJSON(&copyInfo)
-	OldAuthorityVerify := utils.Rules{
-		"OldAuthorityId": {utils.NotEmpty()},
-	}
-	OldAuthorityVerifyErr := utils.Verify(copyInfo, OldAuthorityVerify)
-	if OldAuthorityVerifyErr != nil {
-		response.FailWithMessage(OldAuthorityVerifyErr.Error(), c)
+	if err := utils.Verify(copyInfo, utils.OldAuthorityVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	AuthorityVerify := utils.Rules{
-		"AuthorityId":   {utils.NotEmpty()},
-		"AuthorityName": {utils.NotEmpty()},
-		"ParentId":      {utils.NotEmpty()},
-	}
-	AuthorityVerifyErr := utils.Verify(copyInfo.Authority, AuthorityVerify)
-	if AuthorityVerifyErr != nil {
-		response.FailWithMessage(AuthorityVerifyErr.Error(), c)
+	if err := utils.Verify(copyInfo.Authority, utils.AuthorityVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err, authBack := service.CopyAuthority(copyInfo)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("拷贝失败,%v", err), c)
+	if err, authBack := service.CopyAuthority(copyInfo); err != nil {
+		global.GVA_LOG.Error("拷贝失败!", zap.Any("err", err))
+		response.FailWithMessage("拷贝失败", c)
 	} else {
-		response.OkWithData(resp.SysAuthorityResponse{Authority: authBack}, c)
+		response.OkWithDetailed(response.SysAuthorityResponse{Authority: authBack}, "拷贝成功", c)
 	}
 }
 
@@ -83,51 +67,43 @@ func CopyAuthority(c *gin.Context) {
 // @accept application/json
 // @Produce application/json
 // @Param data body model.SysAuthority true "删除角色"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
 // @Router /authority/deleteAuthority [post]
 func DeleteAuthority(c *gin.Context) {
-	var a model.SysAuthority
-	_ = c.ShouldBindJSON(&a)
-	AuthorityIdVerifyErr := utils.Verify(a, utils.CustomizeMap["AuthorityIdVerify"])
-	if AuthorityIdVerifyErr != nil {
-		response.FailWithMessage(AuthorityIdVerifyErr.Error(), c)
+	var authority model.SysAuthority
+	_ = c.ShouldBindJSON(&authority)
+	if err := utils.Verify(authority, utils.AuthorityIdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	// 删除角色之前需要判断是否有用户正在使用此角色
-	err := service.DeleteAuthority(&a)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
+	if err := service.DeleteAuthority(&authority); err != nil { // 删除角色之前需要判断是否有用户正在使用此角色
+		global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
+		response.FailWithMessage("删除失败", c)
 	} else {
 		response.OkWithMessage("删除成功", c)
 	}
 }
 
 // @Tags authority
-// @Summary 设置角色资源权限
+// @Summary 更新角色信息
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.SysAuthority true "设置角色资源权限"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}"
+// @Param data body model.SysAuthority true "权限id, 权限名, 父角色id"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
 // @Router /authority/updateAuthority [post]
 func UpdateAuthority(c *gin.Context) {
 	var auth model.SysAuthority
 	_ = c.ShouldBindJSON(&auth)
-	AuthorityVerify := utils.Rules{
-		"AuthorityId":   {utils.NotEmpty()},
-		"AuthorityName": {utils.NotEmpty()},
-		"ParentId":      {utils.NotEmpty()},
-	}
-	AuthorityVerifyErr := utils.Verify(auth, AuthorityVerify)
-	if AuthorityVerifyErr != nil {
-		response.FailWithMessage(AuthorityVerifyErr.Error(), c)
+	if err := utils.Verify(auth, utils.AuthorityVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err, authority := service.UpdateAuthority(auth)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c)
+	if err, authority := service.UpdateAuthority(auth); err != nil {
+		global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
+		response.FailWithMessage("更新失败", c)
 	} else {
-		response.OkWithData(resp.SysAuthorityResponse{Authority: authority}, c)
+		response.OkWithDetailed(response.SysAuthorityResponse{Authority: authority}, "更新成功", c)
 	}
 }
 
@@ -136,27 +112,26 @@ func UpdateAuthority(c *gin.Context) {
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body request.PageInfo true "分页获取用户列表"
+// @Param data body request.PageInfo true "页码, 每页大小"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /authority/getAuthorityList [post]
 func GetAuthorityList(c *gin.Context) {
 	var pageInfo request.PageInfo
 	_ = c.ShouldBindJSON(&pageInfo)
-	PageVerifyErr := utils.Verify(pageInfo, utils.CustomizeMap["PageVerify"])
-	if PageVerifyErr != nil {
-		response.FailWithMessage(PageVerifyErr.Error(), c)
+	if err := utils.Verify(pageInfo, utils.PageInfoVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err, list, total := service.GetAuthorityInfoList(pageInfo)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
+	if err, list, total := service.GetAuthorityInfoList(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)
 	}
 }
 
@@ -171,15 +146,14 @@ func GetAuthorityList(c *gin.Context) {
 func SetDataAuthority(c *gin.Context) {
 	var auth model.SysAuthority
 	_ = c.ShouldBindJSON(&auth)
-	AuthorityIdVerifyErr := utils.Verify(auth, utils.CustomizeMap["AuthorityIdVerify"])
-	if AuthorityIdVerifyErr != nil {
-		response.FailWithMessage(AuthorityIdVerifyErr.Error(), c)
+	if err := utils.Verify(auth, utils.AuthorityIdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err := service.SetDataAuthority(auth)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("设置关联失败,%v", err), c)
+	if err := service.SetDataAuthority(auth); err != nil {
+		global.GVA_LOG.Error("设置失败!", zap.Any("err", err))
+		response.FailWithMessage("设置失败", c)
 	} else {
-		response.Ok(c)
+		response.OkWithMessage("设置成功", c)
 	}
 }

+ 27 - 39
server/api/v1/sys_auto_code.go

@@ -3,35 +3,29 @@ package v1
 import (
 	"fmt"
 	"gin-vue-admin/global"
-	"gin-vue-admin/global/response"
 	"gin-vue-admin/model"
+	"gin-vue-admin/model/response"
 	"gin-vue-admin/service"
 	"gin-vue-admin/utils"
 	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
 	"net/url"
 	"os"
 )
 
-// @Tags SysApi
+// @Tags AutoCode
 // @Summary 自动代码模板
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.AutoCodeStruct true "创建自动代码"
+// TODO @Param data body model.AutoCodeStruct true "创建自动代码"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
 // @Router /autoCode/createTemp [post]
 func CreateTemp(c *gin.Context) {
 	var a model.AutoCodeStruct
 	_ = c.ShouldBindJSON(&a)
-	AutoCodeVerify := utils.Rules{
-		"Abbreviation": {utils.NotEmpty()},
-		"StructName":   {utils.NotEmpty()},
-		"PackageName":  {utils.NotEmpty()},
-		"Fields":       {utils.NotEmpty()},
-	}
-	WKVerifyErr := utils.Verify(a, AutoCodeVerify)
-	if WKVerifyErr != nil {
-		response.FailWithMessage(WKVerifyErr.Error(), c)
+	if err := utils.Verify(a, utils.AutoCodeVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
 	if a.AutoCreateApiToSql {
@@ -49,7 +43,7 @@ func CreateTemp(c *gin.Context) {
 				Method:      "DELETE",
 			},
 			{
-				Path:        "/" + a.Abbreviation + "/" + "delete" + a.StructName+"ByIds",
+				Path:        "/" + a.Abbreviation + "/" + "delete" + a.StructName + "ByIds",
 				Description: "批量删除" + a.Description,
 				ApiGroup:    a.Abbreviation,
 				Method:      "DELETE",
@@ -74,10 +68,10 @@ func CreateTemp(c *gin.Context) {
 			},
 		}
 		for _, v := range apiList {
-			errC := service.AutoCreateApi(v)
-			if errC != nil {
+			if err := service.AutoCreateApi(v); err != nil {
+				global.GVA_LOG.Error("自动化创建失败!请自行清空垃圾数据!", zap.Any("err", err))
 				c.Writer.Header().Add("success", "false")
-				c.Writer.Header().Add("msg", url.QueryEscape(fmt.Sprintf("自动化创建失败,%v,请自行清空垃圾数据", errC)))
+				c.Writer.Header().Add("msg", url.QueryEscape("自动化创建失败!请自行清空垃圾数据!"))
 				return
 			}
 		}
@@ -96,60 +90,54 @@ func CreateTemp(c *gin.Context) {
 	}
 }
 
-// @Tags SysApi
+// @Tags AutoCode
 // @Summary 获取当前数据库所有表
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /autoCode/getTables [get]
-
 func GetTables(c *gin.Context) {
 	dbName := c.DefaultQuery("dbName", global.GVA_CONFIG.Mysql.Dbname)
 	err, tables := service.GetTables(dbName)
 	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("查询table失败,%v", err), c)
+		global.GVA_LOG.Error("查询table失败!", zap.Any("err", err))
+		response.FailWithMessage("查询table失败", c)
 	} else {
-		response.OkWithData(gin.H{
-			"tables": tables,
-		}, c)
+		response.OkWithDetailed(gin.H{"tables": tables}, "获取成功", c)
 	}
 }
 
-// @Tags SysApi
+// @Tags AutoCode
 // @Summary 获取当前所有数据库
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /autoCode/getDatabase [get]
 func GetDB(c *gin.Context) {
-	err, dbs := service.GetDB()
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("查询table失败,%v", err), c)
+	if err, dbs := service.GetDB(); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
 	} else {
-		response.OkWithData(gin.H{
-			"dbs": dbs,
-		}, c)
+		response.OkWithDetailed(gin.H{"dbs": dbs}, "获取成功", c)
 	}
 }
 
-// @Tags SysApi
+// @Tags AutoCode
 // @Summary 获取当前表所有字段
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /autoCode/getColumn [get]
 func GetColumn(c *gin.Context) {
 	dbName := c.DefaultQuery("dbName", global.GVA_CONFIG.Mysql.Dbname)
 	tableName := c.Query("tableName")
-	err, columns := service.GetColumn(tableName, dbName)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("查询table失败,%v", err), c)
+	if err, columns := service.GetColumn(tableName, dbName); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
 	} else {
-		response.OkWithData(gin.H{
-			"columns": columns,
-		}, c)
+		response.OkWithDetailed(gin.H{"columns": columns}, "获取成功", c)
 	}
 }

+ 8 - 9
server/api/v1/sys_captcha.go

@@ -1,33 +1,32 @@
 package v1
 
 import (
-	"fmt"
 	"gin-vue-admin/global"
-	"gin-vue-admin/global/response"
-	resp "gin-vue-admin/model/response"
+	"gin-vue-admin/model/response"
 	"github.com/gin-gonic/gin"
 	"github.com/mojocn/base64Captcha"
+	"go.uber.org/zap"
 )
 
 var store = base64Captcha.DefaultMemStore
 
-// @Tags base
+// @Tags Base
 // @Summary 生成验证码
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"验证码获取成功"}"
 // @Router /base/captcha [post]
 func Captcha(c *gin.Context) {
 	//字符,公式,验证码配置
 	// 生成默认数字的driver
 	driver := base64Captcha.NewDriverDigit(global.GVA_CONFIG.Captcha.ImgHeight, global.GVA_CONFIG.Captcha.ImgWidth, global.GVA_CONFIG.Captcha.KeyLong, 0.7, 80)
 	cp := base64Captcha.NewCaptcha(driver, store)
-	id, b64s, err := cp.Generate()
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
+	if id, b64s, err := cp.Generate(); err != nil {
+		global.GVA_LOG.Error("验证码获取失败!", zap.Any("err", err))
+		response.FailWithMessage("验证码获取失败", c)
 	} else {
-		response.OkDetailed(resp.SysCaptchaResponse{
+		response.OkWithDetailed(response.SysCaptchaResponse{
 			CaptchaId: id,
 			PicPath:   b64s,
 		}, "验证码获取成功", c)

+ 21 - 23
server/api/v1/sys_casbin.go

@@ -1,56 +1,54 @@
 package v1
 
 import (
-	"fmt"
-	"gin-vue-admin/global/response"
+	"gin-vue-admin/global"
 	"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 casbin
-// @Summary 更角色api权限
+// @Tags Casbin
+// @Summary 更角色api权限
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body request.CasbinInReceive true "更改角色api权限"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Param data body request.CasbinInReceive true "权限id, 权限模型列表"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
 // @Router /casbin/UpdateCasbin [post]
 func UpdateCasbin(c *gin.Context) {
 	var cmr request.CasbinInReceive
 	_ = c.ShouldBindJSON(&cmr)
-	AuthorityIdVerifyErr := utils.Verify(cmr, utils.CustomizeMap["AuthorityIdVerify"])
-	if AuthorityIdVerifyErr != nil {
-		response.FailWithMessage(AuthorityIdVerifyErr.Error(), c)
+	if err := utils.Verify(cmr, utils.AuthorityIdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err := service.UpdateCasbin(cmr.AuthorityId, cmr.CasbinInfos)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("添加规则失败,%v", err), c)
+	if err := service.UpdateCasbin(cmr.AuthorityId, cmr.CasbinInfos); err != nil {
+		global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
+		response.FailWithMessage("更新失败", c)
 	} else {
-		response.OkWithMessage("添加规则成功", c)
+		response.OkWithMessage("更新成功", c)
 	}
 }
 
-// @Tags casbin
+// @Tags Casbin
 // @Summary 获取权限列表
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body request.CasbinInReceive true "获取权限列表"
+// @Param data body request.CasbinInReceive true "权限id, 权限模型列表"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /casbin/getPolicyPathByAuthorityId [post]
 func GetPolicyPathByAuthorityId(c *gin.Context) {
-	var cmr request.CasbinInReceive
-	_ = c.ShouldBindJSON(&cmr)
-	AuthorityIdVerifyErr := utils.Verify(cmr, utils.CustomizeMap["AuthorityIdVerify"])
-	if AuthorityIdVerifyErr != nil {
-		response.FailWithMessage(AuthorityIdVerifyErr.Error(), c)
+	var casbin request.CasbinInReceive
+	_ = c.ShouldBindJSON(&casbin)
+	if err := utils.Verify(casbin, utils.AuthorityIdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	paths := service.GetPolicyPathByAuthorityId(cmr.AuthorityId)
-	response.OkWithData(resp.PolicyPathResponse{Paths: paths}, c)
+	paths := service.GetPolicyPathByAuthorityId(casbin.AuthorityId)
+	response.OkWithDetailed(response.PolicyPathResponse{Paths: paths}, "获取成功", c)
 }
 

+ 44 - 35
server/api/v1/sys_dictionary.go

@@ -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)
 	}
 }

+ 38 - 33
server/api/v1/sys_dictionary_detail.go

@@ -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 SysDictionaryDetail
@@ -15,15 +16,15 @@ import (
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.SysDictionaryDetail true "创建SysDictionaryDetail"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Param data body model.SysDictionaryDetail true "SysDictionaryDetail模型"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
 // @Router /sysDictionaryDetail/createSysDictionaryDetail [post]
 func CreateSysDictionaryDetail(c *gin.Context) {
-	var sysDictionaryDetail model.SysDictionaryDetail
-	_ = c.ShouldBindJSON(&sysDictionaryDetail)
-	err := service.CreateSysDictionaryDetail(sysDictionaryDetail)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
+	var detail model.SysDictionaryDetail
+	_ = c.ShouldBindJSON(&detail)
+	if err := service.CreateSysDictionaryDetail(detail); err != nil {
+		global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
+		response.FailWithMessage("创建失败", c)
 	} else {
 		response.OkWithMessage("创建成功", c)
 	}
@@ -34,15 +35,15 @@ func CreateSysDictionaryDetail(c *gin.Context) {
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.SysDictionaryDetail true "删除SysDictionaryDetail"
+// @Param data body model.SysDictionaryDetail true "SysDictionaryDetail模型"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
 // @Router /sysDictionaryDetail/deleteSysDictionaryDetail [delete]
 func DeleteSysDictionaryDetail(c *gin.Context) {
-	var sysDictionaryDetail model.SysDictionaryDetail
-	_ = c.ShouldBindJSON(&sysDictionaryDetail)
-	err := service.DeleteSysDictionaryDetail(sysDictionaryDetail)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
+	var detail model.SysDictionaryDetail
+	_ = c.ShouldBindJSON(&detail)
+	if err := service.DeleteSysDictionaryDetail(detail); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
+		response.FailWithMessage("删除失败", c)
 	} else {
 		response.OkWithMessage("删除成功", c)
 	}
@@ -57,11 +58,11 @@ func DeleteSysDictionaryDetail(c *gin.Context) {
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
 // @Router /sysDictionaryDetail/updateSysDictionaryDetail [put]
 func UpdateSysDictionaryDetail(c *gin.Context) {
-	var sysDictionaryDetail model.SysDictionaryDetail
-	_ = c.ShouldBindJSON(&sysDictionaryDetail)
-	err := service.UpdateSysDictionaryDetail(&sysDictionaryDetail)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c)
+	var detail model.SysDictionaryDetail
+	_ = c.ShouldBindJSON(&detail)
+	if err := service.UpdateSysDictionaryDetail(&detail); err != nil {
+		global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
+		response.FailWithMessage("更新失败", c)
 	} else {
 		response.OkWithMessage("更新成功", c)
 	}
@@ -76,13 +77,17 @@ func UpdateSysDictionaryDetail(c *gin.Context) {
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
 // @Router /sysDictionaryDetail/findSysDictionaryDetail [get]
 func FindSysDictionaryDetail(c *gin.Context) {
-	var sysDictionaryDetail model.SysDictionaryDetail
-	_ = c.ShouldBindQuery(&sysDictionaryDetail)
-	err, resysDictionaryDetail := service.GetSysDictionaryDetail(sysDictionaryDetail.ID)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c)
+	var detail model.SysDictionaryDetail
+	_ = c.ShouldBindQuery(&detail)
+	if err := utils.Verify(detail, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	if err, resysDictionaryDetail := service.GetSysDictionaryDetail(detail.ID); err != nil {
+		global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
+		response.FailWithMessage("查询失败", c)
 	} else {
-		response.OkWithData(gin.H{"resysDictionaryDetail": resysDictionaryDetail}, c)
+		response.OkWithDetailed(gin.H{"resysDictionaryDetail": resysDictionaryDetail}, "查询成功", c)
 	}
 }
 
@@ -91,21 +96,21 @@ func FindSysDictionaryDetail(c *gin.Context) {
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body request.SysDictionaryDetailSearch true "分页获取SysDictionaryDetail列表"
+// @Param data body request.SysDictionaryDetailSearch true "页码, 每页大小, 搜索条件"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /sysDictionaryDetail/getSysDictionaryDetailList [get]
 func GetSysDictionaryDetailList(c *gin.Context) {
 	var pageInfo request.SysDictionaryDetailSearch
 	_ = c.ShouldBindQuery(&pageInfo)
-	err, list, total := service.GetSysDictionaryDetailInfoList(pageInfo)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
+	if err, list, total := service.GetSysDictionaryDetailInfoList(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)
 	}
 }

+ 8 - 7
server/api/v1/sys_email.go

@@ -1,22 +1,23 @@
 package v1
 
 import (
-	"fmt"
-	"gin-vue-admin/global/response"
+	"gin-vue-admin/global"
+	"gin-vue-admin/model/response"
 	"gin-vue-admin/service"
 	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
 )
 
-// @Tags system
+// @Tags System
 // @Summary 发送测试邮件
 // @Security ApiKeyAuth
 // @Produce  application/json
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"发送成功"}"
 // @Router /email/emailTest [post]
 func EmailTest(c *gin.Context) {
-	err := service.EmailTest()
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("发送失败,%v", err), c)
+	if err := service.EmailTest(); err != nil {
+		global.GVA_LOG.Error("发送失败!", zap.Any("err", err))
+		response.FailWithMessage("发送失败", c)
 	} else {
 		response.OkWithData("发送成功", c)
 	}

+ 8 - 9
server/api/v1/sys_jwt_blacklist.go

@@ -1,14 +1,15 @@
 package v1
 
 import (
-	"fmt"
-	"gin-vue-admin/global/response"
+	"gin-vue-admin/global"
 	"gin-vue-admin/model"
+	"gin-vue-admin/model/response"
 	"gin-vue-admin/service"
 	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
 )
 
-// @Tags jwt
+// @Tags Jwt
 // @Summary jwt加入黑名单
 // @Security ApiKeyAuth
 // @accept application/json
@@ -17,12 +18,10 @@ import (
 // @Router /jwt/jsonInBlacklist [post]
 func JsonInBlacklist(c *gin.Context) {
 	token := c.Request.Header.Get("x-token")
-	modelJwt := model.JwtBlacklist{
-		Jwt: token,
-	}
-	err := service.JsonInBlacklist(modelJwt)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("jwt作废失败,%v", err), c)
+	jwt := model.JwtBlacklist{Jwt: token}
+	if err := service.JsonInBlacklist(jwt); err != nil {
+		global.GVA_LOG.Error("jwt作废失败!", zap.Any("err", err))
+		response.FailWithMessage("jwt作废失败", c)
 	} else {
 		response.OkWithMessage("jwt作废成功", c)
 	}

+ 99 - 105
server/api/v1/sys_menu.go

@@ -1,14 +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 AuthorityMenu
@@ -16,93 +16,34 @@ import (
 // @Security ApiKeyAuth
 // @Produce  application/json
 // @Param data body request.Empty true "空"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /menu/getMenu [post]
 func GetMenu(c *gin.Context) {
 	if err, menus := service.GetMenuTree(getUserAuthorityId(c)); err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取失败,%v", err), c)
-	} else {
-		response.OkWithData(resp.SysMenusResponse{Menus: menus}, c)
-	}
-}
-
-// @Tags menu
-// @Summary 分页获取基础menu列表
-// @Security ApiKeyAuth
-// @accept application/json
-// @Produce application/json
-// @Param data body request.PageInfo true "页码, 每页大小"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}"
-// @Router /menu/getMenuList [post]
-func GetMenuList(c *gin.Context) {
-	var pageInfo request.PageInfo
-	_ = c.ShouldBindJSON(&pageInfo)
-	if err := utils.Verify(pageInfo, utils.CustomizeMap["PageVerify"]); err != nil {
-		response.FailWithMessage(err.Error(), c)
-		return
-	}
-	err, menuList, total := service.GetInfoList()
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
 	} else {
-		response.OkWithData(resp.PageResult{
-			List:     menuList,
-			Total:    total,
-			Page:     pageInfo.Page,
-			PageSize: pageInfo.PageSize,
-		}, c)
+		response.OkWithDetailed(response.SysMenusResponse{Menus: menus}, "获取成功", c)
 	}
 }
 
-// @Tags menu
-// @Summary 新增菜单
-// @Security ApiKeyAuth
-// @accept application/json
-// @Produce application/json
-// @Param data body model.SysBaseMenu true "路由path, 父菜单ID, 路由name, 对应前端文件路径, 排序标记"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
-// @Router /menu/addBaseMenu [post]
-func AddBaseMenu(c *gin.Context) {
-	var menu model.SysBaseMenu
-	_ = c.ShouldBindJSON(&menu)
-	MenuVerify := utils.Rules{
-		"Path":      {utils.NotEmpty()},
-		"ParentId":  {utils.NotEmpty()},
-		"Name":      {utils.NotEmpty()},
-		"Component": {utils.NotEmpty()},
-		"Sort":      {utils.Ge("0")},
-	}
-	if err := utils.Verify(menu, MenuVerify); err != nil {
-		response.FailWithMessage(err.Error(), c)
-		return
-	}
-	if err := utils.Verify(menu.Meta, utils.Rules{"Title": {utils.NotEmpty()}}); err != nil {
-		response.FailWithMessage(err.Error(), c)
-		return
-	}
-	if err := service.AddBaseMenu(menu); err != nil {
-		response.FailWithMessage(fmt.Sprintf("添加失败,%v", err), c)
-	} else {
-		response.OkWithMessage("添加成功", c)
-	}
-}
-
-// @Tags authorityAndMenu
+// @Tags AuthorityMenu
 // @Summary 获取用户动态路由
 // @Security ApiKeyAuth
 // @Produce  application/json
 // @Param data body request.Empty true "空"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /menu/getBaseMenuTree [post]
 func GetBaseMenuTree(c *gin.Context) {
 	if err, menus := service.GetBaseMenuTree(); err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取失败,%v", err), c)
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
 	} else {
-		response.OkWithData(resp.SysBaseMenusResponse{Menus: menus}, c)
+		response.OkWithDetailed(response.SysBaseMenusResponse{Menus: menus}, "获取成功", c)
 	}
 }
 
-// @Tags AuthorityAndMenu
+// @Tags AuthorityMenu
 // @Summary 增加menu和角色关联关系
 // @Security ApiKeyAuth
 // @accept application/json
@@ -111,20 +52,21 @@ func GetBaseMenuTree(c *gin.Context) {
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
 // @Router /menu/addMenuAuthority [post]
 func AddMenuAuthority(c *gin.Context) {
-	var params request.AddMenuAuthorityInfo
-	_ = c.ShouldBindJSON(&params)
-	if err := utils.Verify(params, utils.Rules{"AuthorityId": {"notEmpty"}}); err != nil {
+	var authorityMenu request.AddMenuAuthorityInfo
+	_ = c.ShouldBindJSON(&authorityMenu)
+	if err := utils.Verify(authorityMenu, utils.AuthorityIdVerify); err != nil {
 		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	if err := service.AddMenuAuthority(params.Menus, params.AuthorityId); err != nil {
-		response.FailWithMessage(fmt.Sprintf("添加失败,%v", err), c)
+	if err := service.AddMenuAuthority(authorityMenu.Menus, authorityMenu.AuthorityId); err != nil {
+		global.GVA_LOG.Error("添加失败!", zap.Any("err", err))
+		response.FailWithMessage("添加失败", c)
 	} else {
 		response.OkWithMessage("添加成功", c)
 	}
 }
 
-// @Tags AuthorityAndMenu
+// @Tags AuthorityMenu
 // @Summary 获取指定角色menu
 // @Security ApiKeyAuth
 // @accept application/json
@@ -135,18 +77,47 @@ func AddMenuAuthority(c *gin.Context) {
 func GetMenuAuthority(c *gin.Context) {
 	var param request.GetAuthorityId
 	_ = c.ShouldBindJSON(&param)
-	if err := utils.Verify(param, utils.Rules{"AuthorityId": {"notEmpty"}}); err != nil {
+	if err := utils.Verify(param, utils.AuthorityIdVerify); err != nil {
 		response.FailWithMessage(err.Error(), c)
 		return
 	}
 	if err, menus := service.GetMenuAuthority(&param); err != nil {
-		response.FailWithDetailed(response.ERROR, resp.SysMenusResponse{Menus: menus}, fmt.Sprintf("添加失败,%v", err), c)
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithDetailed(response.SysMenusResponse{Menus: menus}, "获取失败", c)
 	} else {
-		response.Result(response.SUCCESS, gin.H{"menus": menus}, "获取成功", c)
+		response.OkWithDetailed(gin.H{"menus": menus}, "获取成功", c)
 	}
 }
 
-// @Tags menu
+// @Tags Menu
+// @Summary 新增菜单
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body model.SysBaseMenu true "路由path, 父菜单ID, 路由name, 对应前端文件路径, 排序标记"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
+// @Router /menu/addBaseMenu [post]
+func AddBaseMenu(c *gin.Context) {
+	var menu model.SysBaseMenu
+	_ = c.ShouldBindJSON(&menu)
+	if err := utils.Verify(menu, utils.MenuVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	if err := utils.Verify(menu.Meta, utils.MenuMetaVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	if err := service.AddBaseMenu(menu); err != nil {
+		global.GVA_LOG.Error("添加失败!", zap.Any("err", err))
+
+		response.FailWithMessage("添加失败", c)
+	} else {
+		response.OkWithMessage("添加成功", c)
+	}
+}
+
+// @Tags Menu
 // @Summary 删除菜单
 // @Security ApiKeyAuth
 // @accept application/json
@@ -155,71 +126,94 @@ func GetMenuAuthority(c *gin.Context) {
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
 // @Router /menu/deleteBaseMenu [post]
 func DeleteBaseMenu(c *gin.Context) {
-	var param request.GetById
-	_ = c.ShouldBindJSON(&param)
-	if err := utils.Verify(param, utils.CustomizeMap["IdVerify"]); err != nil {
+	var menu request.GetById
+	_ = c.ShouldBindJSON(&menu)
+	if err := utils.Verify(menu, utils.IdVerify); err != nil {
 		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	if err := service.DeleteBaseMenu(param.Id); err != nil {
-		response.FailWithMessage(fmt.Sprintf("删除失败:%v", err), c)
+	if err := service.DeleteBaseMenu(menu.Id); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
+		response.FailWithMessage("删除失败", c)
 	} else {
 		response.OkWithMessage("删除成功", c)
-
 	}
 }
 
-// @Tags menu
+// @Tags Menu
 // @Summary 更新菜单
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
 // @Param data body model.SysBaseMenu true "路由path, 父菜单ID, 路由name, 对应前端文件路径, 排序标记"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
 // @Router /menu/updateBaseMenu [post]
 func UpdateBaseMenu(c *gin.Context) {
 	var menu model.SysBaseMenu
 	_ = c.ShouldBindJSON(&menu)
-	MenuVerify := utils.Rules{
-		"Path":      {"notEmpty"},
-		"ParentId":  {utils.NotEmpty()},
-		"Name":      {utils.NotEmpty()},
-		"Component": {utils.NotEmpty()},
-		"Sort":      {utils.Ge("0")},
-	}
-	if err := utils.Verify(menu, MenuVerify); err != nil {
+	if err := utils.Verify(menu, utils.MenuVerify); err != nil {
 		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	if err := utils.Verify(menu.Meta, utils.Rules{"Title": {utils.NotEmpty()}}); err != nil {
+	if err := utils.Verify(menu.Meta, utils.MenuMetaVerify); err != nil {
 		response.FailWithMessage(err.Error(), c)
 		return
 	}
 	if err := service.UpdateBaseMenu(menu); err != nil {
-		response.FailWithMessage(fmt.Sprintf("更新失败:%v", err), c)
+		global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
+		response.FailWithMessage("更新失败", c)
 	} else {
 		response.OkWithMessage("更新成功", c)
 	}
 }
 
-// @Tags menu
+// @Tags Menu
 // @Summary 根据id获取菜单
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
 // @Param data body request.GetById true "菜单id"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /menu/getBaseMenuById [post]
 func GetBaseMenuById(c *gin.Context) {
 	var idInfo request.GetById
 	_ = c.ShouldBindJSON(&idInfo)
-	if err := utils.Verify(idInfo, utils.Rules{"Id": {"notEmpty"}}); err != nil {
+	if err := utils.Verify(idInfo, utils.IdVerify); err != nil {
 		response.FailWithMessage(err.Error(), c)
 		return
 	}
 	if err, menu := service.GetBaseMenuById(idInfo.Id); err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取失败:%v", err), c)
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
 	} else {
-		response.OkWithData(resp.SysBaseMenuResponse{Menu: menu}, c)
+		response.OkWithDetailed(response.SysBaseMenuResponse{Menu: menu}, "获取成功", c)
 	}
 }
+
+// @Tags Menu
+// @Summary 分页获取基础menu列表
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body request.PageInfo true "页码, 每页大小"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Router /menu/getMenuList [post]
+func GetMenuList(c *gin.Context) {
+	var pageInfo request.PageInfo
+	_ = c.ShouldBindJSON(&pageInfo)
+	if err := utils.Verify(pageInfo, utils.PageInfoVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	if err, menuList, total := service.GetInfoList(); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List:     menuList,
+			Total:    total,
+			Page:     pageInfo.Page,
+			PageSize: pageInfo.PageSize,
+		},"获取成功", c)
+	}
+}

+ 32 - 26
server/api/v1/sys_operation_record.go

@@ -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 SysOperationRecord
@@ -21,9 +22,9 @@ import (
 func CreateSysOperationRecord(c *gin.Context) {
 	var sysOperationRecord model.SysOperationRecord
 	_ = c.ShouldBindJSON(&sysOperationRecord)
-	err := service.CreateSysOperationRecord(sysOperationRecord)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
+	if err := service.CreateSysOperationRecord(sysOperationRecord); err != nil {
+		global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
+		response.FailWithMessage("创建失败", c)
 	} else {
 		response.OkWithMessage("创建成功", c)
 	}
@@ -34,15 +35,15 @@ func CreateSysOperationRecord(c *gin.Context) {
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.SysOperationRecord true "删除SysOperationRecord"
+// @Param data body model.SysOperationRecord true "SysOperationRecord模型"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
 // @Router /sysOperationRecord/deleteSysOperationRecord [delete]
 func DeleteSysOperationRecord(c *gin.Context) {
 	var sysOperationRecord model.SysOperationRecord
 	_ = c.ShouldBindJSON(&sysOperationRecord)
-	err := service.DeleteSysOperationRecord(sysOperationRecord)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
+	if err := service.DeleteSysOperationRecord(sysOperationRecord); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
+		response.FailWithMessage("删除失败", c)
 	} else {
 		response.OkWithMessage("删除成功", c)
 	}
@@ -54,16 +55,17 @@ func DeleteSysOperationRecord(c *gin.Context) {
 // @accept application/json
 // @Produce application/json
 // @Param data body request.IdsReq true "批量删除SysOperationRecord"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
 // @Router /sysOperationRecord/deleteSysOperationRecordByIds [delete]
 func DeleteSysOperationRecordByIds(c *gin.Context) {
 	var IDS request.IdsReq
 	_ = c.ShouldBindJSON(&IDS)
-	err := service.DeleteSysOperationRecordByIds(IDS)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
+	if err := service.DeleteSysOperationRecordByIds(IDS); err != nil {
+		global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
+
+		response.FailWithMessage("批量删除失败", c)
 	} else {
-		response.OkWithMessage("删除成功", c)
+		response.OkWithMessage("批量删除成功", c)
 	}
 }
 
@@ -72,17 +74,21 @@ func DeleteSysOperationRecordByIds(c *gin.Context) {
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.SysOperationRecord true "用id查询SysOperationRecord"
+// @Param data body model.SysOperationRecord true "Id"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
 // @Router /sysOperationRecord/findSysOperationRecord [get]
 func FindSysOperationRecord(c *gin.Context) {
 	var sysOperationRecord model.SysOperationRecord
 	_ = c.ShouldBindQuery(&sysOperationRecord)
-	err, resysOperationRecord := service.GetSysOperationRecord(sysOperationRecord.ID)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c)
+	if err := utils.Verify(sysOperationRecord, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	if err, resysOperationRecord := service.GetSysOperationRecord(sysOperationRecord.ID); err != nil {
+		global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
+		response.FailWithMessage("查询失败", c)
 	} else {
-		response.OkWithData(gin.H{"resysOperationRecord": resysOperationRecord}, c)
+		response.OkWithDetailed(gin.H{"resysOperationRecord": resysOperationRecord}, "查询成功", c)
 	}
 }
 
@@ -91,21 +97,21 @@ func FindSysOperationRecord(c *gin.Context) {
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body request.SysOperationRecordSearch true "分页获取SysOperationRecord列表"
+// @Param data body request.SysOperationRecordSearch true "页码, 每页大小, 搜索条件"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /sysOperationRecord/getSysOperationRecordList [get]
 func GetSysOperationRecordList(c *gin.Context) {
 	var pageInfo request.SysOperationRecordSearch
 	_ = c.ShouldBindQuery(&pageInfo)
-	err, list, total := service.GetSysOperationRecordInfoList(pageInfo)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
+	if err, list, total := service.GetSysOperationRecordInfoList(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)
 	}
 }

+ 29 - 28
server/api/v1/sys_system.go

@@ -1,78 +1,79 @@
 package v1
 
 import (
-	"fmt"
-	"gin-vue-admin/global/response"
+	"gin-vue-admin/global"
 	"gin-vue-admin/model"
-	resp "gin-vue-admin/model/response"
+	"gin-vue-admin/model/response"
 	"gin-vue-admin/service"
 	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
 )
 
-// @Tags system
+// @Tags System
 // @Summary 获取配置文件内容
 // @Security ApiKeyAuth
 // @Produce  application/json
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /system/getSystemConfig [post]
 func GetSystemConfig(c *gin.Context) {
-	err, config := service.GetSystemConfig()
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取失败,%v", err), c)
+	if err, config := service.GetSystemConfig(); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
 	} else {
-		response.OkWithData(resp.SysConfigResponse{Config: config}, c)
+		response.OkWithDetailed(response.SysConfigResponse{Config: config}, "获取成功", c)
 	}
 }
 
-// @Tags system
+// @Tags System
 // @Summary 设置配置文件内容
 // @Security ApiKeyAuth
 // @Produce  application/json
 // @Param data body model.System true "设置配置文件内容"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}"
 // @Router /system/setSystemConfig [post]
 func SetSystemConfig(c *gin.Context) {
 	var sys model.System
 	_ = c.ShouldBindJSON(&sys)
-	err := service.SetSystemConfig(sys)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("设置失败,%v", err), c)
+	if err := service.SetSystemConfig(sys); err != nil {
+		global.GVA_LOG.Error("设置失败!", zap.Any("err", err))
+		response.FailWithMessage("设置失败", c)
 	} else {
 		response.OkWithData("设置成功", c)
 	}
 }
 
 // 本方法开发中 开发者windows系统 缺少linux系统所需的包 因此搁置
-// @Tags system
-// @Summary 设置配置文件内容
+// @Tags System
+// @Summary 重启系统
 // @Security ApiKeyAuth
 // @Produce  application/json
-// @Param data body model.System true "设置配置文件内容"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
+// @Param data body model.System true "重启系统"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"重启系统成功"}"
 // @Router /system/ReloadSystem [post]
 func ReloadSystem(c *gin.Context) {
 	var sys model.System
 	_ = c.ShouldBindJSON(&sys)
-	err := service.SetSystemConfig(sys)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("设置失败,%v", err), c)
+	if err := service.SetSystemConfig(sys); err != nil {
+		global.GVA_LOG.Error("重启系统失败!", zap.Any("err", err))
+		response.FailWithMessage("重启系统失败", c)
 	} else {
-		response.OkWithMessage("设置成功", c)
+		response.OkWithMessage("重启系统成功", c)
 	}
 }
 
-// @Tags system
+// @Tags System
 // @Summary 获取服务器信息
 // @Security ApiKeyAuth
 // @Produce  application/json
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /system/getServerInfo [post]
 func GetServerInfo(c *gin.Context) {
-	server, err := service.GetServerInfo()
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取失败,%v", err), c)
+	if server, err := service.GetServerInfo(); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
 		return
+	}else {
+		response.OkWithDetailed(gin.H{"server": server}, "获取成功", c)
 	}
-	response.OkDetailed(gin.H{"server":server}, "获取成功",c)
 
-}
+}

+ 57 - 82
server/api/v1/sys_user.go

@@ -1,44 +1,38 @@
 package v1
 
 import (
-	"fmt"
 	"gin-vue-admin/global"
-	"gin-vue-admin/global/response"
 	"gin-vue-admin/middleware"
 	"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/dgrijalva/jwt-go"
 	"github.com/gin-gonic/gin"
 	"github.com/go-redis/redis"
+	"go.uber.org/zap"
 	"time"
 )
 
 // @Tags Base
 // @Summary 用户登录
 // @Produce  application/json
-// @Param data body request.RegisterAndLoginStruct true "用户名, 密码, 验证码"
+// @Param data body request.Login true "用户名, 密码, 验证码"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}"
 // @Router /base/login [post]
 func Login(c *gin.Context) {
-	var L request.RegisterAndLoginStruct
+	var L request.Login
 	_ = c.ShouldBindJSON(&L)
-	UserVerify := utils.Rules{
-		"CaptchaId": {utils.NotEmpty()},
-		"Captcha":   {utils.NotEmpty()},
-		"Username":  {utils.NotEmpty()},
-		"Password":  {utils.NotEmpty()},
-	}
-	if UserVerifyErr := utils.Verify(L, UserVerify); UserVerifyErr != nil {
-		response.FailWithMessage(UserVerifyErr.Error(), c)
+	if err := utils.Verify(L, utils.LoginVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
 	if store.Verify(L.CaptchaId, L.Captcha, true) {
 		U := &model.SysUser{Username: L.Username, Password: L.Password}
 		if err, user := service.Login(U); err != nil {
-			response.FailWithMessage(fmt.Sprintf("用户名密码错误或%v", err), c)
+			global.GVA_LOG.Error("登陆失败! 用户名不存在或者密码错误", zap.Any("err", err))
+			response.FailWithMessage("登陆失败!", c)
 		} else {
 			tokenNext(c, *user)
 		}
@@ -65,30 +59,32 @@ func tokenNext(c *gin.Context, user model.SysUser) {
 	}
 	token, err := j.CreateToken(claims)
 	if err != nil {
+		global.GVA_LOG.Error("获取token失败", zap.Any("err", err))
 		response.FailWithMessage("获取token失败", c)
 		return
 	}
 	if !global.GVA_CONFIG.System.UseMultipoint {
-		response.OkWithData(resp.LoginResponse{
+		response.OkWithDetailed(response.LoginResponse{
 			User:      user,
 			Token:     token,
 			ExpiresAt: claims.StandardClaims.ExpiresAt * 1000,
-		}, c)
+		}, "登录成功", c)
 		return
 	}
-	err, jwtStr := service.GetRedisJWT(user.Username)
-	if err == redis.Nil {
+	if err, jwtStr := service.GetRedisJWT(user.Username); err == redis.Nil {
 		if err := service.SetRedisJWT(token, user.Username); err != nil {
+			global.GVA_LOG.Error("设置登录状态失败", zap.Any("err", err))
 			response.FailWithMessage("设置登录状态失败", c)
 			return
 		}
-		response.OkWithData(resp.LoginResponse{
+		response.OkWithDetailed(response.LoginResponse{
 			User:      user,
 			Token:     token,
 			ExpiresAt: claims.StandardClaims.ExpiresAt * 1000,
-		}, c)
+		}, "登录成功", c)
 	} else if err != nil {
-		response.FailWithMessage(fmt.Sprintf("%v", err), c)
+		global.GVA_LOG.Error("设置登录状态失败", zap.Any("err", err))
+		response.FailWithMessage("设置登录状态失败", c)
 	} else {
 		var blackJWT model.JwtBlacklist
 		blackJWT.Jwt = jwtStr
@@ -100,11 +96,11 @@ func tokenNext(c *gin.Context, user model.SysUser) {
 			response.FailWithMessage("设置登录状态失败", c)
 			return
 		}
-		response.OkWithData(resp.LoginResponse{
+		response.OkWithDetailed(response.LoginResponse{
 			User:      user,
 			Token:     token,
 			ExpiresAt: claims.StandardClaims.ExpiresAt * 1000,
-		}, c)
+		}, "登录成功", c)
 	}
 }
 
@@ -115,24 +111,19 @@ func tokenNext(c *gin.Context, user model.SysUser) {
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"注册成功"}"
 // @Router /user/register [post]
 func Register(c *gin.Context) {
-	var R request.RegisterStruct
+	var R request.Register
 	_ = c.ShouldBindJSON(&R)
-	UserVerify := utils.Rules{
-		"Username":    {utils.NotEmpty()},
-		"NickName":    {utils.NotEmpty()},
-		"Password":    {utils.NotEmpty()},
-		"AuthorityId": {utils.NotEmpty()},
-	}
-	if UserVerifyErr := utils.Verify(R, UserVerify); UserVerifyErr != nil {
-		response.FailWithMessage(UserVerifyErr.Error(), c)
+	if err := utils.Verify(R, utils.RegisterVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
 	user := &model.SysUser{Username: R.Username, NickName: R.NickName, Password: R.Password, HeaderImg: R.HeaderImg, AuthorityId: R.AuthorityId}
 	err, userReturn := service.Register(*user)
 	if err != nil {
-		response.FailWithDetailed(response.ERROR, resp.SysUserResponse{User: userReturn}, fmt.Sprintf("%v", err), c)
+		global.GVA_LOG.Error("注册失败", zap.Any("err", err))
+		response.FailWithDetailed(response.SysUserResponse{User: userReturn}, "注册失败", c)
 	} else {
-		response.OkDetailed(resp.SysUserResponse{User: userReturn}, "注册成功", c)
+		response.OkWithDetailed(response.SysUserResponse{User: userReturn}, "注册成功", c)
 	}
 }
 
@@ -144,19 +135,15 @@ func Register(c *gin.Context) {
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
 // @Router /user/changePassword [put]
 func ChangePassword(c *gin.Context) {
-	var params request.ChangePasswordStruct
-	_ = c.ShouldBindJSON(&params)
-	UserVerify := utils.Rules{
-		"Username":    {utils.NotEmpty()},
-		"Password":    {utils.NotEmpty()},
-		"NewPassword": {utils.NotEmpty()},
-	}
-	if UserVerifyErr := utils.Verify(params, UserVerify); UserVerifyErr != nil {
-		response.FailWithMessage(UserVerifyErr.Error(), c)
+	var user request.ChangePasswordStruct
+	_ = c.ShouldBindJSON(&user)
+	if err := utils.Verify(user, utils.ChangePasswordVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	U := &model.SysUser{Username: params.Username, Password: params.Password}
-	if err, _ := service.ChangePassword(U, params.NewPassword); err != nil {
+	U := &model.SysUser{Username: user.Username, Password: user.Password}
+	if err, _ := service.ChangePassword(U, user.NewPassword); err != nil {
+		global.GVA_LOG.Error("修改失败", zap.Any("err", err))
 		response.FailWithMessage("修改失败,请检查用户名密码", c)
 	} else {
 		response.OkWithMessage("修改成功", c)
@@ -174,20 +161,20 @@ func ChangePassword(c *gin.Context) {
 func GetUserList(c *gin.Context) {
 	var pageInfo request.PageInfo
 	_ = c.ShouldBindJSON(&pageInfo)
-	if PageVerifyErr := utils.Verify(pageInfo, utils.CustomizeMap["PageVerify"]); PageVerifyErr != nil {
-		response.FailWithMessage(PageVerifyErr.Error(), c)
+	if err := utils.Verify(pageInfo, utils.PageInfoVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err, list, total := service.GetUserInfoList(pageInfo)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
+	if err, list, total := service.GetUserInfoList(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)
 	}
 }
 
@@ -202,17 +189,13 @@ func GetUserList(c *gin.Context) {
 func SetUserAuthority(c *gin.Context) {
 	var sua request.SetUserAuth
 	_ = c.ShouldBindJSON(&sua)
-	UserVerify := utils.Rules{
-		"UUID":        {utils.NotEmpty()},
-		"AuthorityId": {utils.NotEmpty()},
-	}
-	if UserVerifyErr := utils.Verify(sua, UserVerify); UserVerifyErr != nil {
+	if UserVerifyErr := utils.Verify(sua, utils.SetUserAuthorityVerify); UserVerifyErr != nil {
 		response.FailWithMessage(UserVerifyErr.Error(), c)
 		return
 	}
-	err := service.SetUserAuthority(sua.UUID, sua.AuthorityId)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("修改失败,%v", err), c)
+	if err := service.SetUserAuthority(sua.UUID, sua.AuthorityId); err != nil {
+		global.GVA_LOG.Error("修改失败", zap.Any("err", err))
+		response.FailWithMessage("修改失败", c)
 	} else {
 		response.OkWithMessage("修改成功", c)
 	}
@@ -224,18 +207,18 @@ func SetUserAuthority(c *gin.Context) {
 // @accept application/json
 // @Produce application/json
 // @Param data body request.GetById true "用户ID"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
 // @Router /user/deleteUser [delete]
 func DeleteUser(c *gin.Context) {
 	var reqId request.GetById
 	_ = c.ShouldBindJSON(&reqId)
-	if IdVerifyErr := utils.Verify(reqId, utils.CustomizeMap["IdVerify"]); IdVerifyErr != nil {
-		response.FailWithMessage(IdVerifyErr.Error(), c)
+	if err := utils.Verify(reqId, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err := service.DeleteUser(reqId.Id)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
+	if err := service.DeleteUser(reqId.Id); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
+		response.FailWithMessage("删除失败", c)
 	} else {
 		response.OkWithMessage("删除成功", c)
 	}
@@ -247,28 +230,20 @@ func DeleteUser(c *gin.Context) {
 // @accept application/json
 // @Produce application/json
 // @Param data body model.SysUser true "ID, 用户名, 昵称, 头像链接"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}"
 // @Router /user/setUserInfo [put]
 func SetUserInfo(c *gin.Context) {
 	var user model.SysUser
-	UserVerify := utils.Rules{
-		"ID":        {utils.NotEmpty()},
-		"Username":  {utils.NotEmpty()},
-		"NickName":  {utils.NotEmpty()},
-		"HeaderImg": {utils.NotEmpty()},
-	}
-	if UserVerifyErr := utils.Verify(user, UserVerify); UserVerifyErr != nil {
-		response.FailWithMessage(UserVerifyErr.Error(), c)
+	_ = c.ShouldBindJSON(&user)
+	if err := utils.Verify(user, utils.SetUserVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	_ = c.ShouldBindJSON(&user)
-	err, ReqUser := service.SetUserInfo(user)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c)
+	if err, ReqUser := service.SetUserInfo(user); err != nil {
+		global.GVA_LOG.Error("设置失败", zap.Any("err", err))
+		response.FailWithMessage("设置失败", c)
 	} else {
-		response.OkWithData(gin.H{
-			"userInfo": ReqUser,
-		}, c)
+		response.OkWithDetailed(gin.H{"userInfo": ReqUser}, "设置成功", c)
 	}
 }
 

+ 9 - 15
server/api/v1/sys_work_flow.go

@@ -1,12 +1,13 @@
 package v1
 
 import (
-	"fmt"
-	"gin-vue-admin/global/response"
+	"gin-vue-admin/global"
 	"gin-vue-admin/model"
+	"gin-vue-admin/model/response"
 	"gin-vue-admin/service"
 	"gin-vue-admin/utils"
 	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
 )
 
 // @Tags workflow
@@ -18,21 +19,14 @@ import (
 func CreateWorkFlow(c *gin.Context) {
 	var wk model.SysWorkflow
 	_ = c.ShouldBindJSON(&wk)
-	WKVerify := utils.Rules{
-		"WorkflowNickName":    {utils.NotEmpty()},
-		"WorkflowName":        {utils.NotEmpty()},
-		"WorkflowDescription": {utils.NotEmpty()},
-		"WorkflowStepInfo":    {utils.NotEmpty()},
-	}
-	WKVerifyErr := utils.Verify(wk, WKVerify)
-	if WKVerifyErr != nil {
-		response.FailWithMessage(WKVerifyErr.Error(), c)
+	if err := utils.Verify(wk, utils.WorkFlowVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err := service.Create(wk)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取失败:%v", err), c)
+	if err := service.Create(wk); err != nil {
+		global.GVA_LOG.Error("注册失败!", zap.Any("err", err))
+		response.FailWithMessage("注册失败", c)
 	} else {
-		response.OkWithMessage("获取成功", c)
+		response.OkWithMessage("注册成功", c)
 	}
 }

+ 2 - 2
server/model/request/sys_user.go

@@ -3,7 +3,7 @@ package request
 import uuid "github.com/satori/go.uuid"
 
 // User register structure
-type RegisterStruct struct {
+type Register struct {
 	Username    string `json:"userName"`
 	Password    string `json:"passWord"`
 	NickName    string `json:"nickName" gorm:"default:'QMPlusUser'"`
@@ -12,7 +12,7 @@ type RegisterStruct struct {
 }
 
 // User login structure
-type RegisterAndLoginStruct struct {
+type Login struct {
 	Username  string `json:"username"`
 	Password  string `json:"password"`
 	Captcha   string `json:"captcha"`

+ 3 - 3
server/global/response/response.go → server/model/response/response.go

@@ -37,7 +37,7 @@ func OkWithData(data interface{}, c *gin.Context) {
 	Result(SUCCESS, data, "操作成功", c)
 }
 
-func OkDetailed(data interface{}, message string, c *gin.Context) {
+func OkWithDetailed(data interface{}, message string, c *gin.Context) {
 	Result(SUCCESS, data, message, c)
 }
 
@@ -49,6 +49,6 @@ func FailWithMessage(message string, c *gin.Context) {
 	Result(ERROR, map[string]interface{}{}, message, c)
 }
 
-func FailWithDetailed(code int, data interface{}, message string, c *gin.Context) {
-	Result(code, data, message, c)
+func FailWithDetailed(data interface{}, message string, c *gin.Context) {
+	Result(ERROR, data, message, c)
 }

+ 21 - 0
server/utils/verify.go

@@ -0,0 +1,21 @@
+package utils
+
+var (
+	IdVerify               = Rules{"ID": {NotEmpty()}}
+	ApiVerify              = Rules{"Path": {NotEmpty()}, "Description": {NotEmpty()}, "ApiGroup": {NotEmpty()}, "Method": {NotEmpty()}}
+	MenuVerify             = Rules{"Path": {NotEmpty()}, "ParentId": {NotEmpty()}, "Name": {NotEmpty()}, "Component": {NotEmpty()}, "Sort": {Ge("0")}}
+	MenuMetaVerify         = Rules{"Title": {NotEmpty()}}
+	LoginVerify            = Rules{"CaptchaId": {NotEmpty()}, "Captcha": {NotEmpty()}, "Username": {NotEmpty()}, "Password": {NotEmpty()}}
+	SetUserVerify          = Rules{"ID": {NotEmpty()}, "Username": {NotEmpty()}, "NickName": {NotEmpty()}, "HeaderImg": {NotEmpty()}}
+	RegisterVerify         = Rules{"Username": {NotEmpty()}, "NickName": {NotEmpty()}, "Password": {NotEmpty()}, "AuthorityId": {NotEmpty()}}
+	PageInfoVerify         = Rules{"Page": {NotEmpty()}, "PageSize": {NotEmpty()}}
+	CustomerVerify         = Rules{"CustomerName": {NotEmpty()}, "CustomerPhoneData": {NotEmpty()}}
+	AutoCodeVerify         = Rules{"Abbreviation": {NotEmpty()}, "StructName": {NotEmpty()}, "PackageName": {NotEmpty()}, "Fields": {NotEmpty()}}
+	WorkFlowVerify         = Rules{"WorkflowNickName": {NotEmpty()}, "WorkflowName": {NotEmpty()}, "WorkflowDescription": {NotEmpty()}, "WorkflowStepInfo": {NotEmpty()}}
+	AuthorityVerify        = Rules{"AuthorityId": {NotEmpty()}, "AuthorityName": {NotEmpty()}, "ParentId": {NotEmpty()}}
+	DictionaryVerify       = Rules{"Type": {NotEmpty()}, "ID": {NotEmpty()}}
+	AuthorityIdVerify      = Rules{"AuthorityId": {NotEmpty()}}
+	OldAuthorityVerify     = Rules{"OldAuthorityId": {NotEmpty()}}
+	ChangePasswordVerify   = Rules{"Username": {NotEmpty()}, "Password": {NotEmpty()}, "NewPassword": {NotEmpty()}}
+	SetUserAuthorityVerify = Rules{"UUID": {NotEmpty()}, "AuthorityId": {NotEmpty()}}
+)