Browse Source

Merge branch 'develop' into develop

奇淼(piexlmax 4 years ago
parent
commit
a694dbd010
100 changed files with 2855 additions and 2078 deletions
  1. 3 1
      README.md
  2. 27 18
      server/api/v1/exa_breakpoint_continue.go
  3. 56 80
      server/api/v1/exa_customer.go
  4. 16 12
      server/api/v1/exa_file_upload_download.go
  5. 21 15
      server/api/v1/exa_simple_uploader.go
  6. 48 70
      server/api/v1/sys_api.go
  7. 60 86
      server/api/v1/sys_authority.go
  8. 41 84
      server/api/v1/sys_auto_code.go
  9. 8 9
      server/api/v1/sys_captcha.go
  10. 21 23
      server/api/v1/sys_casbin.go
  11. 40 35
      server/api/v1/sys_dictionary.go
  12. 38 33
      server/api/v1/sys_dictionary_detail.go
  13. 8 7
      server/api/v1/sys_email.go
  14. 8 9
      server/api/v1/sys_jwt_blacklist.go
  15. 121 161
      server/api/v1/sys_menu.go
  16. 31 26
      server/api/v1/sys_operation_record.go
  17. 29 28
      server/api/v1/sys_system.go
  18. 127 118
      server/api/v1/sys_user.go
  19. 9 15
      server/api/v1/sys_work_flow.go
  20. 3 2
      server/cmd/datas/AuthorityMenu.go
  21. 8 4
      server/cmd/datas/apis.go
  22. 7 3
      server/cmd/datas/authorities.go
  23. 7 3
      server/cmd/datas/authority_Ids.go
  24. 7 3
      server/cmd/datas/authority_menus.go
  25. 8 4
      server/cmd/datas/casbins.go
  26. 7 3
      server/cmd/datas/customers.go
  27. 7 3
      server/cmd/datas/dictionaries.go
  28. 7 3
      server/cmd/datas/dictionary_details.go
  29. 8 3
      server/cmd/datas/files.go
  30. 12 18
      server/cmd/datas/init.go
  31. 7 3
      server/cmd/datas/menus.go
  32. 8 4
      server/cmd/datas/users.go
  33. 53 0
      server/cmd/gva/run.go
  34. 2 2
      server/config.yaml
  35. 2 1
      server/core/server.go
  36. 1 1
      server/core/zap.go
  37. 177 135
      server/docs/docs.go
  38. 177 134
      server/docs/swagger.json
  39. 201 188
      server/docs/swagger.yaml
  40. 4 2
      server/go.mod
  41. 24 19
      server/initialize/router.go
  42. 2 2
      server/middleware/casbin_rbac.go
  43. 18 28
      server/middleware/jwt.go
  44. 6 6
      server/middleware/operation.go
  45. 8 1
      server/model/request/common.go
  46. 6 6
      server/model/request/sys_autocode.go
  47. 0 5
      server/model/request/sys_menu.go
  48. 2 2
      server/model/request/sys_user.go
  49. 3 3
      server/model/response/response.go
  50. 5 0
      server/model/sys_auto_code.go
  51. 3 3
      server/model/sys_base_menu.go
  52. 35 35
      server/resource/template/server/api.go.tpl
  53. 3 3
      server/resource/template/server/model.go.tpl
  54. 0 0
      server/resource/template/server/request.go.tpl
  55. 0 0
      server/resource/template/server/router.go.tpl
  56. 30 31
      server/resource/template/server/service.go.tpl
  57. 0 0
      server/resource/template/web/api.js.tpl
  58. 125 0
      server/resource/template/web/form.vue.tpl
  59. 10 1
      server/resource/template/web/table.vue.tpl
  60. 1 4
      server/router/exa_simple_uploader.go
  61. 1 4
      server/router/exp_customer.go
  62. 0 1
      server/router/exp_file_upload_and_download.go
  63. 1 1
      server/router/sys_api.go
  64. 1 4
      server/router/sys_authority.go
  65. 2 6
      server/router/sys_auto_code.go
  66. 1 4
      server/router/sys_casbin.go
  67. 1 4
      server/router/sys_dictionary.go
  68. 1 4
      server/router/sys_dictionary_detail.go
  69. 1 1
      server/router/sys_email.go
  70. 1 1
      server/router/sys_jwt.go
  71. 1 1
      server/router/sys_menu.go
  72. 5 7
      server/router/sys_operation_record.go
  73. 1 1
      server/router/sys_system.go
  74. 1 4
      server/router/sys_user.go
  75. 1 1
      server/router/sys_workflow.go
  76. 15 23
      server/service/exa_breakpoint_continue.go
  77. 25 27
      server/service/exa_customer.go
  78. 26 31
      server/service/exa_file_upload_download.go
  79. 40 26
      server/service/exa_simple_uploader.go
  80. 20 23
      server/service/jwt_black_list.go
  81. 29 39
      server/service/sys_api.go
  82. 46 52
      server/service/sys_authority.go
  83. 157 21
      server/service/sys_auto_code.go
  84. 45 23
      server/service/sys_base_menu.go
  85. 35 40
      server/service/sys_casbin.go
  86. 26 26
      server/service/sys_dictionary.go
  87. 25 26
      server/service/sys_dictionary_detail.go
  88. 4 4
      server/service/sys_email.go
  89. 50 59
      server/service/sys_menu.go
  90. 27 26
      server/service/sys_operation_record.go
  91. 14 16
      server/service/sys_system.go
  92. 46 56
      server/service/sys_user.go
  93. 5 5
      server/service/sys_workflow.go
  94. 30 0
      server/utils/breakpoint_continue.go
  95. 204 0
      server/utils/cmd_Task.go
  96. 174 0
      server/utils/cmd_monitor.go
  97. 10 10
      server/utils/directory.go
  98. 24 1
      server/utils/email.go
  99. 41 0
      server/utils/file_operations.go
  100. 12 2
      server/utils/fmt_plus.go

+ 3 - 1
README.md

@@ -12,12 +12,14 @@
 
 [English](./README-en.md) | 简体中文
 
-[gitee地址](https://gitee.com/pixelmax/gin-vue-admin)
+[gitee地址](https://gitee.com/pixelmax/gin-vue-admin)|
 [github地址](https://github.com/flipped-aurora/gin-vue-admin)
 
 # 项目文档
 [在线文档](https://www.gin-vue-admin.com/) : https://www.gin-vue-admin.com/
 
+[从环境到部署教学视频](https://www.bilibili.com/video/BV1fV411y7dT)
+
 [开发教学](https://www.gin-vue-admin.com/docs/help) (贡献者:  <a href="https://github.com/LLemonGreen">LLemonGreen</a> And <a href="https://github.com/fkk0509">Fann</a>)
 - 前端UI框架:[element-ui](https://github.com/ElemeFE/element) 
 - 后台框架:[gin](https://github.com/gin-gonic/gin) 

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

+ 56 - 80
server/api/v1/exa_customer.go

@@ -2,164 +2,140 @@ 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
+// @Tags ExaCustomer
 // @Summary 创建客户
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.ExaCustomer true "创建客户"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Param data body model.ExaCustomer true "客户用户名, 客户手机号码"
+// @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()},
-	}
-	CustomerVerifyErr := utils.Verify(cu, CustomerVerify)
-	if 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
 	}
-	claims, _ := c.Get("claims")
-	waitUse := claims.(*request.CustomClaims)
-	cu.SysUserID = waitUse.ID
-	cu.SysUserAuthorityID = waitUse.AuthorityId
-	err := service.CreateExaCustomer(cu)
-	if 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)
 	}
 }
 
-// @Tags SysApi
+// @Tags ExaCustomer
 // @Summary 删除客户
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.ExaCustomer true "删除客户"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Param data body model.ExaCustomer true "客户ID"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
 // @Router /customer/customer [delete]
 func DeleteExaCustomer(c *gin.Context) {
-	var cu model.ExaCustomer
-	_ = c.ShouldBindJSON(&cu)
-	CustomerVerify := utils.Rules{
-		"ID": {utils.NotEmpty()},
-	}
-	CustomerVerifyErr := utils.Verify(cu.GVA_MODEL, CustomerVerify)
-	if 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
 	}
-	err := service.DeleteExaCustomer(cu)
-	if 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)
 	}
 }
 
-// @Tags SysApi
+// @Tags ExaCustomer
 // @Summary 更新客户信息
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.ExaCustomer true "创建客户"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Param data body model.ExaCustomer true "客户ID, 客户信息"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
 // @Router /customer/customer [put]
 func UpdateExaCustomer(c *gin.Context) {
-	var cu model.ExaCustomer
-	_ = c.ShouldBindJSON(&cu)
-	IdCustomerVerify := utils.Rules{
-		"ID": {utils.NotEmpty()},
-	}
-	IdCustomerVerifyErr := utils.Verify(cu.GVA_MODEL, IdCustomerVerify)
-	if 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()},
-	}
-	CustomerVerifyErr := utils.Verify(cu, CustomerVerify)
-	if CustomerVerifyErr != nil {
-		response.FailWithMessage(CustomerVerifyErr.Error(), c)
+	if err := utils.Verify(customer, utils.CustomerVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err := service.UpdateExaCustomer(&cu)
-	if 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)
 	}
 }
 
-// @Tags SysApi
+// @Tags ExaCustomer
 // @Summary 获取单一客户信息
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.ExaCustomer true "获取单一客户信息"
+// @Param data body model.ExaCustomer true "客户ID"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /customer/customer [get]
 func GetExaCustomer(c *gin.Context) {
-	var cu model.ExaCustomer
-	_ = c.ShouldBindQuery(&cu)
-	IdCustomerVerify := utils.Rules{
-		"ID": {utils.NotEmpty()},
-	}
-	IdCustomerVerifyErr := utils.Verify(cu.GVA_MODEL, IdCustomerVerify)
-	if 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 SysApi
-// @Summary 获取权限客户列表
+// @Tags ExaCustomer
+// @Summary 分页获取权限客户列表
 // @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 /customer/customerList [get]
 func GetExaCustomerList(c *gin.Context) {
-	claims, _ := c.Get("claims")
-	waitUse := claims.(*request.CustomClaims)
 	var pageInfo request.PageInfo
 	_ = c.ShouldBindQuery(&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, customerList, total := service.GetCustomerInfoList(waitUse.AuthorityId, pageInfo)
+	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)
 	}
 }

+ 21 - 15
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
@@ -15,7 +16,7 @@ import (
 // @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 /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)
 	}
 }

+ 60 - 86
server/api/v1/sys_authority.go

@@ -1,166 +1,141 @@
 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
+// @Tags Authority
 // @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/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("创建失败"+err.Error(), c)
 	} else {
-		response.OkWithData(resp.SysAuthorityResponse{Authority: authBack}, c)
+		response.OkWithDetailed(response.SysAuthorityResponse{Authority: authBack}, "创建成功", c)
 	}
 }
 
-// @Tags authority
+// @Tags Authority
 // @Summary 拷贝角色
 // @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("拷贝失败"+err.Error(), c)
 	} else {
-		response.OkWithData(resp.SysAuthorityResponse{Authority: authBack}, c)
+		response.OkWithDetailed(response.SysAuthorityResponse{Authority: authBack}, "拷贝成功", c)
 	}
 }
 
-// @Tags authority
+// @Tags Authority
 // @Summary 删除角色
 // @Security ApiKeyAuth
 // @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("删除失败"+err.Error(), c)
 	} else {
 		response.OkWithMessage("删除成功", c)
 	}
 }
 
-// @Tags authority
-// @Summary 设置角色资源权限
+// @Tags Authority
+// @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("更新失败"+err.Error(), c)
 	} else {
-		response.OkWithData(resp.SysAuthorityResponse{Authority: authority}, c)
+		response.OkWithDetailed(response.SysAuthorityResponse{Authority: authority}, "更新成功", c)
 	}
 }
 
-// @Tags authority
+// @Tags Authority
 // @Summary 分页获取角色列表
 // @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("获取失败"+err.Error(), c)
 	} else {
-		response.OkWithData(resp.PageResult{
+		response.OkWithDetailed(response.PageResult{
 			List:     list,
 			Total:    total,
 			Page:     pageInfo.Page,
 			PageSize: pageInfo.PageSize,
-		}, c)
+		}, "获取成功", c)
 	}
 }
 
-// @Tags authority
+// @Tags Authority
 // @Summary 设置角色资源权限
 // @Security ApiKeyAuth
 // @accept application/json
@@ -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("设置失败"+err.Error(), c)
 	} else {
-		response.Ok(c)
+		response.OkWithMessage("设置成功", c)
 	}
 }

+ 41 - 84
server/api/v1/sys_auto_code.go

@@ -3,16 +3,18 @@ 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"
+	"github.com/pkg/errors"
+	"go.uber.org/zap"
 	"net/url"
 	"os"
 )
 
-// @Tags SysApi
+// @Tags AutoCode
 // @Summary 自动代码模板
 // @Security ApiKeyAuth
 // @accept application/json
@@ -23,132 +25,87 @@ import (
 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 {
-		apiList := [6]model.SysApi{
-			{
-				Path:        "/" + a.Abbreviation + "/" + "create" + a.StructName,
-				Description: "新增" + a.Description,
-				ApiGroup:    a.Abbreviation,
-				Method:      "POST",
-			},
-			{
-				Path:        "/" + a.Abbreviation + "/" + "delete" + a.StructName,
-				Description: "删除" + a.Description,
-				ApiGroup:    a.Abbreviation,
-				Method:      "DELETE",
-			},
-			{
-				Path:        "/" + a.Abbreviation + "/" + "delete" + a.StructName+"ByIds",
-				Description: "批量删除" + a.Description,
-				ApiGroup:    a.Abbreviation,
-				Method:      "DELETE",
-			},
-			{
-				Path:        "/" + a.Abbreviation + "/" + "update" + a.StructName,
-				Description: "更新" + a.Description,
-				ApiGroup:    a.Abbreviation,
-				Method:      "PUT",
-			},
-			{
-				Path:        "/" + a.Abbreviation + "/" + "find" + a.StructName,
-				Description: "根据ID获取" + a.Description,
-				ApiGroup:    a.Abbreviation,
-				Method:      "GET",
-			},
-			{
-				Path:        "/" + a.Abbreviation + "/" + "get" + a.StructName + "List",
-				Description: "获取" + a.Description + "列表",
-				ApiGroup:    a.Abbreviation,
-				Method:      "GET",
-			},
-		}
-		for _, v := range apiList {
-			errC := service.CreateApi(v)
-			if errC != nil {
-				c.Writer.Header().Add("success", "false")
-				c.Writer.Header().Add("msg", url.QueryEscape(fmt.Sprintf("自动化创建失败,%v,请自行清空垃圾数据", errC)))
-				return
-			}
+		if err := service.AutoCreateApi(&a); err != nil {
+			global.GVA_LOG.Error("自动化创建失败!请自行清空垃圾数据!", zap.Any("err", err))
+			c.Writer.Header().Add("success", "false")
+			c.Writer.Header().Add("msg", url.QueryEscape("自动化创建失败!请自行清空垃圾数据!"))
+			return
 		}
 	}
 	err := service.CreateTemp(a)
 	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
-		os.Remove("./ginvueadmin.zip")
+		if errors.Is(err, model.AutoMoveErr) {
+			c.Writer.Header().Add("success", "false")
+			c.Writer.Header().Add("msgtype", "success")
+			c.Writer.Header().Add("msg", url.QueryEscape(err.Error()))
+		} else {
+			c.Writer.Header().Add("success", "false")
+			c.Writer.Header().Add("msg", url.QueryEscape(err.Error()))
+			_ = os.Remove("./ginvueadmin.zip")
+		}
+
 	} else {
 		c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", "ginvueadmin.zip")) // fmt.Sprintf("attachment; filename=%s", filename)对下载的文件重命名
 		c.Writer.Header().Add("Content-Type", "application/json")
 		c.Writer.Header().Add("success", "true")
 		c.File("./ginvueadmin.zip")
-		os.Remove("./ginvueadmin.zip")
+		_ = os.Remove("./ginvueadmin.zip")
 	}
 }
 
-// @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":"创建成功"}"
-// @Router /autoCode/getDatabase [get]
-func GetColume(c *gin.Context) {
+// @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, columes := service.GetColume(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{
-			"columes": columes,
-		}, 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)
 }
 

+ 40 - 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,17 @@ 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, 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 +92,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)
 	}

+ 121 - 161
server/api/v1/sys_menu.go

@@ -1,259 +1,219 @@
 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 authorityAndMenu
+// @Tags AuthorityMenu
 // @Summary 获取用户动态路由
 // @Security ApiKeyAuth
 // @Produce  application/json
-// @Param data body request.RegisterAndLoginStruct true "可以什么都不填"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
+// @Param data body request.Empty true "空"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /menu/getMenu [post]
 func GetMenu(c *gin.Context) {
-	claims, _ := c.Get("claims")
-	waitUse := claims.(*request.CustomClaims)
-	err, menus := service.GetMenuTree(waitUse.AuthorityId)
-	if 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 "分页获取基础menu列表"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
-// @Router /menu/getMenuList [post]
-func GetMenuList(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)
-		return
-	}
-	err, menuList, total := service.GetInfoList()
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
-	} else {
-		response.OkWithData(resp.PageResult{
-			List:     menuList,
-			Total:    total,
-			Page:     pageInfo.Page,
-			PageSize: pageInfo.PageSize,
-		}, c)
-	}
-}
-
-// @Tags menu
-// @Summary 新增菜单
-// @Security ApiKeyAuth
-// @accept application/json
-// @Produce application/json
-// @Param data body model.SysBaseMenu true "新增菜单"
-// @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")},
-	}
-	MenuVerifyErr := utils.Verify(menu, MenuVerify)
-	if MenuVerifyErr != nil {
-		response.FailWithMessage(MenuVerifyErr.Error(), c)
-		return
-	}
-	MetaVerify := utils.Rules{
-		"Title": {utils.NotEmpty()},
-	}
-	MetaVerifyErr := utils.Verify(menu.Meta, MetaVerify)
-	if MetaVerifyErr != nil {
-		response.FailWithMessage(MetaVerifyErr.Error(), c)
-		return
-	}
-	err := service.AddBaseMenu(menu)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("添加失败,%v", err), c)
+	if err, menus := service.GetMenuTree(getUserAuthorityId(c)); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
 	} else {
-		response.OkWithMessage("添加成功", c)
+		response.OkWithDetailed(response.SysMenusResponse{Menus: menus}, "获取成功", c)
 	}
 }
 
-// @Tags authorityAndMenu
+// @Tags AuthorityMenu
 // @Summary 获取用户动态路由
 // @Security ApiKeyAuth
 // @Produce  application/json
-// @Param data body request.RegisterAndLoginStruct true "可以什么都不填"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
+// @Param data body request.Empty true "空"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /menu/getBaseMenuTree [post]
 func GetBaseMenuTree(c *gin.Context) {
-	err, menus := service.GetBaseMenuTree()
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取失败,%v", err), c)
+	if err, menus := service.GetBaseMenuTree(); err != nil {
+		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
 // @Produce application/json
-// @Param data body request.AddMenuAuthorityInfo true "增加menu和角色关联关系"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Param data body request.AddMenuAuthorityInfo true "角色ID"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
 // @Router /menu/addMenuAuthority [post]
 func AddMenuAuthority(c *gin.Context) {
-	var addMenuAuthorityInfo request.AddMenuAuthorityInfo
-	_ = c.ShouldBindJSON(&addMenuAuthorityInfo)
-	MenuVerify := utils.Rules{
-		"AuthorityId": {"notEmpty"},
-	}
-	MenuVerifyErr := utils.Verify(addMenuAuthorityInfo, MenuVerify)
-	if MenuVerifyErr != nil {
-		response.FailWithMessage(MenuVerifyErr.Error(), c)
+	var authorityMenu request.AddMenuAuthorityInfo
+	_ = c.ShouldBindJSON(&authorityMenu)
+	if err := utils.Verify(authorityMenu, utils.AuthorityIdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err := service.AddMenuAuthority(addMenuAuthorityInfo.Menus, addMenuAuthorityInfo.AuthorityId)
-	if 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
 // @Produce application/json
-// @Param data body request.AuthorityIdInfo true "增加menu和角色关联关系"
+// @Param data body request.GetAuthorityId true "角色ID"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /menu/GetMenuAuthority [post]
 func GetMenuAuthority(c *gin.Context) {
-	var authorityIdInfo request.AuthorityIdInfo
-	_ = c.ShouldBindJSON(&authorityIdInfo)
-	MenuVerify := utils.Rules{
-		"AuthorityId": {"notEmpty"},
+	var param request.GetAuthorityId
+	_ = c.ShouldBindJSON(&param)
+	if err := utils.Verify(param, utils.AuthorityIdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
 	}
-	MenuVerifyErr := utils.Verify(authorityIdInfo, MenuVerify)
-	if MenuVerifyErr != nil {
-		response.FailWithMessage(MenuVerifyErr.Error(), c)
+	if err, menus := service.GetMenuAuthority(&param); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithDetailed(response.SysMenusResponse{Menus: menus}, "获取失败", c)
+	} else {
+		response.OkWithDetailed(gin.H{"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)
+	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
 	}
-	err, menus := service.GetMenuAuthority(authorityIdInfo.AuthorityId)
-	if err != nil {
-		response.FailWithDetailed(response.ERROR, resp.SysMenusResponse{Menus: menus}, fmt.Sprintf("添加失败,%v", err), c)
+	if err := service.AddBaseMenu(menu); err != nil {
+		global.GVA_LOG.Error("添加失败!", zap.Any("err", err))
+
+		response.FailWithMessage("添加失败", c)
 	} else {
-		response.Result(response.SUCCESS, gin.H{"menus": menus}, "获取成功", c)
+		response.OkWithMessage("添加成功", c)
 	}
 }
 
-// @Tags menu
+// @Tags Menu
 // @Summary 删除菜单
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body request.GetById true "删除菜单"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Param data body request.GetById true "菜单id"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
 // @Router /menu/deleteBaseMenu [post]
 func DeleteBaseMenu(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)
+	var menu request.GetById
+	_ = c.ShouldBindJSON(&menu)
+	if err := utils.Verify(menu, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err := service.DeleteBaseMenu(idInfo.Id)
-	if 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 "更新菜单"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Param data body model.SysBaseMenu true "路由path, 父菜单ID, 路由name, 对应前端文件路径, 排序标记"
+// @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")},
-	}
-	MenuVerifyErr := utils.Verify(menu, MenuVerify)
-	if MenuVerifyErr != nil {
-		response.FailWithMessage(MenuVerifyErr.Error(), c)
+	if err := utils.Verify(menu, utils.MenuVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	MetaVerify := utils.Rules{
-		"Title": {utils.NotEmpty()},
-	}
-	MetaVerifyErr := utils.Verify(menu.Meta, MetaVerify)
-	if MetaVerifyErr != nil {
-		response.FailWithMessage(MetaVerifyErr.Error(), c)
+	if err := utils.Verify(menu.Meta, utils.MenuMetaVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err := service.UpdateBaseMenu(menu)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("修改失败:%v", err), c)
+	if err := service.UpdateBaseMenu(menu); err != nil {
+		global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
+		response.FailWithMessage("更新失败", c)
 	} else {
-		response.OkWithMessage("修改成功", c)
+		response.OkWithMessage("更新成功", c)
 	}
 }
 
-// @Tags menu
+// @Tags Menu
 // @Summary 根据id获取菜单
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body request.GetById true "根据id获取菜单"
+// @Param data body request.GetById true "菜单id"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
 // @Router /menu/getBaseMenuById [post]
 func GetBaseMenuById(c *gin.Context) {
 	var idInfo request.GetById
 	_ = c.ShouldBindJSON(&idInfo)
-	MenuVerify := utils.Rules{
-		"Id": {"notEmpty"},
-	}
-	MenuVerifyErr := utils.Verify(idInfo, MenuVerify)
-	if MenuVerifyErr != nil {
-		response.FailWithMessage(MenuVerifyErr.Error(), c)
+	if err := utils.Verify(idInfo, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	err, menu := service.GetBaseMenuById(idInfo.Id)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("查询失败:%v", err), c)
+	if err, menu := service.GetBaseMenuById(idInfo.Id); err != nil {
+		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)
+	}
+}

+ 31 - 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,16 @@ 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 +73,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 +96,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)
 
-}
+}

+ 127 - 118
server/api/v1/sys_user.go

@@ -1,90 +1,50 @@
 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"
-	"mime/multipart"
+	"go.uber.org/zap"
 	"time"
 )
 
-// @Tags Base
-// @Summary 用户注册账号
-// @Produce  application/json
-// @Param data body model.SysUser true "用户注册接口"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"注册成功"}"
-// @Router /user/register [post]
-func Register(c *gin.Context) {
-	var R request.RegisterStruct
-	_ = c.ShouldBindJSON(&R)
-	UserVerify := utils.Rules{
-		"Username":    {utils.NotEmpty()},
-		"NickName":    {utils.NotEmpty()},
-		"Password":    {utils.NotEmpty()},
-		"AuthorityId": {utils.NotEmpty()},
-	}
-	UserVerifyErr := utils.Verify(R, UserVerify)
-	if UserVerifyErr != nil {
-		response.FailWithMessage(UserVerifyErr.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)
-	} else {
-		response.OkDetailed(resp.SysUserResponse{User: userReturn}, "注册成功", c)
-	}
-}
-
 // @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()},
-	}
-	UserVerifyErr := utils.Verify(L, UserVerify)
-	if 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)
 		}
 	} else {
 		response.FailWithMessage("验证码错误", c)
 	}
-
 }
 
 // 登录以后签发jwt
 func tokenNext(c *gin.Context, user model.SysUser) {
-	j := &middleware.JWT{
-		SigningKey: []byte(global.GVA_CONFIG.JWT.SigningKey), // 唯一签名
-	}
-	clams := request.CustomClaims{
+	j := &middleware.JWT{SigningKey: []byte(global.GVA_CONFIG.JWT.SigningKey)} // 唯一签名
+	claims := request.CustomClaims{
 		UUID:        user.UUID,
 		ID:          user.ID,
 		NickName:    user.NickName,
@@ -97,32 +57,34 @@ func tokenNext(c *gin.Context, user model.SysUser) {
 			Issuer:    "qmPlus",                       // 签名的发行者
 		},
 	}
-	token, err := j.CreateToken(clams)
+	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: clams.StandardClaims.ExpiresAt * 1000,
-		}, c)
+			ExpiresAt: claims.StandardClaims.ExpiresAt * 1000,
+		}, "登录成功", 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: clams.StandardClaims.ExpiresAt * 1000,
-		}, c)
+			ExpiresAt: claims.StandardClaims.ExpiresAt * 1000,
+		}, "登录成功", 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
@@ -134,11 +96,34 @@ 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: clams.StandardClaims.ExpiresAt * 1000,
-		}, c)
+			ExpiresAt: claims.StandardClaims.ExpiresAt * 1000,
+		}, "登录成功", c)
+	}
+}
+
+// @Tags SysUser
+// @Summary 用户注册账号
+// @Produce  application/json
+// @Param data body model.SysUser true "用户名, 昵称, 密码, 角色ID"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"注册成功"}"
+// @Router /user/register [post]
+func Register(c *gin.Context) {
+	var R request.Register
+	_ = c.ShouldBindJSON(&R)
+	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 {
+		global.GVA_LOG.Error("注册失败", zap.Any("err", err))
+		response.FailWithDetailed(response.SysUserResponse{User: userReturn}, "注册失败", c)
+	} else {
+		response.OkWithDetailed(response.SysUserResponse{User: userReturn}, "注册成功", c)
 	}
 }
 
@@ -146,60 +131,50 @@ func tokenNext(c *gin.Context, user model.SysUser) {
 // @Summary 用户修改密码
 // @Security ApiKeyAuth
 // @Produce  application/json
-// @Param data body request.ChangePasswordStruct true "用户修改密码"
+// @Param data body request.ChangePasswordStruct true "用户名, 原密码, 新密码"
 // @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()},
-	}
-	UserVerifyErr := utils.Verify(params, UserVerify)
-	if 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 {
-		response.FailWithMessage("修改失败,请检查用户名密码", c)
+	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)
 	}
 }
 
-type UserHeaderImg struct {
-	HeaderImg multipart.File `json:"headerImg"`
-}
-
 // @Tags SysUser
 // @Summary 分页获取用户列表
 // @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 /user/getUserList [post]
 func GetUserList(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.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)
 	}
 }
 
@@ -208,24 +183,19 @@ func GetUserList(c *gin.Context) {
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body request.SetUserAuth true "设置用户权限"
+// @Param data body request.SetUserAuth true "用户UUID, 角色ID"
 // @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
 // @Router /user/setUserAuthority [post]
 func SetUserAuthority(c *gin.Context) {
 	var sua request.SetUserAuth
 	_ = c.ShouldBindJSON(&sua)
-	UserVerify := utils.Rules{
-		"UUID":        {utils.NotEmpty()},
-		"AuthorityId": {utils.NotEmpty()},
-	}
-	UserVerifyErr := utils.Verify(sua, UserVerify)
-	if 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)
 	}
@@ -236,42 +206,81 @@ func SetUserAuthority(c *gin.Context) {
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body request.GetById true "删除用户"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
+// @Param data body request.GetById true "用户ID"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
 // @Router /user/deleteUser [delete]
 func DeleteUser(c *gin.Context) {
 	var reqId request.GetById
 	_ = c.ShouldBindJSON(&reqId)
-	IdVerifyErr := utils.Verify(reqId, utils.CustomizeMap["IdVerify"])
-	if 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)
+	jwtId := getUserID(c)
+	if jwtId == uint(reqId.Id) {
+		response.FailWithMessage("删除失败, 自杀失败", c)
+		return
+	}
+	if err := service.DeleteUser(reqId.Id); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
+		response.FailWithMessage("删除失败", c)
 	} else {
 		response.OkWithMessage("删除成功", c)
 	}
 }
 
 // @Tags SysUser
-// @Summary 删除用户
+// @Summary 设置用户信息
 // @Security ApiKeyAuth
 // @accept application/json
 // @Produce application/json
-// @Param data body model.SysUser true "删除用户"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
+// @Param data body model.SysUser true "ID, 用户名, 昵称, 头像链接"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}"
 // @Router /user/setUserInfo [put]
 func SetUserInfo(c *gin.Context) {
 	var user model.SysUser
-	c.ShouldBindJSON(&user)
-	err, ReqUser := service.SetUserInfo(user)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c)
+	_ = c.ShouldBindJSON(&user)
+	if err := utils.Verify(user, utils.SetUserVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	if err, ReqUser := service.SetUserInfo(user); err != nil {
+		global.GVA_LOG.Error("设置失败", zap.Any("err", err))
+		response.FailWithMessage("设置失败", c)
+	} else {
+		response.OkWithDetailed(gin.H{"userInfo": ReqUser}, "设置成功", c)
+	}
+}
+
+// 从Gin的Context中获取从jwt解析出来的用户ID
+func getUserID(c *gin.Context) uint {
+	if claims, exists := c.Get("claims"); !exists {
+		global.GVA_LOG.Error("从Gin的Context中获取从jwt解析出来的用户ID失败, 请检查路由是否使用jwt中间件")
+		return 0
+	} else {
+		waitUse := claims.(*request.CustomClaims)
+		return waitUse.ID
+	}
+}
+
+// 从Gin的Context中获取从jwt解析出来的用户UUID
+func getUserUuid(c *gin.Context) string {
+	if claims, exists := c.Get("claims"); !exists {
+		global.GVA_LOG.Error("从Gin的Context中获取从jwt解析出来的用户UUID失败, 请检查路由是否使用jwt中间件")
+		return ""
+	} else {
+		waitUse := claims.(*request.CustomClaims)
+		return waitUse.UUID.String()
+	}
+}
+
+// 从Gin的Context中获取从jwt解析出来的用户角色id
+func getUserAuthorityId(c *gin.Context) string {
+	if claims, exists := c.Get("claims"); !exists {
+		global.GVA_LOG.Error("从Gin的Context中获取从jwt解析出来的用户UUID失败, 请检查路由是否使用jwt中间件")
+		return ""
 	} else {
-		response.OkWithData(gin.H{
-			"userInfo": ReqUser,
-		}, c)
+		waitUse := claims.(*request.CustomClaims)
+		return waitUse.AuthorityId
 	}
 }

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

+ 3 - 2
server/cmd/datas/AuthorityMenu.go

@@ -5,9 +5,10 @@ import (
 	"gorm.io/gorm"
 )
 
-func InitAuthorityMenu(db *gorm.DB) (err error) {
+func InitAuthorityMenu(db *gorm.DB) {
 	if err := db.Exec("CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `authority_menu` AS select `sys_base_menus`.`id` AS `id`,`sys_base_menus`.`created_at` AS `created_at`, `sys_base_menus`.`updated_at` AS `updated_at`, `sys_base_menus`.`deleted_at` AS `deleted_at`, `sys_base_menus`.`menu_level` AS `menu_level`,`sys_base_menus`.`parent_id` AS `parent_id`,`sys_base_menus`.`path` AS `path`,`sys_base_menus`.`name` AS `name`,`sys_base_menus`.`hidden` AS `hidden`,`sys_base_menus`.`component` AS `component`, `sys_base_menus`.`title`  AS `title`,`sys_base_menus`.`icon` AS `icon`,`sys_base_menus`.`sort` AS `sort`,`sys_authority_menus`.`sys_authority_authority_id` AS `authority_id`,`sys_authority_menus`.`sys_base_menu_id` AS `menu_id`,`sys_base_menus`.`keep_alive` AS `keep_alive`,`sys_base_menus`.`default_menu` AS `default_menu` from (`sys_authority_menus` join `sys_base_menus` on ((`sys_authority_menus`.`sys_base_menu_id` = `sys_base_menus`.`id`)))").Error; err != nil {
 		color.Danger.Println("authority_menu视图已存在!")
+		return
 	}
-	return nil
+	color.Info.Println("authority_menu视图创建成功!")
 }

+ 8 - 4
server/cmd/datas/apis.go

@@ -4,6 +4,7 @@ import (
 	"gin-vue-admin/global"
 	"gin-vue-admin/model"
 	"github.com/gookit/color"
+	"os"
 	"time"
 
 	"gorm.io/gorm"
@@ -68,7 +69,7 @@ var Apis = []model.SysApi{
 	{global.GVA_MODEL{ID: 57, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/getSysOperationRecordList", "获取操作记录列表", "sysOperationRecord", "GET"},
 	{global.GVA_MODEL{ID: 58, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getTables", "获取数据库表", "autoCode", "GET"},
 	{global.GVA_MODEL{ID: 59, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getDB", "获取所有数据库", "autoCode", "GET"},
-	{global.GVA_MODEL{ID: 60, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getColume", "获取所选table的所有字段", "autoCode", "GET"},
+	{global.GVA_MODEL{ID: 60, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getColumn", "获取所选table的所有字段", "autoCode", "GET"},
 	{global.GVA_MODEL{ID: 61, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/deleteSysOperationRecordByIds", "批量删除操作历史", "sysOperationRecord", "DELETE"},
 	{global.GVA_MODEL{ID: 62, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/upload", "插件版分片上传", "simpleUploader", "POST"},
 	{global.GVA_MODEL{ID: 63, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/checkFileMd5", "文件完整度验证", "simpleUploader", "GET"},
@@ -78,8 +79,8 @@ var Apis = []model.SysApi{
 	{global.GVA_MODEL{ID: 67, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/email/emailTest", "发送测试邮件", "email", "POST"},
 }
 
-func InitSysApi(db *gorm.DB) (err error) {
-	return db.Transaction(func(tx *gorm.DB) error {
+func InitSysApi(db *gorm.DB) {
+	if err := db.Transaction(func(tx *gorm.DB) error {
 		if tx.Where("id IN ?", []int{1, 67}).Find(&[]model.SysApi{}).RowsAffected == 2 {
 			color.Danger.Println("sys_apis表的初始数据已存在!")
 			return nil
@@ -88,5 +89,8 @@ func InitSysApi(db *gorm.DB) (err error) {
 			return err
 		}
 		return nil
-	})
+	}); err != nil {
+		color.Warn.Printf("[Mysql]--> sys_apis 表的初始数据失败,err: %v\n", err)
+		os.Exit(0)
+	}
 }

+ 7 - 3
server/cmd/datas/authorities.go

@@ -2,6 +2,7 @@ package datas
 
 import (
 	"github.com/gookit/color"
+	"os"
 	"time"
 
 	"gin-vue-admin/model"
@@ -14,8 +15,8 @@ var Authorities = []model.SysAuthority{
 	{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "9528", AuthorityName: "测试角色", ParentId: "0"},
 }
 
-func InitSysAuthority(db *gorm.DB) (err error) {
-	return db.Transaction(func(tx *gorm.DB) error {
+func InitSysAuthority(db *gorm.DB) {
+	if err := db.Transaction(func(tx *gorm.DB) error {
 		if tx.Where("authority_id IN ? ", []string{"888", "9528"}).Find(&[]model.SysAuthority{}).RowsAffected == 2 {
 			color.Danger.Println("sys_authorities表的初始数据已存在!")
 			return nil
@@ -24,5 +25,8 @@ func InitSysAuthority(db *gorm.DB) (err error) {
 			return err
 		}
 		return nil
-	})
+	}); err != nil {
+		color.Warn.Printf("[Mysql]--> sys_authorities 表的初始数据失败,err: %v\n", err)
+		os.Exit(0)
+	}
 }

+ 7 - 3
server/cmd/datas/authority_Ids.go

@@ -3,6 +3,7 @@ package datas
 import (
 	"github.com/gookit/color"
 	"gorm.io/gorm"
+	"os"
 )
 
 type SysDataAuthorityId struct {
@@ -18,8 +19,8 @@ var DataAuthorityId = []SysDataAuthorityId{
 	{"9528", "9528"},
 }
 
-func InitSysDataAuthorityId(db *gorm.DB) (err error) {
-	return db.Table("sys_data_authority_id").Transaction(func(tx *gorm.DB) error {
+func InitSysDataAuthorityId(db *gorm.DB) {
+	if err := db.Table("sys_data_authority_id").Transaction(func(tx *gorm.DB) error {
 		if tx.Where("sys_authority_authority_id IN ?", []string{"888", "9528"}).Find(&[]SysDataAuthorityId{}).RowsAffected == 5 {
 			color.Danger.Println("sys_data_authority_id表的初始数据已存在!")
 			return nil
@@ -28,5 +29,8 @@ func InitSysDataAuthorityId(db *gorm.DB) (err error) {
 			return err
 		}
 		return nil
-	})
+	}); err != nil {
+		color.Warn.Printf("[Mysql]--> sys_data_authority_id 表的初始数据失败,err: %v\n", err)
+		os.Exit(0)
+	}
 }

+ 7 - 3
server/cmd/datas/authority_menus.go

@@ -3,6 +3,7 @@ package datas
 import (
 	"github.com/gookit/color"
 	"gorm.io/gorm"
+	"os"
 )
 
 type SysAuthorityMenus struct {
@@ -66,8 +67,8 @@ var AuthorityMenus = []SysAuthorityMenus{
 	{"9528", 20},
 }
 
-func InitSysAuthorityMenus(db *gorm.DB) (err error) {
-	return db.Table("sys_authority_menus").Transaction(func(tx *gorm.DB) error {
+func InitSysAuthorityMenus(db *gorm.DB) {
+	if err := db.Table("sys_authority_menus").Transaction(func(tx *gorm.DB) error {
 		if tx.Where("sys_authority_authority_id IN ?", []string{"888", "8881", "9528"}).Find(&[]SysAuthorityMenus{}).RowsAffected == 53 {
 			color.Danger.Println("sys_authority_menus表的初始数据已存在!")
 			return nil
@@ -76,5 +77,8 @@ func InitSysAuthorityMenus(db *gorm.DB) (err error) {
 			return err
 		}
 		return nil
-	})
+	}); err != nil {
+		color.Warn.Printf("[Mysql]--> sys_authority_menus 表的初始数据失败,err: %v\n", err)
+		os.Exit(0)
+	}
 }

+ 8 - 4
server/cmd/datas/casbins.go

@@ -4,6 +4,7 @@ import (
 	gormadapter "github.com/casbin/gorm-adapter/v3"
 	"github.com/gookit/color"
 	"gorm.io/gorm"
+	"os"
 )
 
 var Carbines = []gormadapter.CasbinRule{
@@ -52,7 +53,7 @@ var Carbines = []gormadapter.CasbinRule{
 	{PType: "p", V0: "888", V1: "/autoCode/createTemp", V2: "POST"},
 	{PType: "p", V0: "888", V1: "/autoCode/getTables", V2: "GET"},
 	{PType: "p", V0: "888", V1: "/autoCode/getDB", V2: "GET"},
-	{PType: "p", V0: "888", V1: "/autoCode/getColume", V2: "GET"},
+	{PType: "p", V0: "888", V1: "/autoCode/getColumn", V2: "GET"},
 	{PType: "p", V0: "888", V1: "/sysDictionaryDetail/createSysDictionaryDetail", V2: "POST"},
 	{PType: "p", V0: "888", V1: "/sysDictionaryDetail/deleteSysDictionaryDetail", V2: "DELETE"},
 	{PType: "p", V0: "888", V1: "/sysDictionaryDetail/updateSysDictionaryDetail", V2: "PUT"},
@@ -151,8 +152,8 @@ var Carbines = []gormadapter.CasbinRule{
 	{PType: "p", V0: "9528", V1: "/autoCode/createTemp", V2: "POST"},
 }
 
-func InitCasbinModel(db *gorm.DB) (err error) {
-	return db.Transaction(func(tx *gorm.DB) error {
+func InitCasbinModel(db *gorm.DB) {
+	if err := db.Transaction(func(tx *gorm.DB) error {
 		if tx.Where("p_type = ? AND v0 IN ?", "p", []string{"888", "8881", "9528"}).Find(&[]gormadapter.CasbinRule{}).RowsAffected == 142 {
 			color.Danger.Println("casbin_rule表的初始数据已存在!")
 			return nil
@@ -161,5 +162,8 @@ func InitCasbinModel(db *gorm.DB) (err error) {
 			return err
 		}
 		return nil
-	})
+	}); err != nil {
+		color.Warn.Printf("[Mysql]--> casbin_rule 表的初始数据失败,err: %v\n", err)
+		os.Exit(0)
+	}
 }

+ 7 - 3
server/cmd/datas/customers.go

@@ -3,6 +3,7 @@ package datas
 import (
 	"gin-vue-admin/global"
 	"github.com/gookit/color"
+	"os"
 	"time"
 
 	"gin-vue-admin/model"
@@ -13,8 +14,8 @@ var Customers = []model.ExaCustomer{
 	{GVA_MODEL: global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, CustomerName: "测试客户", CustomerPhoneData: "1761111111", SysUserID: 1, SysUserAuthorityID: "888"},
 }
 
-func InitExaCustomer(db *gorm.DB) (err error) {
-	return db.Transaction(func(tx *gorm.DB) error {
+func InitExaCustomer(db *gorm.DB) {
+	if err := db.Transaction(func(tx *gorm.DB) error {
 		if tx.Where("id IN ? ", []int{1}).Find(&[]model.ExaCustomer{}).RowsAffected == 1 {
 			color.Danger.Println("exa_customers表的初始数据已存在!")
 			return nil
@@ -23,5 +24,8 @@ func InitExaCustomer(db *gorm.DB) (err error) {
 			return err
 		}
 		return nil
-	})
+	}); err != nil {
+		color.Warn.Printf("[Mysql]--> exa_customers 表的初始数据失败,err: %v\n", err)
+		os.Exit(0)
+	}
 }

+ 7 - 3
server/cmd/datas/dictionaries.go

@@ -3,13 +3,14 @@ package datas
 import (
 	"gin-vue-admin/global"
 	"github.com/gookit/color"
+	"os"
 	"time"
 
 	"gin-vue-admin/model"
 	"gorm.io/gorm"
 )
 
-func InitSysDictionary(db *gorm.DB) (err error) {
+func InitSysDictionary(db *gorm.DB) {
 	var status = new(bool)
 	*status = true
 	Dictionaries := []model.SysDictionary{
@@ -20,7 +21,7 @@ func InitSysDictionary(db *gorm.DB) (err error) {
 		{GVA_MODEL: global.GVA_MODEL{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库字符串", Type: "string", Status: status, Desc: "数据库字符串"},
 		{GVA_MODEL: global.GVA_MODEL{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库bool类型", Type: "bool", Status: status, Desc: "数据库bool类型"},
 	}
-	return db.Transaction(func(tx *gorm.DB) error {
+	if err := db.Transaction(func(tx *gorm.DB) error {
 		if tx.Where("id IN ?", []int{1, 6}).Find(&[]model.SysDictionary{}).RowsAffected == 2 {
 			color.Danger.Println("sys_dictionaries表的初始数据已存在!")
 			return nil
@@ -29,5 +30,8 @@ func InitSysDictionary(db *gorm.DB) (err error) {
 			return err
 		}
 		return nil
-	})
+	}); err != nil {
+		color.Warn.Printf("[Mysql]--> sys_dictionaries 表的初始数据失败,err: %v\n", err)
+		os.Exit(0)
+	}
 }

+ 7 - 3
server/cmd/datas/dictionary_details.go

@@ -3,13 +3,14 @@ package datas
 import (
 	"gin-vue-admin/global"
 	"github.com/gookit/color"
+	"os"
 	"time"
 
 	"gin-vue-admin/model"
 	"gorm.io/gorm"
 )
 
-func InitSysDictionaryDetail(db *gorm.DB) (err error) {
+func InitSysDictionaryDetail(db *gorm.DB) {
 	status := new(bool)
 	*status = true
 	DictionaryDetail := []model.SysDictionaryDetail{
@@ -37,7 +38,7 @@ func InitSysDictionaryDetail(db *gorm.DB) (err error) {
 		{global.GVA_MODEL{ID: 22, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "longtext", 9, status, 9, 5},
 		{global.GVA_MODEL{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "tinyint", 0, status, 0, 6},
 	}
-	return db.Transaction(func(tx *gorm.DB) error {
+	if err := db.Transaction(func(tx *gorm.DB) error {
 		if tx.Where("id IN ?", []int{1, 23}).Find(&[]model.SysDictionaryDetail{}).RowsAffected == 2 {
 			color.Danger.Println("sys_dictionary_details表的初始数据已存在!")
 			return nil
@@ -46,5 +47,8 @@ func InitSysDictionaryDetail(db *gorm.DB) (err error) {
 			return err
 		}
 		return nil
-	})
+	}); err != nil {
+		color.Warn.Printf("[Mysql]--> sys_dictionary_details 表的初始数据失败,err: %v\n", err)
+		os.Exit(0)
+	}
 }

+ 8 - 3
server/cmd/datas/files.go

@@ -3,6 +3,7 @@ package datas
 import (
 	"gin-vue-admin/global"
 	"github.com/gookit/color"
+	"os"
 	"time"
 
 	"gin-vue-admin/model"
@@ -14,8 +15,8 @@ var Files = []model.ExaFileUploadAndDownload{
 	{global.GVA_MODEL{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "logo.png", "http://qmplusimg.henrongyi.top/1576554439myAvatar.png", "png", "1587973709logo.png"},
 }
 
-func InitExaFileUploadAndDownload(db *gorm.DB) (err error) {
-	return db.Transaction(func(tx *gorm.DB) error {
+func InitExaFileUploadAndDownload(db *gorm.DB) {
+	if err := db.Transaction(func(tx *gorm.DB) error {
 		if tx.Where("id IN ?", []int{1, 2}).Find(&[]model.ExaFileUploadAndDownload{}).RowsAffected == 2 {
 			color.Danger.Println("exa_file_upload_and_downloads表的初始数据已存在!")
 			return nil
@@ -23,6 +24,10 @@ func InitExaFileUploadAndDownload(db *gorm.DB) (err error) {
 		if err := tx.Create(&Files).Error; err != nil { // 遇到错误时回滚事务
 			return err
 		}
+		color.Info.Println("[Mysql]-->初始化数据成功")
 		return nil
-	})
+	}); err != nil {
+		color.Warn.Printf("[Mysql]--> exa_file_upload_and_downloads 表的初始数据失败,err: %v\n", err)
+		os.Exit(0)
+	}
 }

+ 12 - 18
server/cmd/datas/init.go

@@ -9,24 +9,18 @@ import (
 )
 
 func InitMysqlData(db *gorm.DB) {
-	var err error
-	err = InitSysApi(db)
-	err = InitSysUser(db)
-	err = InitExaCustomer(db)
-	err = InitCasbinModel(db)
-	err = InitSysAuthority(db)
-	err = InitSysBaseMenus(db)
-	err = InitAuthorityMenu(db)
-	err = InitSysDictionary(db)
-	err = InitSysAuthorityMenus(db)
-	err = InitSysDataAuthorityId(db)
-	err = InitSysDictionaryDetail(db)
-	err = InitExaFileUploadAndDownload(db)
-	if err != nil {
-		color.Warn.Printf("[Mysql]-->初始化数据失败,err: %v\n", err)
-		os.Exit(0)
-	}
-	color.Info.Println("[Mysql]-->初始化数据成功")
+	InitSysApi(db)
+	InitSysUser(db)
+	InitExaCustomer(db)
+	InitCasbinModel(db)
+	InitSysAuthority(db)
+	InitSysBaseMenus(db)
+	InitAuthorityMenu(db)
+	InitSysDictionary(db)
+	InitSysAuthorityMenus(db)
+	InitSysDataAuthorityId(db)
+	InitSysDictionaryDetail(db)
+	InitExaFileUploadAndDownload(db)
 }
 
 func InitMysqlTables(db *gorm.DB) {

+ 7 - 3
server/cmd/datas/menus.go

@@ -3,6 +3,7 @@ package datas
 import (
 	"gin-vue-admin/global"
 	"github.com/gookit/color"
+	"os"
 	"time"
 
 	"gin-vue-admin/model"
@@ -39,8 +40,8 @@ var BaseMenus = []model.SysBaseMenu{
 	{GVA_MODEL: global.GVA_MODEL{ID: 27, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "state", Name: "state", Hidden: false, Component: "view/system/state.vue", Sort: 6, Meta: model.Meta{Title: "服务器状态", Icon: "cloudy"}},
 }
 
-func InitSysBaseMenus(db *gorm.DB) (err error) {
-	return db.Transaction(func(tx *gorm.DB) error {
+func InitSysBaseMenus(db *gorm.DB) {
+	if err := db.Transaction(func(tx *gorm.DB) error {
 		if tx.Where("id IN ?", []int{1, 27}).Find(&[]model.SysBaseMenu{}).RowsAffected == 2 {
 			color.Danger.Println("sys_base_menus表的初始数据已存在!")
 			return nil
@@ -49,5 +50,8 @@ func InitSysBaseMenus(db *gorm.DB) (err error) {
 			return err
 		}
 		return nil
-	})
+	}); err != nil {
+		color.Warn.Printf("[Mysql]--> sys_base_menus 表的初始数据失败,err: %v\n", err)
+		os.Exit(0)
+	}
 }

+ 8 - 4
server/cmd/datas/users.go

@@ -3,6 +3,7 @@ package datas
 import (
 	"gin-vue-admin/global"
 	"github.com/gookit/color"
+	"os"
 	"time"
 
 	"gin-vue-admin/model"
@@ -11,12 +12,12 @@ import (
 )
 
 var Users = []model.SysUser{
-	{GVA_MODEL: global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "admin", Password: "e10adc3949ba59abbe56e057f20f883e", NickName: "超级管理员", HeaderImg: "http://qmplusimg.henrongyi.top/1571627762timg.jpg", AuthorityId: "888"},
+	{GVA_MODEL: global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "admin", Password: "e10adc3949ba59abbe56e057f20f883e", NickName: "超级管理员", HeaderImg: "http://qmplusimg.henrongyi.top/gva_header.jpg", AuthorityId: "888"},
 	{GVA_MODEL: global.GVA_MODEL{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "a303176530", Password: "3ec063004a6f31642261936a379fde3d", NickName: "QMPlusUser", HeaderImg: "http://qmplusimg.henrongyi.top/1572075907logo.png", AuthorityId: "9528"},
 }
 
-func InitSysUser(db *gorm.DB) (err error) {
-	return db.Transaction(func(tx *gorm.DB) error {
+func InitSysUser(db *gorm.DB) {
+	if err := db.Transaction(func(tx *gorm.DB) error {
 		if tx.Where("id IN ?", []int{1, 2}).Find(&[]model.SysUser{}).RowsAffected == 2 {
 			color.Danger.Println("sys_users表的初始数据已存在!")
 			return nil
@@ -25,5 +26,8 @@ func InitSysUser(db *gorm.DB) (err error) {
 			return err
 		}
 		return nil
-	})
+	}); err != nil {
+		color.Warn.Printf("[Mysql]--> sys_users 表的初始数据失败,err: %v\n", err)
+		os.Exit(0)
+	}
 }

+ 53 - 0
server/cmd/gva/run.go

@@ -0,0 +1,53 @@
+/*
+Copyright © 2020 NAME HERE <EMAIL ADDRESS>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+package gva
+
+import (
+	"gin-vue-admin/utils"
+	"github.com/spf13/cobra"
+	"os"
+)
+
+// runCmd represents the run command
+var runCmd = &cobra.Command{
+	Use:   "run",
+	Short: "running go codes with hot-compiled-like feature",
+	Long: `
+	The "run" command is used for running go codes with hot-compiled-like feature,     
+	which compiles and runs the go codes asynchronously when codes change.
+`,
+	Run: func(cmd *cobra.Command, args []string) {
+		w := utils.NewWatch()
+		t := utils.NewT()
+		path, _ := os.Getwd()
+		go w.Watch(path, t)
+		t.RunTask()
+	},
+}
+
+func init() {
+	rootCmd.AddCommand(runCmd)
+
+	// Here you will define your flags and configuration settings.
+
+	// Cobra supports Persistent Flags which will work for this command
+	// and all subcommands, e.g.:
+	// runCmd.PersistentFlags().String("foo", "", "A help for foo")
+
+	// Cobra supports local flags which will only run when this command
+	// is called directly, e.g.:
+	// runCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
+}

+ 2 - 2
server/config.yaml

@@ -58,14 +58,14 @@ mysql:
   username: 'root'
   password: 'Aa@6447985'
   max-idle-conns: 10
-  max-open-conns: 10
+  max-open-conns: 100
   log-mode: false
 
 # local configuration
 local:
   path: 'uploads/file'
 
-# qiniu configuration (请自行七牛申请对应的 公钥 私钥 bucket 域名地址)
+# qiniu configuration (请自行七牛申请对应的 公钥 私钥 bucket �?域名地址)
 qiniu:
   zone: 'ZoneHuadong'
   bucket: 'qm-plus-img'

+ 2 - 1
server/core/server.go

@@ -29,9 +29,10 @@ func RunWindowsServer() {
 
 	fmt.Printf(`
 	欢迎使用 Gin-Vue-Admin
-	当前版本:V2.3.4
+	当前版本:V2.3.7
 	默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
 	默认前端文件运行地址:http://127.0.0.1:8080
+	如果项目让您获得了收益,希望您能请团队喝杯可乐:https://www.gin-vue-admin.com/docs/coffee
 `, address)
 	global.GVA_LOG.Error(s.ListenAndServe().Error())
 }

+ 1 - 1
server/core/zap.go

@@ -43,7 +43,7 @@ func Zap() (logger *zap.Logger) {
 		logger = zap.New(getEncoderCore())
 	}
 	if global.GVA_CONFIG.Zap.ShowLine {
-		logger.WithOptions(zap.AddCaller())
+		logger = logger.WithOptions(zap.AddCaller())
 	}
 	return logger
 }

File diff suppressed because it is too large
+ 177 - 135
server/docs/docs.go


File diff suppressed because it is too large
+ 177 - 134
server/docs/swagger.json


File diff suppressed because it is too large
+ 201 - 188
server/docs/swagger.yaml


+ 4 - 2
server/go.mod

@@ -1,6 +1,6 @@
 module gin-vue-admin
 
-go 1.12
+go 1.14
 
 require (
 	github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
@@ -33,7 +33,7 @@ require (
 	github.com/onsi/ginkgo v1.7.0 // indirect
 	github.com/onsi/gomega v1.4.3 // indirect
 	github.com/pelletier/go-toml v1.6.0 // indirect
-	github.com/pkg/errors v0.9.1 // indirect
+	github.com/pkg/errors v0.9.1
 	github.com/qiniu/api.v7/v7 v7.4.1
 	github.com/satori/go.uuid v1.2.0
 	github.com/shirou/gopsutil v2.20.8+incompatible
@@ -56,3 +56,5 @@ require (
 	gorm.io/driver/mysql v0.3.0
 	gorm.io/gorm v1.20.5
 )
+
+replace github.com/casbin/gorm-adapter/v3 => github.com/casbin/gorm-adapter/v3 v3.0.2

+ 24 - 19
server/initialize/router.go

@@ -24,25 +24,30 @@ func Routers() *gin.Engine {
 	Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
 	global.GVA_LOG.Info("register swagger handler")
 	// 方便统一添加路由组前缀 多服务器上线使用
-	ApiGroup := Router.Group("")
-	router.InitUserRouter(ApiGroup)                  // 注册用户路由
-	router.InitBaseRouter(ApiGroup)                  // 注册基础功能路由 不做鉴权
-	router.InitMenuRouter(ApiGroup)                  // 注册menu路由
-	router.InitAuthorityRouter(ApiGroup)             // 注册角色路由
-	router.InitApiRouter(ApiGroup)                   // 注册功能api路由
-	router.InitFileUploadAndDownloadRouter(ApiGroup) // 文件上传下载功能路由
-	router.InitSimpleUploaderRouter(ApiGroup)        // 断点续传(插件版)
-	router.InitWorkflowRouter(ApiGroup)              // 工作流相关路由
-	router.InitCasbinRouter(ApiGroup)                // 权限相关路由
-	router.InitJwtRouter(ApiGroup)                   // jwt相关路由
-	router.InitSystemRouter(ApiGroup)                // system相关路由
-	router.InitCustomerRouter(ApiGroup)              // 客户路由
-	router.InitAutoCodeRouter(ApiGroup)              // 创建自动化代码
-	router.InitSysDictionaryDetailRouter(ApiGroup)   // 字典详情管理
-	router.InitSysDictionaryRouter(ApiGroup)         // 字典管理
-	router.InitSysOperationRecordRouter(ApiGroup)    // 操作记录
-	router.InitEmailRouter(ApiGroup)                 // 邮件相关路由
-
+	PublicGroup := Router.Group("")
+	{
+		router.InitBaseRouter(PublicGroup) // 注册基础功能路由 不做鉴权
+	}
+	PrivateGroup := Router.Group("")
+	PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
+	{
+		router.InitApiRouter(PrivateGroup)                   // 注册功能api路由
+		router.InitJwtRouter(PrivateGroup)                   // jwt相关路由
+		router.InitUserRouter(PrivateGroup)                  // 注册用户路由
+		router.InitMenuRouter(PrivateGroup)                  // 注册menu路由
+		router.InitEmailRouter(PrivateGroup)                 // 邮件相关路由
+		router.InitSystemRouter(PrivateGroup)                // system相关路由
+		router.InitCasbinRouter(PrivateGroup)                // 权限相关路由
+		router.InitWorkflowRouter(PrivateGroup)              // 工作流相关路由
+		router.InitCustomerRouter(PrivateGroup)              // 客户路由
+		router.InitAutoCodeRouter(PrivateGroup)              // 创建自动化代码
+		router.InitAuthorityRouter(PrivateGroup)             // 注册角色路由
+		router.InitSimpleUploaderRouter(PrivateGroup)        // 断点续传(插件版)
+		router.InitSysDictionaryRouter(PrivateGroup)         // 字典管理
+		router.InitSysOperationRecordRouter(PrivateGroup)    // 操作记录
+		router.InitSysDictionaryDetailRouter(PrivateGroup)   // 字典详情管理
+		router.InitFileUploadAndDownloadRouter(PrivateGroup) // 文件上传下载功能路由
+	}
 	global.GVA_LOG.Info("router register success")
 	return Router
 }

+ 2 - 2
server/middleware/casbin_rbac.go

@@ -2,8 +2,8 @@ package middleware
 
 import (
 	"gin-vue-admin/global"
-	"gin-vue-admin/global/response"
 	"gin-vue-admin/model/request"
+	"gin-vue-admin/model/response"
 	"gin-vue-admin/service"
 	"github.com/gin-gonic/gin"
 )
@@ -25,7 +25,7 @@ func CasbinHandler() gin.HandlerFunc {
 		if global.GVA_CONFIG.System.Env == "develop" || success {
 			c.Next()
 		} else {
-			response.Result(response.ERROR, gin.H{}, "权限不足", c)
+			response.FailWithDetailed(gin.H{}, "权限不足", c)
 			c.Abort()
 			return
 		}

+ 18 - 28
server/middleware/jwt.go

@@ -3,9 +3,9 @@ package middleware
 import (
 	"errors"
 	"gin-vue-admin/global"
-	"gin-vue-admin/global/response"
 	"gin-vue-admin/model"
 	"gin-vue-admin/model/request"
+	"gin-vue-admin/model/response"
 	"gin-vue-admin/service"
 	"github.com/dgrijalva/jwt-go"
 	"github.com/gin-gonic/gin"
@@ -19,16 +19,12 @@ func JWTAuth() gin.HandlerFunc {
 		// 我们这里jwt鉴权取头部信息 x-token 登录时回返回token信息 这里前端需要把token存储到cookie或者本地localStorage中 不过需要跟后端协商过期时间 可以约定刷新令牌或者重新登录
 		token := c.Request.Header.Get("x-token")
 		if token == "" {
-			response.Result(response.ERROR, gin.H{
-				"reload": true,
-			}, "未登录或非法访问", c)
+			response.FailWithDetailed(gin.H{"reload": true}, "未登录或非法访问", c)
 			c.Abort()
 			return
 		}
 		if service.IsBlacklist(token) {
-			response.Result(response.ERROR, gin.H{
-				"reload": true,
-			}, "您的帐户异地登陆或令牌失效", c)
+			response.FailWithDetailed(gin.H{"reload": true}, "您的帐户异地登陆或令牌失效", c)
 			c.Abort()
 			return
 		}
@@ -37,40 +33,34 @@ func JWTAuth() gin.HandlerFunc {
 		claims, err := j.ParseToken(token)
 		if err != nil {
 			if err == TokenExpired {
-				response.Result(response.ERROR, gin.H{
-					"reload": true,
-				}, "授权已过期", c)
+				response.FailWithDetailed(gin.H{"reload": true}, "授权已过期", c)
 				c.Abort()
 				return
 			}
-			response.Result(response.ERROR, gin.H{
-				"reload": true,
-			}, err.Error(), c)
+			response.FailWithDetailed(gin.H{"reload": true}, err.Error(), c)
 			c.Abort()
 			return
 		}
-		if err, _ = service.FindUserByUuid(claims.UUID.String()); err != nil{
-			response.Result(response.ERROR, gin.H{
-				"reload": true,
-			}, err.Error(), c)
+		if err, _ = service.FindUserByUuid(claims.UUID.String()); err != nil {
+			_ = service.JsonInBlacklist(model.JwtBlacklist{Jwt: token})
+			response.FailWithDetailed(gin.H{"reload": true}, err.Error(), c)
 			c.Abort()
 		}
-		if claims.ExpiresAt - time.Now().Unix()<claims.BufferTime {
+		if claims.ExpiresAt-time.Now().Unix() < claims.BufferTime {
 			claims.ExpiresAt = time.Now().Unix() + 60*60*24*7
-			newToken,_ := j.CreateToken(*claims)
-			newClaims,_ := j.ParseToken(newToken)
-			c.Header("new-token",newToken)
-			c.Header("new-expires-at",strconv.FormatInt(newClaims.ExpiresAt,10))
+			newToken, _ := j.CreateToken(*claims)
+			newClaims, _ := j.ParseToken(newToken)
+			c.Header("new-token", newToken)
+			c.Header("new-expires-at", strconv.FormatInt(newClaims.ExpiresAt, 10))
 			if global.GVA_CONFIG.System.UseMultipoint {
-				err,RedisJwtToken := service.GetRedisJWT(newClaims.Username)
-				if err!=nil {
-					global.GVA_LOG.Error("get redis jwt failed",  zap.Any("err", err))
-				}else{
+				err, RedisJwtToken := service.GetRedisJWT(newClaims.Username)
+				if err != nil {
+					global.GVA_LOG.Error("get redis jwt failed", zap.Any("err", err))
+				} else { // 当之前的取成功时才进行拉黑操作
 					_ = service.JsonInBlacklist(model.JwtBlacklist{Jwt: RedisJwtToken})
-					//当之前的取成功时才进行拉黑操作
 				}
 				// 无论如何都要记录当前的活跃状态
-				_ = service.SetRedisJWT(newToken,newClaims.Username)
+				_ = service.SetRedisJWT(newToken, newClaims.Username)
 			}
 		}
 		c.Set("claims", claims)

+ 6 - 6
server/middleware/operation.go

@@ -11,7 +11,6 @@ import (
 	"io/ioutil"
 	"net/http"
 	"strconv"
-	"strings"
 	"time"
 )
 
@@ -31,7 +30,7 @@ func OperationRecord() gin.HandlerFunc {
 		if claims, ok := c.Get("claims"); ok {
 			waitUse := claims.(*request.CustomClaims)
 			userId = int(waitUse.ID)
-		}else {
+		} else {
 			id, err := strconv.Atoi(c.Request.Header.Get("x-user-id"))
 			if err != nil {
 				userId = 0
@@ -46,10 +45,11 @@ func OperationRecord() gin.HandlerFunc {
 			Body:   string(body),
 			UserID: userId,
 		}
-		values := c.Request.Header.Values("content-type")
-		if len(values) >0 && strings.Contains(values[0], "boundary") {
-			record.Body = "file"
-		}
+		// 存在某些未知错误 TODO
+		//values := c.Request.Header.Values("content-type")
+		//if len(values) >0 && strings.Contains(values[0], "boundary") {
+		//	record.Body = "file"
+		//}
 		writer := responseBodyWriter{
 			ResponseWriter: c.Writer,
 			body:           &bytes.Buffer{},

+ 8 - 1
server/model/request/common.go

@@ -13,4 +13,11 @@ type GetById struct {
 
 type IdsReq struct {
 	Ids []int `json:"ids" form:"ids"`
-}
+}
+
+// Get role by id structure
+type GetAuthorityId struct {
+	AuthorityId string
+}
+
+type Empty struct {}

+ 6 - 6
server/model/request/sys_autocode.go

@@ -1,16 +1,16 @@
 package request
 
 type DBReq struct {
-	Database string `json:"database";gorm:"column:database"`
+	Database string `json:"database" gorm:"column:database"`
 }
 
 type TableReq struct {
 	TableName string `json:"tableName"`
 }
 
-type ColumeReq struct {
-	ColumeName    string `json:"columeName";gorm:"column:colume_name"`
-	DataType      string `json:"dataType";gorm:"column:data_type"`
-	DataTypeLong  string `json:"dataTypeLong";gorm:"column:data_type_long"`
-	ColumeComment string `json:"columeComment";gorm:"column:colume_comment"`
+type ColumnReq struct {
+	ColumnName    string `json:"columnName" gorm:"column:column_name"`
+	DataType      string `json:"dataType" gorm:"column:data_type"`
+	DataTypeLong  string `json:"dataTypeLong" gorm:"column:data_type_long"`
+	ColumnComment string `json:"columnComment" gorm:"column:column_comment"`
 }

+ 0 - 5
server/model/request/sys_menu.go

@@ -7,8 +7,3 @@ type AddMenuAuthorityInfo struct {
 	Menus       []model.SysBaseMenu
 	AuthorityId string
 }
-
-// Get role by id structure
-type AuthorityIdInfo struct {
-	AuthorityId string
-}

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

+ 5 - 0
server/model/sys_auto_code.go

@@ -1,5 +1,7 @@
 package model
 
+import "errors"
+
 // 初始版本自动化代码工具
 type AutoCodeStruct struct {
 	StructName         string  `json:"structName"`
@@ -8,6 +10,7 @@ type AutoCodeStruct struct {
 	Abbreviation       string  `json:"abbreviation"`
 	Description        string  `json:"description"`
 	AutoCreateApiToSql bool    `json:"autoCreateApiToSql"`
+	AutoMoveFile       bool    `json:"autoMoveFile"`
 	Fields             []Field `json:"fields"`
 }
 
@@ -23,3 +26,5 @@ type Field struct {
 	FieldSearchType string `json:"fieldSearchType"`
 	DictType        string `json:"dictType"`
 }
+
+var AutoMoveErr error = errors.New("创建代码成功并移动文件成功")

+ 3 - 3
server/model/sys_base_menu.go

@@ -29,7 +29,7 @@ type Meta struct {
 type SysBaseMenuParameter struct {
 	global.GVA_MODEL
 	SysBaseMenuID uint
-	Type          string `json:"type" gorm:"commit:'地址栏携带参数为params还是query'"`
-	Key           string `json:"key" gorm:"commit:'地址栏携带参数的key'"`
-	Value         string `json:"value" gorm:"commit:'地址栏携带参数的值'"`
+	Type          string `json:"type" gorm:"comment:地址栏携带参数为params还是query"`
+	Key           string `json:"key" gorm:"comment:地址栏携带参数的key"`
+	Value         string `json:"value" gorm:"comment:地址栏携带参数的值"`
 }

+ 35 - 35
server/resource/template/te/api.go.tpl → server/resource/template/server/api.go.tpl

@@ -1,13 +1,13 @@
 package v1
 
 import (
-	"fmt"
-	"gin-vue-admin/global/response"
-	"gin-vue-admin/model"
-	"gin-vue-admin/model/request"
-	resp "gin-vue-admin/model/response"
-	"gin-vue-admin/service"
-	"github.com/gin-gonic/gin"
+	"gin-vue-admin/global"
+    "gin-vue-admin/model"
+    "gin-vue-admin/model/request"
+    "gin-vue-admin/model/response"
+    "gin-vue-admin/service"
+    "github.com/gin-gonic/gin"
+    "go.uber.org/zap"
 )
 
 // @Tags {{.StructName}}
@@ -21,9 +21,9 @@ import (
 func Create{{.StructName}}(c *gin.Context) {
 	var {{.Abbreviation}} model.{{.StructName}}
 	_ = c.ShouldBindJSON(&{{.Abbreviation}})
-	err := service.Create{{.StructName}}({{.Abbreviation}})
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
+	if err := service.Create{{.StructName}}({{.Abbreviation}}); err != nil {
+        global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
+		response.FailWithMessage("创建失败", c)
 	} else {
 		response.OkWithMessage("创建成功", c)
 	}
@@ -40,9 +40,9 @@ func Create{{.StructName}}(c *gin.Context) {
 func Delete{{.StructName}}(c *gin.Context) {
 	var {{.Abbreviation}} model.{{.StructName}}
 	_ = c.ShouldBindJSON(&{{.Abbreviation}})
-	err := service.Delete{{.StructName}}({{.Abbreviation}})
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
+	if err := service.Delete{{.StructName}}({{.Abbreviation}}); err != nil {
+        global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
+		response.FailWithMessage("删除失败", c)
 	} else {
 		response.OkWithMessage("删除成功", c)
 	}
@@ -54,16 +54,16 @@ func Delete{{.StructName}}(c *gin.Context) {
 // @accept application/json
 // @Produce application/json
 // @Param data body request.IdsReq true "批量删除{{.StructName}}"
-// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
 // @Router /{{.Abbreviation}}/delete{{.StructName}}ByIds [delete]
 func Delete{{.StructName}}ByIds(c *gin.Context) {
 	var IDS request.IdsReq
     _ = c.ShouldBindJSON(&IDS)
-	err := service.Delete{{.StructName}}ByIds(IDS)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
+	if err := service.Delete{{.StructName}}ByIds(IDS); err != nil {
+        global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
+		response.FailWithMessage("批量删除失败", c)
 	} else {
-		response.OkWithMessage("删除成功", c)
+		response.OkWithMessage("批量删除成功", c)
 	}
 }
 
@@ -78,9 +78,9 @@ func Delete{{.StructName}}ByIds(c *gin.Context) {
 func Update{{.StructName}}(c *gin.Context) {
 	var {{.Abbreviation}} model.{{.StructName}}
 	_ = c.ShouldBindJSON(&{{.Abbreviation}})
-	err := service.Update{{.StructName}}(&{{.Abbreviation}})
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c)
+	if err := service.Update{{.StructName}}(&{{.Abbreviation}}); err != nil {
+        global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
+		response.FailWithMessage("更新失败", c)
 	} else {
 		response.OkWithMessage("更新成功", c)
 	}
@@ -97,9 +97,9 @@ func Update{{.StructName}}(c *gin.Context) {
 func Find{{.StructName}}(c *gin.Context) {
 	var {{.Abbreviation}} model.{{.StructName}}
 	_ = c.ShouldBindQuery(&{{.Abbreviation}})
-	err, re{{.Abbreviation}} := service.Get{{.StructName}}({{.Abbreviation}}.ID)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c)
+	if err, re{{.Abbreviation}} := service.Get{{.StructName}}({{.Abbreviation}}.ID); err != nil {
+        global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
+		response.FailWithMessage("查询失败", c)
 	} else {
 		response.OkWithData(gin.H{"re{{.Abbreviation}}": re{{.Abbreviation}}}, c)
 	}
@@ -116,15 +116,15 @@ func Find{{.StructName}}(c *gin.Context) {
 func Get{{.StructName}}List(c *gin.Context) {
 	var pageInfo request.{{.StructName}}Search
 	_ = c.ShouldBindQuery(&pageInfo)
-	err, list, total := service.Get{{.StructName}}InfoList(pageInfo)
-	if err != nil {
-		response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
-	} else {
-		response.OkWithData(resp.PageResult{
-			List:     list,
-			Total:    total,
-			Page:     pageInfo.Page,
-			PageSize: pageInfo.PageSize,
-		}, c)
-	}
+	if err, list, total := service.Get{{.StructName}}InfoList(pageInfo); err != nil {
+	    global.GVA_LOG.Error("获取失败", zap.Any("err", err))
+        response.FailWithMessage("获取失败", c)
+    } else {
+        response.OkWithDetailed(response.PageResult{
+            List:     list,
+            Total:    total,
+            Page:     pageInfo.Page,
+            PageSize: pageInfo.PageSize,
+        }, "获取成功", c)
+    }
 }

+ 3 - 3
server/resource/template/te/model.go.tpl → server/resource/template/server/model.go.tpl

@@ -9,10 +9,10 @@ import (
 type {{.StructName}} struct {
       global.GVA_MODEL {{- range .Fields}}
             {{- if eq .FieldType "bool" }}
-      {{.FieldName}}  *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"`
+      {{.FieldName}}  *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if eq .FieldType "string" -}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}{{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"`
             {{- else }}
-      {{.FieldName}}  {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"`
-            {{- end }}  {{- end }} 
+      {{.FieldName}}  {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if eq .FieldType "string" -}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}{{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"`
+            {{- end }} {{- end }}
 }
 
 {{ if .TableName }}

+ 0 - 0
server/resource/template/te/request.go.tpl → server/resource/template/server/request.go.tpl


+ 0 - 0
server/resource/template/te/router.go.tpl → server/resource/template/server/router.go.tpl


+ 30 - 31
server/resource/template/te/service.go.tpl → server/resource/template/server/service.go.tpl

@@ -6,67 +6,66 @@ import (
 	"gin-vue-admin/model/request"
 )
 
-// @title    Create{{.StructName}}
-// @description   create a {{.StructName}}
-// @param     {{.Abbreviation}}               model.{{.StructName}}
-// @auth                     (2020/04/05  20:22)
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: Create{{.StructName}}
+//@description: 创建{{.StructName}}记录
+//@param: {{.Abbreviation}} model.{{.StructName}}
+//@return: err error
 
 func Create{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) {
 	err = global.GVA_DB.Create(&{{.Abbreviation}}).Error
 	return err
 }
 
-// @title    Delete{{.StructName}}
-// @description   delete a {{.StructName}}
-// @auth                     (2020/04/05  20:22)
-// @param     {{.Abbreviation}}               model.{{.StructName}}
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: Delete{{.StructName}}
+//@description: 删除{{.StructName}}记录
+//@param: {{.Abbreviation}} model.{{.StructName}}
+//@return: err error
 
 func Delete{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) {
 	err = global.GVA_DB.Delete({{.Abbreviation}}).Error
 	return err
 }
 
-// @title    Delete{{.StructName}}ByIds
-// @description   delete {{.StructName}}s
-// @auth                     (2020/04/05  20:22)
-// @param     {{.Abbreviation}}               model.{{.StructName}}
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: Delete{{.StructName}}ByIds
+//@description: 批量删除{{.StructName}}记录
+//@param: ids request.IdsReq
+//@return: err error
 
 func Delete{{.StructName}}ByIds(ids request.IdsReq) (err error) {
 	err = global.GVA_DB.Delete(&[]model.{{.StructName}}{},"id in ?",ids.Ids).Error
 	return err
 }
 
-// @title    Update{{.StructName}}
-// @description   update a {{.StructName}}
-// @param     {{.Abbreviation}}          *model.{{.StructName}}
-// @auth                     (2020/04/05  20:22)
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: Update{{.StructName}}
+//@description: 更新{{.StructName}}记录
+//@param: {{.Abbreviation}} *model.{{.StructName}}
+//@return: err error
 
 func Update{{.StructName}}({{.Abbreviation}} *model.{{.StructName}}) (err error) {
 	err = global.GVA_DB.Save({{.Abbreviation}}).Error
 	return err
 }
 
-// @title    Get{{.StructName}}
-// @description   get the info of a {{.StructName}}
-// @auth                     (2020/04/05  20:22)
-// @param     id              uint
-// @return                    error
-// @return    {{.StructName}}        {{.StructName}}
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: Get{{.StructName}}
+//@description: 根据id获取{{.StructName}}记录
+//@param: id uint
+//@return: err error, {{.Abbreviation}} model.{{.StructName}}
 
 func Get{{.StructName}}(id uint) (err error, {{.Abbreviation}} model.{{.StructName}}) {
 	err = global.GVA_DB.Where("id = ?", id).First(&{{.Abbreviation}}).Error
 	return
 }
 
-// @title    Get{{.StructName}}InfoList
-// @description   get {{.StructName}} list by pagination, 分页获取{{.StructName}}
-// @auth                     (2020/04/05  20:22)
-// @param     info            PageInfo
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: Get{{.StructName}}InfoList
+//@description: 分页获取{{.StructName}}记录
+//@param: info request.{{.StructName}}Search
+//@return: err error, list interface{}, total int64
 
 func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error, list interface{}, total int64) {
 	limit := info.PageSize

+ 0 - 0
server/resource/template/fe/api.js.tpl → server/resource/template/web/api.js.tpl


+ 125 - 0
server/resource/template/web/form.vue.tpl

@@ -0,0 +1,125 @@
+<template>
+<div>
+    <el-form :model="formData" label-position="right" label-width="80px">
+        {{- range .Fields}}
+             <el-form-item label="{{.FieldDesc}}:">
+          {{- if eq .FieldType "bool" }}
+                <el-switch active-color="#13ce66" inactive-color="#ff4949" active-text="是" inactive-text="否" v-model="formData.{{.FieldJson}}" clearable ></el-switch>
+          {{ end -}}
+          {{- if eq .FieldType "string" }}
+                <el-input v-model="formData.{{.FieldJson}}" clearable placeholder="请输入" ></el-input>
+          {{ end -}}
+          {{- if eq .FieldType "int" }}
+          {{- if .DictType}}
+                 <el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" clearable>
+                     <el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value"></el-option>
+                 </el-select>
+          {{ else -}}
+                 <el-input v-model.number="formData.{{ .FieldJson }}" clearable placeholder="请输入"></el-input>
+          {{ end -}}
+          {{ end -}}
+          {{- if eq .FieldType "time.Time" }}
+                  <el-date-picker type="date" placeholder="选择日期" v-model="formData.{{ .FieldJson }}" clearable></el-date-picker>
+           {{ end -}}
+           {{- if eq .FieldType "float64" }}
+                  <el-input-number v-model="formData.{{ .FieldJson }}" :precision="2" clearable></el-input-number>
+           {{ end -}}
+              </el-form-item>
+           {{ end -}}
+
+           <el-form-item>
+           <el-button @click="save" type="primary">保存</el-button>
+           <el-button @click="back" type="primary">返回</el-button>
+           </el-form-item>
+    </el-form>
+</div>
+</template>
+
+<script>
+import {
+    create{{.StructName}},
+    update{{.StructName}},
+    find{{.StructName}}
+} from "@/api/{{.PackageName}}";  //  此处请自行替换地址
+import infoList from "@/mixins/infoList";
+export default {
+  name: "{{.StructName}}",
+  mixins: [infoList],
+  data() {
+    return {
+      type: "",
+
+      {{- range .Fields}}
+          {{- if .DictType }}
+      {{ .DictType }}Options:[],
+          {{ end -}}
+      {{end -}}
+
+      formData: {
+            {{range .Fields}}
+            {{- if eq .FieldType "bool" -}}
+               {{.FieldJson}}:false,
+            {{ end -}}
+            {{- if eq .FieldType "string" -}}
+               {{.FieldJson}}:"",
+            {{ end -}}
+            {{- if eq .FieldType "int" -}}
+               {{.FieldJson}}:0,
+            {{ end -}}
+            {{- if eq .FieldType "time.Time" -}}
+               {{.FieldJson}}:new Date(),
+            {{ end -}}
+            {{- if eq .FieldType "float64" -}}
+               {{.FieldJson}}:0,
+            {{ end -}}
+            {{ end }}
+      }
+    };
+  },
+  methods: {
+    async save() {
+      let res;
+      switch (this.type) {
+        case "create":
+          res = await create{{.StructName}}(this.formData);
+          break;
+        case "update":
+          res = await update{{.StructName}}(this.formData);
+          break;
+        default:
+          res = await create{{.StructName}}(this.formData);
+          break;
+      }
+      if (res.code == 0) {
+        this.$message({
+          type:"success",
+          message:"创建/更改成功"
+        })
+      }
+    },
+    back(){
+        this.$router.go(-1)
+    }
+  },
+  async created() {
+   // 建议通过url传参获取目标数据ID 调用 find方法进行查询数据操作 从而决定本页面是create还是update 以下为id作为url参数示例
+    if(this.$route.query.id){
+    const res = await find{{.StructName}}({ ID: this.$route.query.id })
+    if(res.code == 0){
+       this.formData = res.data.re{{.Abbreviation}}
+       this.type == "update"
+     }
+    }else{
+     this.type == "create"
+   }
+  {{ range .Fields -}}
+    {{- if .DictType }}
+    await this.getDict("{{.DictType}}");
+    {{ end -}}
+  {{- end }}
+}
+};
+</script>
+
+<style>
+</style>

+ 10 - 1
server/resource/template/fe/table.vue.tpl → server/resource/template/web/table.vue.tpl

@@ -136,7 +136,7 @@ import {
     find{{.StructName}},
     get{{.StructName}}List
 } from "@/api/{{.PackageName}}";  //  此处请自行替换地址
-import { formatTimeToStr } from "@/utils/data";
+import { formatTimeToStr } from "@/utils/date";
 import infoList from "@/mixins/infoList";
 export default {
   name: "{{.StructName}}",
@@ -149,11 +149,13 @@ export default {
       type: "",
       deleteVisible: false,
       multipleSelection: [],
+
       {{- range .Fields}}
           {{- if .DictType }}
       {{ .DictType }}Options:[],
           {{ end -}}
       {{end -}}
+
       formData: {
             {{range .Fields}}
             {{- if eq .FieldType "bool" -}}
@@ -208,6 +210,13 @@ export default {
       },
       async onDelete() {
         const ids = []
+        if(this.multipleSelection.length == 0){
+          this.$message({
+            type: 'warning',
+            message: '请选择要删除的数据'
+          })
+          return
+        }
         this.multipleSelection &&
           this.multipleSelection.map(item => {
             ids.push(item.ID)

+ 1 - 4
server/router/exa_simple_uploader.go

@@ -2,14 +2,11 @@ package router
 
 import (
 	"gin-vue-admin/api/v1"
-	"gin-vue-admin/middleware"
 	"github.com/gin-gonic/gin"
 )
 
 func InitSimpleUploaderRouter(Router *gin.RouterGroup) {
-	ApiRouter := Router.Group("simpleUploader").
-		Use(middleware.JWTAuth()).
-		Use(middleware.CasbinHandler())
+	ApiRouter := Router.Group("simpleUploader")
 	{
 		ApiRouter.POST("upload", v1.SimpleUploaderUpload) // 上传功能
 		ApiRouter.GET("checkFileMd5", v1.CheckFileMd5)    // 文件完整度验证

+ 1 - 4
server/router/exp_customer.go

@@ -7,10 +7,7 @@ import (
 )
 
 func InitCustomerRouter(Router *gin.RouterGroup) {
-	ApiRouter := Router.Group("customer").
-		Use(middleware.JWTAuth()).
-		Use(middleware.CasbinHandler()).
-		Use(middleware.OperationRecord())
+	ApiRouter := Router.Group("customer").Use(middleware.OperationRecord())
 	{
 		ApiRouter.POST("customer", v1.CreateExaCustomer)     // 创建客户
 		ApiRouter.PUT("customer", v1.UpdateExaCustomer)      // 更新客户

+ 0 - 1
server/router/exp_file_upload_and_download.go

@@ -7,7 +7,6 @@ import (
 
 func InitFileUploadAndDownloadRouter(Router *gin.RouterGroup) {
 	FileUploadAndDownloadGroup := Router.Group("fileUploadAndDownload")
-	// .Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
 	{
 		FileUploadAndDownloadGroup.POST("/upload", v1.UploadFile)                                 // 上传文件
 		FileUploadAndDownloadGroup.POST("/getFileList", v1.GetFileList)                           // 获取上传文件列表

+ 1 - 1
server/router/sys_api.go

@@ -7,7 +7,7 @@ import (
 )
 
 func InitApiRouter(Router *gin.RouterGroup) {
-	ApiRouter := Router.Group("api").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
+	ApiRouter := Router.Group("api").Use(middleware.OperationRecord())
 	{
 		ApiRouter.POST("createApi", v1.CreateApi)   // 创建Api
 		ApiRouter.POST("deleteApi", v1.DeleteApi)   // 删除Api

+ 1 - 4
server/router/sys_authority.go

@@ -7,10 +7,7 @@ import (
 )
 
 func InitAuthorityRouter(Router *gin.RouterGroup) {
-	AuthorityRouter := Router.Group("authority").
-		Use(middleware.JWTAuth()).
-		Use(middleware.CasbinHandler()).
-		Use(middleware.OperationRecord())
+	AuthorityRouter := Router.Group("authority").Use(middleware.OperationRecord())
 	{
 		AuthorityRouter.POST("createAuthority", v1.CreateAuthority)   // 创建角色
 		AuthorityRouter.POST("deleteAuthority", v1.DeleteAuthority)   // 删除角色

+ 2 - 6
server/router/sys_auto_code.go

@@ -2,19 +2,15 @@ package router
 
 import (
 	"gin-vue-admin/api/v1"
-	"gin-vue-admin/middleware"
 	"github.com/gin-gonic/gin"
 )
 
 func InitAutoCodeRouter(Router *gin.RouterGroup) {
-	AutoCodeRouter := Router.Group("autoCode").
-		Use(middleware.JWTAuth()).
-		Use(middleware.CasbinHandler()).
-		Use(middleware.OperationRecord())
+	AutoCodeRouter := Router.Group("autoCode")
 	{
 		AutoCodeRouter.POST("createTemp", v1.CreateTemp) // 创建自动化代码
 		AutoCodeRouter.GET("getTables", v1.GetTables)    // 获取对应数据库的表
 		AutoCodeRouter.GET("getDB", v1.GetDB)            // 获取数据库
-		AutoCodeRouter.GET("getColume", v1.GetColume)    // 获取指定表所有字段信息
+		AutoCodeRouter.GET("getColumn", v1.GetColumn)    // 获取指定表所有字段信息
 	}
 }

+ 1 - 4
server/router/sys_casbin.go

@@ -7,10 +7,7 @@ import (
 )
 
 func InitCasbinRouter(Router *gin.RouterGroup) {
-	CasbinRouter := Router.Group("casbin").
-		Use(middleware.JWTAuth()).
-		Use(middleware.CasbinHandler()).
-		Use(middleware.OperationRecord())
+	CasbinRouter := Router.Group("casbin").Use(middleware.OperationRecord())
 	{
 		CasbinRouter.POST("updateCasbin", v1.UpdateCasbin)
 		CasbinRouter.POST("getPolicyPathByAuthorityId", v1.GetPolicyPathByAuthorityId)

+ 1 - 4
server/router/sys_dictionary.go

@@ -7,10 +7,7 @@ import (
 )
 
 func InitSysDictionaryRouter(Router *gin.RouterGroup) {
-	SysDictionaryRouter := Router.Group("sysDictionary").
-		Use(middleware.JWTAuth()).
-		Use(middleware.CasbinHandler()).
-		Use(middleware.OperationRecord())
+	SysDictionaryRouter := Router.Group("sysDictionary").Use(middleware.OperationRecord())
 	{
 		SysDictionaryRouter.POST("createSysDictionary", v1.CreateSysDictionary)   // 新建SysDictionary
 		SysDictionaryRouter.DELETE("deleteSysDictionary", v1.DeleteSysDictionary) // 删除SysDictionary

+ 1 - 4
server/router/sys_dictionary_detail.go

@@ -7,10 +7,7 @@ import (
 )
 
 func InitSysDictionaryDetailRouter(Router *gin.RouterGroup) {
-	SysDictionaryDetailRouter := Router.Group("sysDictionaryDetail").
-		Use(middleware.JWTAuth()).
-		Use(middleware.CasbinHandler()).
-		Use(middleware.OperationRecord())
+	SysDictionaryDetailRouter := Router.Group("sysDictionaryDetail").Use(middleware.OperationRecord())
 	{
 		SysDictionaryDetailRouter.POST("createSysDictionaryDetail", v1.CreateSysDictionaryDetail)   // 新建SysDictionaryDetail
 		SysDictionaryDetailRouter.DELETE("deleteSysDictionaryDetail", v1.DeleteSysDictionaryDetail) // 删除SysDictionaryDetail

+ 1 - 1
server/router/sys_email.go

@@ -7,7 +7,7 @@ import (
 )
 
 func InitEmailRouter(Router *gin.RouterGroup) {
-	UserRouter := Router.Group("email").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
+	UserRouter := Router.Group("email").Use(middleware.OperationRecord())
 	{
 		UserRouter.POST("emailTest", v1.EmailTest) // 发送测试邮件
 	}

+ 1 - 1
server/router/sys_jwt.go

@@ -7,7 +7,7 @@ import (
 )
 
 func InitJwtRouter(Router *gin.RouterGroup) {
-	ApiRouter := Router.Group("jwt").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
+	ApiRouter := Router.Group("jwt").Use(middleware.OperationRecord())
 	{
 		ApiRouter.POST("jsonInBlacklist", v1.JsonInBlacklist) // jwt加入黑名单
 	}

+ 1 - 1
server/router/sys_menu.go

@@ -7,7 +7,7 @@ import (
 )
 
 func InitMenuRouter(Router *gin.RouterGroup) (R gin.IRoutes) {
-	MenuRouter := Router.Group("menu").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
+	MenuRouter := Router.Group("menu").Use(middleware.OperationRecord())
 	{
 		MenuRouter.POST("getMenu", v1.GetMenu)                   // 获取菜单树
 		MenuRouter.POST("getMenuList", v1.GetMenuList)           // 分页获取基础menu列表

+ 5 - 7
server/router/sys_operation_record.go

@@ -7,15 +7,13 @@ import (
 )
 
 func InitSysOperationRecordRouter(Router *gin.RouterGroup) {
-	SysOperationRecordRouter := Router.Group("sysOperationRecord").
-		Use(middleware.JWTAuth()).
-		Use(middleware.CasbinHandler())
+	SysOperationRecordRouter := Router.Group("sysOperationRecord").Use(middleware.OperationRecord())
 	{
-		SysOperationRecordRouter.POST("createSysOperationRecord", v1.CreateSysOperationRecord)   // 新建SysOperationRecord
-		SysOperationRecordRouter.DELETE("deleteSysOperationRecord", v1.DeleteSysOperationRecord) // 删除SysOperationRecord
+		SysOperationRecordRouter.POST("createSysOperationRecord", v1.CreateSysOperationRecord)             // 新建SysOperationRecord
+		SysOperationRecordRouter.DELETE("deleteSysOperationRecord", v1.DeleteSysOperationRecord)           // 删除SysOperationRecord
 		SysOperationRecordRouter.DELETE("deleteSysOperationRecordByIds", v1.DeleteSysOperationRecordByIds) // 批量删除SysOperationRecord
-		SysOperationRecordRouter.GET("findSysOperationRecord", v1.FindSysOperationRecord)        // 根据ID获取SysOperationRecord
-		SysOperationRecordRouter.GET("getSysOperationRecordList", v1.GetSysOperationRecordList)  // 获取SysOperationRecord列表
+		SysOperationRecordRouter.GET("findSysOperationRecord", v1.FindSysOperationRecord)                  // 根据ID获取SysOperationRecord
+		SysOperationRecordRouter.GET("getSysOperationRecordList", v1.GetSysOperationRecordList)            // 获取SysOperationRecord列表
 
 	}
 }

+ 1 - 1
server/router/sys_system.go

@@ -7,7 +7,7 @@ import (
 )
 
 func InitSystemRouter(Router *gin.RouterGroup) {
-	SystemRouter := Router.Group("system").Use(middleware.JWTAuth(), middleware.CasbinHandler())
+	SystemRouter := Router.Group("system").Use(middleware.OperationRecord())
 	{
 		SystemRouter.POST("getSystemConfig", v1.GetSystemConfig) // 获取配置文件内容
 		SystemRouter.POST("setSystemConfig", v1.SetSystemConfig) // 设置配置文件内容

+ 1 - 4
server/router/sys_user.go

@@ -7,10 +7,7 @@ import (
 )
 
 func InitUserRouter(Router *gin.RouterGroup) {
-	UserRouter := Router.Group("user").
-		Use(middleware.JWTAuth()).
-		Use(middleware.CasbinHandler()).
-		Use(middleware.OperationRecord())
+	UserRouter := Router.Group("user").Use(middleware.OperationRecord())
 	{
 		UserRouter.POST("register", v1.Register)
 		UserRouter.POST("changePassword", v1.ChangePassword)     // 修改密码

+ 1 - 1
server/router/sys_workflow.go

@@ -7,7 +7,7 @@ import (
 )
 
 func InitWorkflowRouter(Router *gin.RouterGroup) {
-	WorkflowRouter := Router.Group("workflow").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
+	WorkflowRouter := Router.Group("workflow").Use(middleware.OperationRecord())
 	{
 		WorkflowRouter.POST("createWorkFlow", v1.CreateWorkFlow) // 创建工作流
 	}

+ 15 - 23
server/service/exa_breakpoint_continue.go

@@ -7,15 +7,11 @@ import (
 	"gorm.io/gorm"
 )
 
-// @title         FindOrCreateFile
-// @description   Check your file if it does not exist, or return current slice of the file
-// 上传文件时检测当前文件属性,如果没有文件则创建,有则返回文件的当前切片
-// @auth                     (2020/04/05  20:22)
-// @param     fileMd5         string
-// @param     fileName        string
-// @param     chunkTotal      int
-// @return    err             error
-// @return    file            ExaFile
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: FindOrCreateFile
+//@description: 上传文件时检测当前文件属性,如果没有文件则创建,有则返回文件的当前切片
+//@param: fileMd5 string, fileName string, chunkTotal int
+//@return: err error, file model.ExaFile
 
 func FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (err error, file model.ExaFile) {
 	var cfile model.ExaFile
@@ -33,13 +29,11 @@ func FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (err erro
 	return err, cfile
 }
 
-// @title    CreateFileChunk
-// @description   create a chunk of the file, 创建文件切片记录
-// @auth                       (2020/04/05  20:22)
-// @param     id                unit
-// @param     fileChunkPath     string
-// @param     fileChunkNumber   int
-// @return                      error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: CreateFileChunk
+//@description: 创建文件切片记录
+//@param: id uint, fileChunkPath string, fileChunkNumber int
+//@return: error
 
 func CreateFileChunk(id uint, fileChunkPath string, fileChunkNumber int) error {
 	var chunk model.ExaFileChunk
@@ -50,13 +44,11 @@ func CreateFileChunk(id uint, fileChunkPath string, fileChunkNumber int) error {
 	return err
 }
 
-// @title    DeleteFileChunk
-// @description   delete a chuck of the file, 删除文件切片记录
-// @auth                     (2020/04/05  20:22)
-// @param     FileMd5         string
-// @param     FileName        string
-// @param     FilePath        string
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: DeleteFileChunk
+//@description: 删除文件切片记录
+//@param: fileMd5 string, fileName string, filePath string
+//@return: error
 
 func DeleteFileChunk(fileMd5 string, fileName string, filePath string) error {
 	var chunks []model.ExaFileChunk

+ 25 - 27
server/service/exa_customer.go

@@ -6,57 +6,55 @@ import (
 	"gin-vue-admin/model/request"
 )
 
-// @title    CreateExaCustomer
-// @description   create a customer, 创建用户
-// @param     e               model.ExaCustomer
-// @auth                     (2020/04/05  20:22)
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: CreateExaCustomer
+//@description: 创建客户
+//@param: e model.ExaCustomer
+//@return: err error
 
 func CreateExaCustomer(e model.ExaCustomer) (err error) {
 	err = global.GVA_DB.Create(&e).Error
 	return err
 }
 
-// @title    DeleteFileChunk
-// @description   delete a customer, 删除用户
-// @auth                     (2020/04/05  20:22)
-// @param     e               model.ExaCustomer
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: DeleteFileChunk
+//@description: 删除客户
+//@param: e model.ExaCustomer
+//@return: err error
 
 func DeleteExaCustomer(e model.ExaCustomer) (err error) {
 	err = global.GVA_DB.Delete(e).Error
 	return err
 }
 
-// @title    UpdateExaCustomer
-// @description   update a customer, 更新用户
-// @param     e               *model.ExaCustomer
-// @auth                     (2020/04/05  20:22)
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: UpdateExaCustomer
+//@description: 更新客户
+//@param: e *model.ExaCustomer
+//@return: err error
 
 func UpdateExaCustomer(e *model.ExaCustomer) (err error) {
 	err = global.GVA_DB.Save(e).Error
 	return err
 }
 
-// @title    GetExaCustomer
-// @description   get the info of a costumer , 获取用户信息
-// @auth                     (2020/04/05  20:22)
-// @param     id              uint
-// @return                    error
-// @return    customer        ExaCustomer
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetExaCustomer
+//@description: 获取客户信息
+//@param: id uint
+//@return: err error, customer model.ExaCustomer
 
 func GetExaCustomer(id uint) (err error, customer model.ExaCustomer) {
 	err = global.GVA_DB.Where("id = ?", id).First(&customer).Error
 	return
 }
 
-// @title    GetCustomerInfoList
-// @description   get customer list by pagination, 分页获取用户列表
-// @auth                     (2020/04/05  20:22)
-// @param     sysUserAuthorityID              string
-// @param     info            PageInfo
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetCustomerInfoList
+//@description: 分页获取客户列表
+//@param: sysUserAuthorityID string, info request.PageInfo
+//@return: err error, list interface{}, total int64
 
 func GetCustomerInfoList(sysUserAuthorityID string, info request.PageInfo) (err error, list interface{}, total int64) {
 	limit := info.PageSize

+ 26 - 31
server/service/exa_file_upload_download.go

@@ -10,22 +10,21 @@ import (
 	"strings"
 )
 
-// @title    Upload
-// @description   创建文件上传记录
-// @param     file            model.ExaFileUploadAndDownload
-// @auth                     (2020/04/05  20:22)
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: Upload
+//@description: 创建文件上传记录
+//@param: file model.ExaFileUploadAndDownload
+//@return: error
 
 func Upload(file model.ExaFileUploadAndDownload) error {
-	err := global.GVA_DB.Create(&file).Error
-	return err
+	return global.GVA_DB.Create(&file).Error
 }
 
-// @title    FindFile
-// @description   删除文件切片记录
-// @auth                     (2020/04/05  20:22)
-// @param     id              uint
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: FindFile
+//@description: 删除文件切片记录
+//@param: id uint
+//@return: error, model.ExaFileUploadAndDownload
 
 func FindFile(id uint) (error, model.ExaFileUploadAndDownload) {
 	var file model.ExaFileUploadAndDownload
@@ -33,11 +32,11 @@ func FindFile(id uint) (error, model.ExaFileUploadAndDownload) {
 	return err, file
 }
 
-// @title    DeleteFile
-// @description   删除文件记录
-// @auth                     (2020/04/05  20:22)
-// @param     file            model.ExaFileUploadAndDownload
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: DeleteFile
+//@description: 删除文件记录
+//@param: file model.ExaFileUploadAndDownload
+//@return: err error
 
 func DeleteFile(file model.ExaFileUploadAndDownload) (err error) {
 	var fileFromDb model.ExaFileUploadAndDownload
@@ -50,13 +49,11 @@ func DeleteFile(file model.ExaFileUploadAndDownload) (err error) {
 	return err
 }
 
-// @title    GetFileRecordInfoList
-// @description   分页获取数据
-// @auth                     (2020/04/05  20:22)
-// @param     info            PageInfo
-// @return    err             error
-// @return    list            error
-// @return    total           error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetFileRecordInfoList
+//@description: 分页获取数据
+//@param: info request.PageInfo
+//@return: err error, list interface{}, total int64
 
 func GetFileRecordInfoList(info request.PageInfo) (err error, list interface{}, total int64) {
 	limit := info.PageSize
@@ -68,13 +65,11 @@ func GetFileRecordInfoList(info request.PageInfo) (err error, list interface{},
 	return err, fileLists, total
 }
 
-// @title    UploadFile
-// @description   根据配置文件判断是文件上传到本地或者七牛云
-// @auth                     (2020/04/05  20:22)
-// @param     header          *multipart.FileHeader
-// @param     noSave          string
-// @return    err             error
-// @return    file            file model.ExaFileUploadAndDownload
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: UploadFile
+//@description: 根据配置文件判断是文件上传到本地或者七牛云
+//@param: header *multipart.FileHeader, noSave string
+//@return: err error, file model.ExaFileUploadAndDownload
 
 func UploadFile(header *multipart.FileHeader, noSave string) (err error, file model.ExaFileUploadAndDownload) {
 	oss := upload.NewOss()

+ 40 - 26
server/service/exa_simple_uploader.go

@@ -11,19 +11,34 @@ import (
 	"strconv"
 )
 
-// 保存文件切片路径
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: SaveChunk
+//@description: 保存文件切片路径
+//@param: uploader model.ExaSimpleUploader
+//@return: err error
+
 func SaveChunk(uploader model.ExaSimpleUploader) (err error) {
 	return global.GVA_DB.Create(uploader).Error
 }
 
-// 检查文件是否已经上传过
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: CheckFileMd5
+//@description: 检查文件是否已经上传过
+//@param: md5 string
+//@return: err error, uploads []model.ExaSimpleUploader, isDone bool
+
 func CheckFileMd5(md5 string) (err error, uploads []model.ExaSimpleUploader, isDone bool) {
 	err = global.GVA_DB.Find(&uploads, "identifier = ? AND is_done = ?", md5, false).Error
 	isDone = errors.Is(global.GVA_DB.First(&model.ExaSimpleUploader{}, "identifier = ? AND is_done = ?", md5, true).Error, gorm.ErrRecordNotFound)
 	return err, uploads, !isDone
 }
 
-// 合并文件
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: MergeFileMd5
+//@description: 合并文件
+//@param: md5 string, fileName string
+//@return: err error
+
 func MergeFileMd5(md5 string, fileName string) (err error) {
 	finishDir := "./finish/"
 	dir := "./chunk/" + md5
@@ -54,27 +69,26 @@ func MergeFileMd5(md5 string, fileName string) (err error) {
 	if err != nil {
 		return err
 	}
-	//创建事务
-	tx := global.GVA_DB.Begin()
-	//删除切片信息
-	err = tx.Delete(&model.ExaSimpleUploader{}, "identifier = ? AND is_done = ?", md5, false).Error
-	// 添加文件信息
-	if err != nil {
-		fmt.Println(err)
-		tx.Rollback()
-	}
-	err = tx.Create(&model.ExaSimpleUploader{
-		Identifier: md5,
-		IsDone:     true,
-		FilePath:   finishDir + fileName,
-		Filename:   fileName,
-	}).Error
-	if err != nil {
-		fmt.Println(err)
-		tx.Rollback()
-	}
-	tx.Commit()
-	//清除切片
-	err = os.RemoveAll(dir)
-	return
+	err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
+		//删除切片信息
+		if err = tx.Delete(&model.ExaSimpleUploader{}, "identifier = ? AND is_done = ?", md5, false).Error; err != nil {
+			fmt.Println(err)
+			return err
+		}
+		data := model.ExaSimpleUploader{
+			Identifier: md5,
+			IsDone:     true,
+			FilePath:   finishDir + fileName,
+			Filename:   fileName,
+		}
+		// 添加文件信息
+		if err = tx.Create(&data).Error; err != nil {
+			fmt.Println(err)
+			return err
+		}
+		return nil
+	})
+
+	err = os.RemoveAll(dir) //清除切片
+	return err
 }

+ 20 - 23
server/service/jwt_black_list.go

@@ -8,47 +8,44 @@ import (
 	"time"
 )
 
-// @title    JsonInBlacklist
-// @description   create jwt blacklist
-// @param     jwtList         model.JwtBlacklist
-// @auth                     (2020/04/05  20:22)
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: JsonInBlacklist
+//@description: 拉黑jwt
+//@param: jwtList model.JwtBlacklist
+//@return: err error
 
 func JsonInBlacklist(jwtList model.JwtBlacklist) (err error) {
 	err = global.GVA_DB.Create(&jwtList).Error
 	return
 }
 
-// @title    IsBlacklist
-// @description   check if the Jwt is in the blacklist or not, 判断JWT是否在黑名单内部
-// @auth                     (2020/04/05  20:22)
-// @param     jwt             string
-// @param     jwtList         model.JwtBlacklist
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: IsBlacklist
+//@description: 判断JWT是否在黑名单内部
+//@param: jwt string
+//@return: bool
 
 func IsBlacklist(jwt string) bool {
 	isNotFound := errors.Is(global.GVA_DB.Where("jwt = ?", jwt).First(&model.JwtBlacklist{}).Error, gorm.ErrRecordNotFound)
 	return !isNotFound
 }
 
-// @title    GetRedisJWT
-// @description   Get user info in redis
-// @auth                     (2020/04/05  20:22)
-// @param     userName        string
-// @return    err             error
-// @return    redisJWT        string
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetRedisJWT
+//@description: 从redis取jwt
+//@param: userName string
+//@return: err error, redisJWT string
 
 func GetRedisJWT(userName string) (err error, redisJWT string) {
 	redisJWT, err = global.GVA_REDIS.Get(userName).Result()
 	return err, redisJWT
 }
 
-// @title    SetRedisJWT
-// @description   set jwt into the Redis
-// @auth                     (2020/04/05  20:22)
-// @param     jwtList         model.JwtBlacklist
-// @param     userName        string
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: SetRedisJWT
+//@description: jwt存入redis并设置过期时间
+//@param: userName string
+//@return: err error, redisJWT string
 
 func SetRedisJWT(jwt string, userName string) (err error) {
 	// 此处过期时间等于jwt过期时间

+ 29 - 39
server/service/sys_api.go

@@ -8,25 +8,24 @@ import (
 	"gorm.io/gorm"
 )
 
-// @title    CreateApi
-// @description   create base apis, 新增基础api
-// @auth                     (2020/04/05  20:22)
-// @param     api             model.SysApi
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: CreateApi
+//@description: 新增基础api
+//@param: api model.SysApi
+//@return: err error
 
 func CreateApi(api model.SysApi) (err error) {
-
 	if !errors.Is(global.GVA_DB.Where("path = ? AND method = ?", api.Path, api.Method).First(&model.SysApi{}).Error, gorm.ErrRecordNotFound) {
 		return errors.New("存在相同api")
 	}
 	return global.GVA_DB.Create(&api).Error
 }
 
-// @title    DeleteApi
-// @description   delete a base api, 删除基础api
-// @param     api             model.SysApi
-// @auth                     (2020/04/05  20:22)
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: DeleteApi
+//@description: 删除基础api
+//@param: api model.SysApi
+//@return: err error
 
 func DeleteApi(api model.SysApi) (err error) {
 	err = global.GVA_DB.Delete(api).Error
@@ -34,16 +33,11 @@ func DeleteApi(api model.SysApi) (err error) {
 	return err
 }
 
-// @title    GetInfoList
-// @description   get apis by pagination, 分页获取数据
-// @auth                     (2020/04/05  20:22)
-// @param     api             model.SysApi
-// @param     info            request.PageInfo
-// @param     order           string
-// @param     desc            bool
-// @return    err             error
-// @return    list            interface{}
-// @return    total           int
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetAPIInfoList
+//@description: 分页获取数据,
+//@param: api model.SysApi, info request.PageInfo, order string, desc bool
+//@return: err error
 
 func GetAPIInfoList(api model.SysApi, info request.PageInfo, order string, desc bool) (err error, list interface{}, total int64) {
 	limit := info.PageSize
@@ -88,40 +82,36 @@ func GetAPIInfoList(api model.SysApi, info request.PageInfo, order string, desc
 	return err, apiList, total
 }
 
-// @title    GetAllApis
-// @description   get all apis, 获取所有的api
-// @auth                     (2020/04/05  20:22)
-// @return       err          error
-// @return       apis         []SysApi
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetAllApis
+//@description: 获取所有的api
+//@return: err error, apis []model.SysApi
 
 func GetAllApis() (err error, apis []model.SysApi) {
 	err = global.GVA_DB.Find(&apis).Error
 	return
 }
 
-// @title    GetApiById
-// @description   根据id获取api
-// @auth                     (2020/04/05  20:22)
-// @param     api             model.SysApi
-// @param     id              float64
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetApiById
+//@description: 根据id获取api
+//@param: id float64
+//@return: err error, api model.SysApi
 
 func GetApiById(id float64) (err error, api model.SysApi) {
 	err = global.GVA_DB.Where("id = ?", id).First(&api).Error
 	return
 }
 
-// @title    UpdateApi
-// @description   update a base api, update api
-// @auth                     (2020/04/05  20:22)
-// @param     api             model.SysApi
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: UpdateApi
+//@description: 根据id更新api
+//@param: api model.SysApi
+//@return: err error
 
 func UpdateApi(api model.SysApi) (err error) {
 	var oldA model.SysApi
-
 	err = global.GVA_DB.Where("id = ?", api.ID).First(&oldA).Error
-
 	if oldA.Path != api.Path || oldA.Method != api.Method {
 		if !errors.Is(global.GVA_DB.Where("path = ? AND method = ?", api.Path, api.Method).First(&model.SysApi{}).Error, gorm.ErrRecordNotFound) {
 			return errors.New("存在相同api路径")

+ 46 - 52
server/service/sys_authority.go

@@ -10,12 +10,11 @@ import (
 	"strconv"
 )
 
-// @title    CreateAuthority
-// @description   创建一个角色
-// @auth                     (2020/04/05  20:22)
-// @param     auth            model.SysAuthority
-// @return                    error
-// @return    authority       model.SysAuthority
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: CreateAuthority
+//@description: 创建一个角色
+//@param: auth model.SysAuthority
+//@return: err error, authority model.SysAuthority
 
 func CreateAuthority(auth model.SysAuthority) (err error, authority model.SysAuthority) {
 	var authorityBox model.SysAuthority
@@ -26,12 +25,11 @@ func CreateAuthority(auth model.SysAuthority) (err error, authority model.SysAut
 	return err, auth
 }
 
-// @title    CopyAuthority
-// @description   复制一个角色
-// @auth                     (2020/04/05  20:22)
-// @param     copyInfo        response.SysAuthorityCopyResponse
-// @return                    error
-// @return    authority       model.SysAuthority
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: CopyAuthority
+//@description: 复制一个角色
+//@param: copyInfo response.SysAuthorityCopyResponse
+//@return: err error, authority model.SysAuthority
 
 func CopyAuthority(copyInfo response.SysAuthorityCopyResponse) (err error, authority model.SysAuthority) {
 	var authorityBox model.SysAuthority
@@ -39,7 +37,7 @@ func CopyAuthority(copyInfo response.SysAuthorityCopyResponse) (err error, autho
 		return errors.New("存在相同角色id"), authority
 	}
 	copyInfo.Authority.Children = []model.SysAuthority{}
-	err, menus := GetMenuAuthority(copyInfo.OldAuthorityId)
+	err, menus := GetMenuAuthority(&request.GetAuthorityId{AuthorityId: copyInfo.OldAuthorityId})
 	var baseMenu []model.SysBaseMenu
 	for _, v := range menus {
 		intNum, _ := strconv.Atoi(v.MenuId)
@@ -57,24 +55,22 @@ func CopyAuthority(copyInfo response.SysAuthorityCopyResponse) (err error, autho
 	return err, copyInfo.Authority
 }
 
-// @title    UpdateAuthority
-// @description   更改一个角色
-// @auth                     (2020/04/05  20:22)
-// @param     auth            model.SysAuthority
-// @return                    error
-// @return    authority       model.SysAuthority
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: UpdateAuthority
+//@description: 更改一个角色
+//@param: auth model.SysAuthority
+//@return:err error, authority model.SysAuthority
 
 func UpdateAuthority(auth model.SysAuthority) (err error, authority model.SysAuthority) {
 	err = global.GVA_DB.Where("authority_id = ?", auth.AuthorityId).First(&model.SysAuthority{}).Updates(&auth).Error
 	return err, auth
 }
 
-// @title    DeleteAuthority
-// @description   删除角色
-// @auth                     (2020/04/05  20:22)
-// @param     auth            model.SysAuthority
-// @return                    error
-// 删除角色
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: DeleteAuthority
+//@description: 删除角色
+//@param: auth *model.SysAuthority
+//@return: err error
 
 func DeleteAuthority(auth *model.SysAuthority) (err error) {
 	if !errors.Is(global.GVA_DB.Where("authority_id = ?", auth.AuthorityId).First(&model.SysUser{}).Error, gorm.ErrRecordNotFound) {
@@ -95,12 +91,11 @@ func DeleteAuthority(auth *model.SysAuthority) (err error) {
 	return err
 }
 
-// @title    GetInfoList
-// @description   删除文件切片记录
-// @auth                     (2020/04/05  20:22)
-// @param     info            request.PaveInfo
-// @return                    error
-// 分页获取数据
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetAuthorityInfoList
+//@description: 分页获取数据
+//@param: info request.PageInfo
+//@return: err error, list interface{}, total int64
 
 func GetAuthorityInfoList(info request.PageInfo) (err error, list interface{}, total int64) {
 	limit := info.PageSize
@@ -116,23 +111,22 @@ func GetAuthorityInfoList(info request.PageInfo) (err error, list interface{}, t
 	return err, authority, total
 }
 
-// @title    GetAuthorityInfo
-// @description   获取所有角色信息
-// @auth                     (2020/04/05  20:22)
-// @param     auth            model.SysAuthority
-// @return                    error
-// @param     authority       model.SysAuthority
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetAuthorityInfo
+//@description: 获取所有角色信息
+//@param: auth model.SysAuthority
+//@return: err error, sa model.SysAuthority
 
 func GetAuthorityInfo(auth model.SysAuthority) (err error, sa model.SysAuthority) {
 	err = global.GVA_DB.Preload("DataAuthorityId").Where("authority_id = ?", auth.AuthorityId).First(&sa).Error
 	return err, sa
 }
 
-// @title    SetDataAuthority
-// @description   设置角色资源权限
-// @auth                     (2020/04/05  20:22)
-// @param     auth            model.SysAuthority
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: SetDataAuthority
+//@description: 设置角色资源权限
+//@param: auth model.SysAuthority
+//@return:error
 
 func SetDataAuthority(auth model.SysAuthority) error {
 	var s model.SysAuthority
@@ -141,11 +135,11 @@ func SetDataAuthority(auth model.SysAuthority) error {
 	return err
 }
 
-// @title    SetMenuAuthority
-// @description   菜单与角色绑定
-// @auth                     (2020/04/05  20:22)
-// @param     auth            *model.SysAuthority
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: SetMenuAuthority
+//@description: 菜单与角色绑定
+//@param: auth *model.SysAuthority
+//@return: error
 
 func SetMenuAuthority(auth *model.SysAuthority) error {
 	var s model.SysAuthority
@@ -154,11 +148,11 @@ func SetMenuAuthority(auth *model.SysAuthority) error {
 	return err
 }
 
-// @title    findChildrenAuthority
-// @description   查询子角色
-// @auth                     (2020/04/05  20:22)
-// @param     auth            *model.SysAuthority
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: findChildrenAuthority
+//@description: 查询子角色
+//@param: authority *model.SysAuthority
+//@return: err error
 
 func findChildrenAuthority(authority *model.SysAuthority) (err error) {
 	err = global.GVA_DB.Preload("DataAuthorityId").Where("parent_id = ?", authority.AuthorityId).Find(&authority.Children).Error

+ 157 - 21
server/service/sys_auto_code.go

@@ -1,27 +1,32 @@
 package service
 
 import (
+	"errors"
+	"fmt"
 	"gin-vue-admin/global"
 	"gin-vue-admin/model"
 	"gin-vue-admin/model/request"
 	"gin-vue-admin/utils"
+	"gorm.io/gorm"
 	"io/ioutil"
 	"os"
+	"path/filepath"
 	"strings"
 	"text/template"
 )
 
 type tplData struct {
-	template     *template.Template
-	locationPath string
-	autoCodePath string
+	template         *template.Template
+	locationPath     string
+	autoCodePath     string
+	autoMoveFilePath string
 }
 
-// @title    CreateTemp
-// @description   函数的详细描述
-// @auth                     (2020/04/05  20:22)
-// @param     autoCode        model.AutoCodeStruct
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: CreateTemp
+//@description: 创建代码
+//@param: model.AutoCodeStruct
+//@return: error
 
 func CreateTemp(autoCode model.AutoCodeStruct) (err error) {
 	basePath := "resource/template"
@@ -46,7 +51,7 @@ func CreateTemp(autoCode model.AutoCodeStruct) (err error) {
 	}
 
 	// 生成文件路径,填充 autoCodePath 字段,readme.txt.tpl不符合规则,需要特殊处理
-	// resource/template/fe/api.js.tpl -> autoCode/fe/autoCode.PackageName/api/autoCode.PackageName.js
+	// resource/template/web/api.js.tpl -> autoCode/web/autoCode.PackageName/api/autoCode.PackageName.js
 	// resource/template/readme.txt.tpl -> autoCode/readme.txt
 	autoPath := "autoCode/"
 	for index, value := range dataList {
@@ -88,19 +93,36 @@ func CreateTemp(autoCode model.AutoCodeStruct) (err error) {
 		_ = f.Close()
 	}
 
-	// 生成压缩包
-	if err := utils.ZipFiles("./ginvueadmin.zip", fileList, ".", "."); err != nil {
-		return err
-	}
-
-	// 移除中间文件
-	if err := os.RemoveAll(autoPath); err != nil {
-		return err
+	defer func() { // 移除中间文件
+		if err := os.RemoveAll(autoPath); err != nil {
+			return
+		}
+	}()
+	if autoCode.AutoMoveFile { // 判断是否需要自动转移
+		for index, _ := range dataList {
+			addAutoMoveFile(&dataList[index])
+		}
+		for _, value := range dataList { // 移动文件
+			if err := utils.FileMove(value.autoCodePath, value.autoMoveFilePath); err != nil {
+				fmt.Println(err)
+				return err
+			}
+		}
+		return errors.New("创建代码成功并移动文件成功")
+	} else { // 打包
+		if err := utils.ZipFiles("./ginvueadmin.zip", fileList, ".", "."); err != nil {
+			return err
+		}
 	}
 	return nil
 }
 
-// GetAllTplFile 用来获取 pathName 文件夹下所有 tpl 文件
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetAllTplFile
+//@description: 获取 pathName 文件夹下所有 tpl 文件
+//@param: pathName string, fileList []string
+//@return: []string, error
+
 func GetAllTplFile(pathName string, fileList []string) ([]string, error) {
 	files, err := ioutil.ReadDir(pathName)
 	for _, fi := range files {
@@ -118,17 +140,131 @@ func GetAllTplFile(pathName string, fileList []string) ([]string, error) {
 	return fileList, err
 }
 
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetTables
+//@description: 获取数据库的所有表名
+//@param: pathName string
+//@param: fileList []string
+//@return: []string, error
+
 func GetTables(dbName string) (err error, TableNames []request.TableReq) {
 	err = global.GVA_DB.Raw("select table_name as table_name from information_schema.tables where table_schema = ?", dbName).Scan(&TableNames).Error
 	return err, TableNames
 }
 
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetDB
+//@description: 获取数据库的所有数据库名
+//@param: pathName string
+//@param: fileList []string
+//@return: []string, error
+
 func GetDB() (err error, DBNames []request.DBReq) {
 	err = global.GVA_DB.Raw("SELECT SCHEMA_NAME AS `database` FROM INFORMATION_SCHEMA.SCHEMATA;").Scan(&DBNames).Error
 	return err, DBNames
 }
 
-func GetColume(tableName string, dbName string) (err error, Columes []request.ColumeReq) {
-	err = global.GVA_DB.Raw("SELECT COLUMN_NAME colume_name,DATA_TYPE data_type,CASE DATA_TYPE WHEN 'longtext' THEN c.CHARACTER_MAXIMUM_LENGTH WHEN 'varchar' THEN c.CHARACTER_MAXIMUM_LENGTH WHEN 'double' THEN CONCAT_WS( ',', c.NUMERIC_PRECISION, c.NUMERIC_SCALE ) WHEN 'decimal' THEN CONCAT_WS( ',', c.NUMERIC_PRECISION, c.NUMERIC_SCALE ) WHEN 'int' THEN c.NUMERIC_PRECISION WHEN 'bigint' THEN c.NUMERIC_PRECISION ELSE '' END AS data_type_long,COLUMN_COMMENT colume_comment FROM INFORMATION_SCHEMA.COLUMNS c WHERE table_name = ? AND table_schema = ?", tableName, dbName).Scan(&Columes).Error
-	return err, Columes
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetDB
+//@description: 获取指定数据库和指定数据表的所有字段名,类型值等
+//@param: pathName string
+//@param: fileList []string
+//@return: []string, error
+
+func GetColumn(tableName string, dbName string) (err error, Columns []request.ColumnReq) {
+	err = global.GVA_DB.Raw("SELECT COLUMN_NAME column_name,DATA_TYPE data_type,CASE DATA_TYPE WHEN 'longtext' THEN c.CHARACTER_MAXIMUM_LENGTH WHEN 'varchar' THEN c.CHARACTER_MAXIMUM_LENGTH WHEN 'double' THEN CONCAT_WS( ',', c.NUMERIC_PRECISION, c.NUMERIC_SCALE ) WHEN 'decimal' THEN CONCAT_WS( ',', c.NUMERIC_PRECISION, c.NUMERIC_SCALE ) WHEN 'int' THEN c.NUMERIC_PRECISION WHEN 'bigint' THEN c.NUMERIC_PRECISION ELSE '' END AS data_type_long,COLUMN_COMMENT column_comment FROM INFORMATION_SCHEMA.COLUMNS c WHERE table_name = ? AND table_schema = ?", tableName, dbName).Scan(&Columns).Error
+	return err, Columns
+}
+
+//@author: [SliverHorn](https://github.com/SliverHorn)
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@function: addAutoMoveFile
+//@description: 生成对应的迁移文件路径
+//@param: *tplData
+//@return: null
+
+func addAutoMoveFile(data *tplData) {
+	dir := filepath.Base(filepath.Dir(data.autoCodePath))
+	base := filepath.Base(data.autoCodePath)
+	if strings.Contains(data.autoCodePath, "server") {
+		if strings.Contains(data.autoCodePath, "router") {
+			data.autoMoveFilePath = filepath.Join(dir, base)
+		} else if strings.Contains(data.autoCodePath, "api") {
+			data.autoMoveFilePath = filepath.Join(dir, "v1", base)
+		} else if strings.Contains(data.autoCodePath, "service") {
+			data.autoMoveFilePath = filepath.Join(dir, base)
+		} else if strings.Contains(data.autoCodePath, "model") {
+			data.autoMoveFilePath = filepath.Join(dir, base)
+		} else if strings.Contains(data.autoCodePath, "request") {
+			data.autoMoveFilePath = filepath.Join("model", dir, base)
+		}
+	} else if strings.Contains(data.autoCodePath, "web") {
+		if strings.Contains(data.autoCodePath, "js") {
+			data.autoMoveFilePath = filepath.Join("../", "web", "src", dir, base)
+		} else if strings.Contains(data.autoCodePath, "form") {
+			data.autoMoveFilePath = filepath.Join("../", "web", "src", "view", filepath.Base(filepath.Dir(filepath.Dir(data.autoCodePath))), strings.TrimSuffix(base, filepath.Ext(base))+"Form.vue")
+		} else if strings.Contains(data.autoCodePath, "table") {
+			data.autoMoveFilePath = filepath.Join("../", "web", "src", "view", filepath.Base(filepath.Dir(filepath.Dir(data.autoCodePath))), base)
+		}
+	}
+}
+
+//@author: [piexlmax](https://github.com/piexlmax)
+//@author: [SliverHorn](https://github.com/SliverHorn)
+//@function: CreateApi
+//@description: 自动创建api数据,
+//@param: a *model.AutoCodeStruct
+//@return: error
+
+func AutoCreateApi(a *model.AutoCodeStruct) (err error) {
+	var apiList = []model.SysApi{
+		{
+			Path:        "/" + a.Abbreviation + "/" + "create" + a.StructName,
+			Description: "新增" + a.Description,
+			ApiGroup:    a.Abbreviation,
+			Method:      "POST",
+		},
+		{
+			Path:        "/" + a.Abbreviation + "/" + "delete" + a.StructName,
+			Description: "删除" + a.Description,
+			ApiGroup:    a.Abbreviation,
+			Method:      "DELETE",
+		},
+		{
+			Path:        "/" + a.Abbreviation + "/" + "delete" + a.StructName + "ByIds",
+			Description: "批量删除" + a.Description,
+			ApiGroup:    a.Abbreviation,
+			Method:      "DELETE",
+		},
+		{
+			Path:        "/" + a.Abbreviation + "/" + "update" + a.StructName,
+			Description: "更新" + a.Description,
+			ApiGroup:    a.Abbreviation,
+			Method:      "PUT",
+		},
+		{
+			Path:        "/" + a.Abbreviation + "/" + "find" + a.StructName,
+			Description: "根据ID获取" + a.Description,
+			ApiGroup:    a.Abbreviation,
+			Method:      "GET",
+		},
+		{
+			Path:        "/" + a.Abbreviation + "/" + "get" + a.StructName + "List",
+			Description: "获取" + a.Description + "列表",
+			ApiGroup:    a.Abbreviation,
+			Method:      "GET",
+		},
+	}
+	err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
+		for _, v := range apiList {
+			var api model.SysApi
+			if errors.Is(tx.Where("path = ? AND method = ?", v.Path, v.Method).First(&api).Error, gorm.ErrRecordNotFound) {
+				if err := tx.Create(&v).Error; err != nil { // 遇到错误时回滚事务
+					return err
+				}
+			}
+		}
+		return nil
+	})
+	return err
 }

+ 45 - 23
server/service/sys_base_menu.go

@@ -7,11 +7,11 @@ import (
 	"gorm.io/gorm"
 )
 
-// @title    DeleteBaseMenu
-// @description   删除基础路由
-// @auth                     (2020/04/05  20:22)
-// @param     id              float64
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: DeleteBaseMenu
+//@description: 删除基础路由
+//@param: id float64
+//@return: err error
 
 func DeleteBaseMenu(id float64) (err error) {
 	err = global.GVA_DB.Preload("Parameters").Where("parent_id = ?", id).First(&model.SysBaseMenu{}).Error
@@ -30,11 +30,11 @@ func DeleteBaseMenu(id float64) (err error) {
 	return err
 }
 
-// @title    UpdateBaseMenu
-// @description   更新路由
-// @auth                     (2020/04/05  20:22)
-// @param     menu            model.SysBaseMenu
-// @return    err             errorgetMenu
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: UpdateBaseMenu
+//@description: 更新路由
+//@param: menu model.SysBaseMenu
+//@return:err error
 
 func UpdateBaseMenu(menu model.SysBaseMenu) (err error) {
 	var oldMenu model.SysBaseMenu
@@ -50,23 +50,45 @@ func UpdateBaseMenu(menu model.SysBaseMenu) (err error) {
 	upDateMap["icon"] = menu.Icon
 	upDateMap["sort"] = menu.Sort
 
-	db := global.GVA_DB.Where("id = ?", menu.ID).Find(&oldMenu)
-	if oldMenu.Name != menu.Name {
-		if !errors.Is(global.GVA_DB.Where("id <> ? AND name = ?", menu.ID, menu.Name).First(&model.SysBaseMenu{}).Error, gorm.ErrRecordNotFound) {
-			global.GVA_LOG.Debug("存在相同name修改失败")
-			return errors.New("存在相同name修改失败")
+	err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
+		db := tx.Where("id = ?", menu.ID).Find(&oldMenu)
+		if oldMenu.Name != menu.Name {
+			if !errors.Is(tx.Where("id <> ? AND name = ?", menu.ID, menu.Name).First(&model.SysBaseMenu{}).Error, gorm.ErrRecordNotFound) {
+				global.GVA_LOG.Debug("存在相同name修改失败")
+				return errors.New("存在相同name修改失败")
+			}
 		}
-	}
-	err = global.GVA_DB.Delete(&model.SysBaseMenuParameter{}, "sys_base_menu_id = ?", menu.ID).Error
-	err = db.Updates(upDateMap).Error
+		txErr := tx.Unscoped().Delete(&model.SysBaseMenuParameter{}, "sys_base_menu_id = ?", menu.ID).Error
+		if txErr != nil {
+			global.GVA_LOG.Debug(txErr.Error())
+			return txErr
+		}
+		if len(menu.Parameters) > 0 {
+			for k, _ := range menu.Parameters {
+				menu.Parameters[k].SysBaseMenuID = menu.ID
+			}
+			txErr = tx.Create(&menu.Parameters).Error
+			if txErr != nil {
+				global.GVA_LOG.Debug(txErr.Error())
+				return txErr
+			}
+		}
+
+		txErr = db.Updates(upDateMap).Error
+		if txErr != nil {
+			global.GVA_LOG.Debug(txErr.Error())
+			return txErr
+		}
+		return nil
+	})
 	return err
 }
 
-// @title    GetBaseMenuById
-// @description   get current menus, 返回当前选中menu
-// @auth                     (2020/04/05  20:22)
-// @param     id              float64
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetBaseMenuById
+//@description: 返回当前选中menu
+//@param: id float64
+//@return: err error, menu model.SysBaseMenu
 
 func GetBaseMenuById(id float64) (err error, menu model.SysBaseMenu) {
 	err = global.GVA_DB.Preload("Parameters").Where("id = ?", id).First(&menu).Error

+ 35 - 40
server/service/sys_casbin.go

@@ -12,12 +12,11 @@ import (
 	"strings"
 )
 
-// @title    UpdateCasbin
-// @description   update casbin authority, 更新casbin权限
-// @auth                     (2020/04/05  20:22)
-// @param     authorityId      string
-// @param     casbinInfos      []CasbinInfo
-// @return                     error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: UpdateCasbin
+//@description: 更新casbin权限
+//@param: authorityId string, casbinInfos []request.CasbinInfo
+//@return: error
 
 func UpdateCasbin(authorityId string, casbinInfos []request.CasbinInfo) error {
 	ClearCasbin(0, authorityId)
@@ -39,14 +38,11 @@ func UpdateCasbin(authorityId string, casbinInfos []request.CasbinInfo) error {
 	return nil
 }
 
-// @title    UpdateCasbinApi
-// @description   update casbin apis, API更新随动
-// @auth                     (2020/04/05  20:22)
-// @param     oldPath          string
-// @param     newPath          string
-// @param     oldMethod        string
-// @param     newMethod        string
-// @return                     error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: UpdateCasbinApi
+//@description: API更新随动
+//@param: oldPath string, newPath string, oldMethod string, newMethod string
+//@return: error
 
 func UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod string) error {
 	err := global.GVA_DB.Table("casbin_rule").Model(&model.CasbinModel{}).Where("v1 = ? AND v2 = ?", oldPath, oldMethod).Updates(map[string]interface{}{
@@ -56,11 +52,12 @@ func UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod
 	return err
 }
 
-// @title    GetPolicyPathByAuthorityId
-// @description   get policy path by authorityId, 获取权限列表
-// @auth                     (2020/04/05  20:22)
-// @param     authorityId     string
-// @return                    []string
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetPolicyPathByAuthorityId
+//@description: 获取权限列表
+//@param: authorityId string
+//@return: pathMaps []request.CasbinInfo
+
 
 func GetPolicyPathByAuthorityId(authorityId string) (pathMaps []request.CasbinInfo) {
 	e := Casbin()
@@ -74,12 +71,11 @@ func GetPolicyPathByAuthorityId(authorityId string) (pathMaps []request.CasbinIn
 	return pathMaps
 }
 
-// @title    ClearCasbin
-// @description   清除匹配的权限
-// @auth                     (2020/04/05  20:22)
-// @param     v               int
-// @param     p               string
-// @return                    bool
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: ClearCasbin
+//@description: 清除匹配的权限
+//@param: v int, p ...string
+//@return: bool
 
 func ClearCasbin(v int, p ...string) bool {
 	e := Casbin()
@@ -88,9 +84,10 @@ func ClearCasbin(v int, p ...string) bool {
 
 }
 
-// @title    Casbin
-// @description   store to DB, 持久化到数据库  引入自定义规则
-// @auth                     (2020/04/05  20:22)
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: Casbin
+//@description: 持久化到数据库  引入自定义规则
+//@return: *casbin.Enforcer
 
 func Casbin() *casbin.Enforcer {
 	admin := global.GVA_CONFIG.Mysql
@@ -101,12 +98,11 @@ func Casbin() *casbin.Enforcer {
 	return e
 }
 
-// @title    ParamsMatch
-// @description   customized rule, 自定义规则函数
-// @auth                     (2020/04/05  20:22)
-// @param     fullNameKey1    string
-// @param     key2            string
-// @return                    bool
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: ParamsMatch
+//@description: 自定义规则函数
+//@param: fullNameKey1 string, key2 string
+//@return: bool
 
 func ParamsMatch(fullNameKey1 string, key2 string) bool {
 	key1 := strings.Split(fullNameKey1, "?")[0]
@@ -114,12 +110,11 @@ func ParamsMatch(fullNameKey1 string, key2 string) bool {
 	return util.KeyMatch2(key1, key2)
 }
 
-// @title    ParamsMatchFunc
-// @description   customized function, 自定义规则函数
-// @auth                     (2020/04/05  20:22)
-// @param     args            ...interface{}
-// @return                    interface{}
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: ParamsMatchFunc
+//@description: 自定义规则函数
+//@param: args ...interface{}
+//@return: interface{}, error
 
 func ParamsMatchFunc(args ...interface{}) (interface{}, error) {
 	name1 := args[0].(string)

+ 26 - 26
server/service/sys_dictionary.go

@@ -8,11 +8,11 @@ import (
 	"gorm.io/gorm"
 )
 
-// @title    CreateSysDictionary
-// @description   create a SysDictionary
-// @param     sysDictionary               model.SysDictionary
-// @auth                     (2020/04/05  20:22)
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: DeleteSysDictionary
+//@description: 创建字典数据
+//@param: sysDictionary model.SysDictionary
+//@return: err error
 
 func CreateSysDictionary(sysDictionary model.SysDictionary) (err error) {
 	if (!errors.Is(global.GVA_DB.First(&model.SysDictionary{}, "type = ?", sysDictionary.Type).Error, gorm.ErrRecordNotFound)) {
@@ -22,22 +22,22 @@ func CreateSysDictionary(sysDictionary model.SysDictionary) (err error) {
 	return err
 }
 
-// @title    DeleteSysDictionary
-// @description   delete a SysDictionary
-// @auth                     (2020/04/05  20:22)
-// @param     sysDictionary               model.SysDictionary
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: DeleteSysDictionary
+//@description: 删除字典数据
+//@param: sysDictionary model.SysDictionary
+//@return: err error
 
 func DeleteSysDictionary(sysDictionary model.SysDictionary) (err error) {
 	err = global.GVA_DB.Delete(sysDictionary).Delete(&sysDictionary.SysDictionaryDetails).Error
 	return err
 }
 
-// @title    UpdateSysDictionary
-// @description   update a SysDictionary
-// @param     sysDictionary          *model.SysDictionary
-// @auth                     (2020/04/05  20:22)
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: UpdateSysDictionary
+//@description: 更新字典数据
+//@param: sysDictionary *model.SysDictionary
+//@return: err error
 
 func UpdateSysDictionary(sysDictionary *model.SysDictionary) (err error) {
 	var dict model.SysDictionary
@@ -60,23 +60,23 @@ func UpdateSysDictionary(sysDictionary *model.SysDictionary) (err error) {
 	return err
 }
 
-// @title    GetSysDictionary
-// @description   get the info of a SysDictionary
-// @auth                     (2020/04/05  20:22)
-// @param     id              uint
-// @return                    error
-// @return    SysDictionary        SysDictionary
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetSysDictionary
+//@description: 根据id或者type获取字典单条数据
+//@param: Type string, Id uint
+//@return: err error, sysDictionary model.SysDictionary
 
 func GetSysDictionary(Type string, Id uint) (err error, sysDictionary model.SysDictionary) {
 	err = global.GVA_DB.Where("type = ? OR id = ?", Type, Id).Preload("SysDictionaryDetails").First(&sysDictionary).Error
 	return
 }
 
-// @title    GetSysDictionaryInfoList
-// @description   get SysDictionary list by pagination, 分页获取用户列表
-// @auth                     (2020/04/05  20:22)
-// @param     info            PageInfo
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@author: [SliverHorn](https://github.com/SliverHorn)
+//@function: GetSysDictionaryInfoList
+//@description: 分页获取字典列表
+//@param: info request.SysDictionarySearch
+//@return: err error, list interface{}, total int64
 
 func GetSysDictionaryInfoList(info request.SysDictionarySearch) (err error, list interface{}, total int64) {
 	limit := info.PageSize

+ 25 - 26
server/service/sys_dictionary_detail.go

@@ -6,56 +6,55 @@ import (
 	"gin-vue-admin/model/request"
 )
 
-// @title    CreateSysDictionaryDetail
-// @description   create a SysDictionaryDetail
-// @param     sysDictionaryDetail               model.SysDictionaryDetail
-// @auth                     (2020/04/05  20:22)
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: CreateSysDictionaryDetail
+//@description: 创建字典详情数据
+//@param: sysDictionaryDetail model.SysDictionaryDetail
+//@return: err error
 
 func CreateSysDictionaryDetail(sysDictionaryDetail model.SysDictionaryDetail) (err error) {
 	err = global.GVA_DB.Create(&sysDictionaryDetail).Error
 	return err
 }
 
-// @title    DeleteSysDictionaryDetail
-// @description   delete a SysDictionaryDetail
-// @auth                     (2020/04/05  20:22)
-// @param     sysDictionaryDetail               model.SysDictionaryDetail
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: DeleteSysDictionaryDetail
+//@description: 删除字典详情数据
+//@param: sysDictionaryDetail model.SysDictionaryDetail
+//@return: err error
 
 func DeleteSysDictionaryDetail(sysDictionaryDetail model.SysDictionaryDetail) (err error) {
 	err = global.GVA_DB.Delete(sysDictionaryDetail).Error
 	return err
 }
 
-// @title    UpdateSysDictionaryDetail
-// @description   update a SysDictionaryDetail
-// @param     sysDictionaryDetail          *model.SysDictionaryDetail
-// @auth                     (2020/04/05  20:22)
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: UpdateSysDictionaryDetail
+//@description: 更新字典详情数据
+//@param: sysDictionaryDetail *model.SysDictionaryDetail
+//@return: err error
 
 func UpdateSysDictionaryDetail(sysDictionaryDetail *model.SysDictionaryDetail) (err error) {
 	err = global.GVA_DB.Save(sysDictionaryDetail).Error
 	return err
 }
 
-// @title    GetSysDictionaryDetail
-// @description   get the info of a SysDictionaryDetail
-// @auth                     (2020/04/05  20:22)
-// @param     id              uint
-// @return                    error
-// @return    SysDictionaryDetail        SysDictionaryDetail
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetSysDictionaryDetail
+//@description: 根据id获取字典详情单条数据
+//@param: id uint
+//@return: err error, sysDictionaryDetail model.SysDictionaryDetail
 
 func GetSysDictionaryDetail(id uint) (err error, sysDictionaryDetail model.SysDictionaryDetail) {
 	err = global.GVA_DB.Where("id = ?", id).First(&sysDictionaryDetail).Error
 	return
 }
 
-// @title    GetSysDictionaryDetailInfoList
-// @description   get SysDictionaryDetail list by pagination, 分页获取用户列表
-// @auth                     (2020/04/05  20:22)
-// @param     info            PageInfo
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetSysDictionaryDetailInfoList
+//@description: 分页获取字典详情列表
+//@param: info request.SysDictionaryDetailSearch
+//@return: err error
 
 func GetSysDictionaryDetailInfoList(info request.SysDictionaryDetailSearch) (err error, list interface{}, total int64) {
 	limit := info.PageSize

+ 4 - 4
server/service/sys_email.go

@@ -4,10 +4,10 @@ import (
 	"gin-vue-admin/utils"
 )
 
-// @title    EmailTest
-// @description   发送邮件测试
-// @auth                    (2020/09/08  13:58
-// @return    err            error
+//@author: [maplepie](https://github.com/maplepie)
+//@function: EmailTest
+//@description: 发送邮件测试
+//@return: err error
 
 func EmailTest() (err error) {
 	subject := "test"

+ 50 - 59
server/service/sys_menu.go

@@ -4,15 +4,16 @@ import (
 	"errors"
 	"gin-vue-admin/global"
 	"gin-vue-admin/model"
+	"gin-vue-admin/model/request"
 	"gorm.io/gorm"
 	"strconv"
 )
 
-// @title   getMenuTreeMap
-// @description    获取路由总树map
-// @auth       qm      (2020/05/06 10:26)
-// @return     err             error
-// @return    menusMsp            map{string}[]SysBaseMenu
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: getMenuTreeMap
+//@description: 获取路由总树map
+//@param: authorityId string
+//@return: err error, treeMap map[string][]model.SysMenu
 
 func getMenuTreeMap(authorityId string) (err error, treeMap map[string][]model.SysMenu) {
 	var allMenus []model.SysMenu
@@ -24,12 +25,11 @@ func getMenuTreeMap(authorityId string) (err error, treeMap map[string][]model.S
 	return err, treeMap
 }
 
-// @title    GetMenuTree
-// @description   获取动态菜单树
-// @auth                     (2020/04/05  20:22)
-// @param     authorityId     string
-// @return    err             error
-// @return    menus           []model.SysMenu
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetMenuTree
+//@description: 获取动态菜单树
+//@param: authorityId string
+//@return: err error, menus []model.SysMenu
 
 func GetMenuTree(authorityId string) (err error, menus []model.SysMenu) {
 	err, menuTree := getMenuTreeMap(authorityId)
@@ -40,12 +40,11 @@ func GetMenuTree(authorityId string) (err error, menus []model.SysMenu) {
 	return err, menus
 }
 
-// @title    getChildrenList
-// @description   获取子菜单
-// @auth                     (2020/04/05  20:22)
-// @param     menu            *model.SysMenu
-// @param     sql             string
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: getChildrenList
+//@description: 获取子菜单
+//@param: menu *model.SysMenu, treeMap map[string][]model.SysMenu
+//@return: err error
 
 func getChildrenList(menu *model.SysMenu, treeMap map[string][]model.SysMenu) (err error) {
 	menu.Children = treeMap[menu.MenuId]
@@ -55,13 +54,10 @@ func getChildrenList(menu *model.SysMenu, treeMap map[string][]model.SysMenu) (e
 	return err
 }
 
-// @title    GetInfoList
-// @description   获取路由分页
-// @auth                     (2020/04/05  20:22)
-// @param     info            request.PageInfo
-// @return    err             error
-// @return    list            interface{}
-// @return    total           int
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetInfoList
+//@description: 获取路由分页
+//@return: err error, list interface{}, total int64
 
 func GetInfoList() (err error, list interface{}, total int64) {
 	var menuList []model.SysBaseMenu
@@ -73,11 +69,11 @@ func GetInfoList() (err error, list interface{}, total int64) {
 	return err, menuList, total
 }
 
-// @title    getBaseChildrenList
-// @description   get children of menu, 获取菜单的子菜单
-// @auth                     (2020/04/05  20:22)
-// @param     menu            *model.SysBaseMenu
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: getBaseChildrenList
+//@description: 获取菜单的子菜单
+//@param: menu *model.SysBaseMenu, treeMap map[string][]model.SysBaseMenu
+//@return: err error
 
 func getBaseChildrenList(menu *model.SysBaseMenu, treeMap map[string][]model.SysBaseMenu) (err error) {
 	menu.Children = treeMap[strconv.Itoa(int(menu.ID))]
@@ -87,12 +83,11 @@ func getBaseChildrenList(menu *model.SysBaseMenu, treeMap map[string][]model.Sys
 	return err
 }
 
-// @title    AddBaseMenu
-// @description   函数的详细描述
-// @auth                     (2020/04/05  20:22)
-// @param     menu            *model.SysBaseMenu
-// @return    err             error
-// 增加基础路由
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: AddBaseMenu
+//@description: 添加基础路由
+//@param: menu model.SysBaseMenu
+//@return: err error
 
 func AddBaseMenu(menu model.SysBaseMenu) (err error) {
 	if !errors.Is(global.GVA_DB.Where("name = ?", menu.Name).First(&model.SysBaseMenu{}).Error, gorm.ErrRecordNotFound) {
@@ -102,11 +97,10 @@ func AddBaseMenu(menu model.SysBaseMenu) (err error) {
 	return err
 }
 
-// @title   getBaseMenuTreeMap
-// @description    获取路由总树map
-// @auth       qm      (2020/05/06 10:26)
-// @return     err             error
-// @return    menusMsp            map{string}[]SysBaseMenu
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: getBaseMenuTreeMap
+//@description: 获取路由总树map
+//@return: err error, treeMap map[string][]model.SysBaseMenu
 
 func getBaseMenuTreeMap() (err error, treeMap map[string][]model.SysBaseMenu) {
 	var allMenus []model.SysBaseMenu
@@ -118,11 +112,10 @@ func getBaseMenuTreeMap() (err error, treeMap map[string][]model.SysBaseMenu) {
 	return err, treeMap
 }
 
-// @title    GetBaseMenuTree
-// @description   获取基础路由树
-// @auth                     (2020/04/05  20:22)
-// @return    err              error
-// @return    menus            []SysBaseMenu
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetBaseMenuTree
+//@description: 获取基础路由树
+//@return: err error, menus []model.SysBaseMenu
 
 func GetBaseMenuTree() (err error, menus []model.SysBaseMenu) {
 	err, treeMap := getBaseMenuTreeMap()
@@ -133,12 +126,11 @@ func GetBaseMenuTree() (err error, menus []model.SysBaseMenu) {
 	return err, menus
 }
 
-// @title    AddMenuAuthority
-// @description   为角色增加menu树
-// @auth                     (2020/04/05  20:22)
-// @param     menus           []model.SysBaseMenu
-// @param     authorityId     string
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: AddMenuAuthority
+//@description: 为角色增加menu树
+//@param: menus []model.SysBaseMenu, authorityId string
+//@return: err error
 
 func AddMenuAuthority(menus []model.SysBaseMenu, authorityId string) (err error) {
 	var auth model.SysAuthority
@@ -148,16 +140,15 @@ func AddMenuAuthority(menus []model.SysBaseMenu, authorityId string) (err error)
 	return err
 }
 
-// @title    GetMenuAuthority
-// @description   查看当前角色树
-// @auth                     (2020/04/05  20:22)
-// @param     authorityId     string
-// @return    err             error
-// @return    menus           []SysBaseMenu
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetMenuAuthority
+//@description: 查看当前角色树
+//@param: info *request.GetAuthorityId
+//@return: err error, menus []model.SysMenu
 
-func GetMenuAuthority(authorityId string) (err error, menus []model.SysMenu) {
+func GetMenuAuthority(info *request.GetAuthorityId) (err error, menus []model.SysMenu) {
+	err = global.GVA_DB.Where("authority_id = ? ", info.AuthorityId).Order("sort").Find(&menus).Error
 	//sql := "SELECT authority_menu.keep_alive,authority_menu.default_menu,authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.menu_id,authority_menu.authority_id FROM authority_menu WHERE authority_menu.authority_id = ? ORDER BY authority_menu.sort ASC"
-	err = global.GVA_DB.Where("authority_id = ? ", authorityId).Order("sort").Find(&menus).Error
 	//err = global.GVA_DB.Raw(sql, authorityId).Scan(&menus).Error
 	return err, menus
 }

+ 27 - 26
server/service/sys_operation_record.go

@@ -6,56 +6,57 @@ import (
 	"gin-vue-admin/model/request"
 )
 
-// @title    CreateSysOperationRecord
-// @description   create a SysOperationRecord
-// @param     sysOperationRecord               model.SysOperationRecord
-// @auth                     (2020/04/05  20:22)
-// @return    err             error
+//@author: [granty1](https://github.com/granty1)
+//@function: CreateSysOperationRecord
+//@description: 创建记录
+//@param: sysOperationRecord model.SysOperationRecord
+//@return: err error
 
 func CreateSysOperationRecord(sysOperationRecord model.SysOperationRecord) (err error) {
 	err = global.GVA_DB.Create(&sysOperationRecord).Error
 	return err
 }
 
-// @title    DeleteSysOperationRecord
-// @description   delete SysOperationRecords
-// @auth                     (2020/04/05  20:22)
-// @param     sysOperationRecord               request.IdsReq
-// @return                    error
+//@author: [granty1](https://github.com/granty1)
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: DeleteSysOperationRecordByIds
+//@description: 批量删除记录
+//@param: ids request.IdsReq
+//@return: err error
 
 func DeleteSysOperationRecordByIds(ids request.IdsReq) (err error) {
 	err = global.GVA_DB.Delete(&[]model.SysOperationRecord{}, "id in (?)", ids.Ids).Error
 	return err
 }
 
-// @title    DeleteSysOperationRecord
-// @description   delete a SysOperationRecord
-// @auth                     (2020/04/05  20:22)
-// @param     sysOperationRecord               model.SysOperationRecord
-// @return                    error
+//@author: [granty1](https://github.com/granty1)
+//@function: DeleteSysOperationRecord
+//@description: 删除操作记录
+//@param: sysOperationRecord model.SysOperationRecord
+//@return: err error
 
 func DeleteSysOperationRecord(sysOperationRecord model.SysOperationRecord) (err error) {
 	err = global.GVA_DB.Delete(sysOperationRecord).Error
 	return err
 }
 
-// @title    GetSysOperationRecord
-// @description   get the info of a SysOperationRecord
-// @auth                     (2020/04/05  20:22)
-// @param     id              uint
-// @return                    error
-// @return    SysOperationRecord        SysOperationRecord
+//@author: [granty1](https://github.com/granty1)
+//@function: DeleteSysOperationRecord
+//@description: 根据id获取单条操作记录
+//@param: id uint
+//@return: err error, sysOperationRecord model.SysOperationRecord
 
 func GetSysOperationRecord(id uint) (err error, sysOperationRecord model.SysOperationRecord) {
 	err = global.GVA_DB.Where("id = ?", id).First(&sysOperationRecord).Error
 	return
 }
 
-// @title    GetSysOperationRecordInfoList
-// @description   get SysOperationRecord list by pagination, 分页获取用户列表
-// @auth                     (2020/04/05  20:22)
-// @param     info            PageInfo
-// @return                    error
+//@author: [granty1](https://github.com/granty1)
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetSysOperationRecordInfoList
+//@description: 分页获取操作记录列表
+//@param: info request.SysOperationRecordSearch
+//@return: err error, list interface{}, total int64
 
 func GetSysOperationRecordInfoList(info request.SysOperationRecordSearch) (err error, list interface{}, total int64) {
 	limit := info.PageSize

+ 14 - 16
server/service/sys_system.go

@@ -8,21 +8,21 @@ import (
 	"go.uber.org/zap"
 )
 
-// @title    GetSystemConfig
-// @description   读取配置文件
-// @auth                     (2020/04/05  20:22)
-// @return    err             error
-// @return    conf            Server
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetSystemConfig
+//@description: 读取配置文件
+//@return: err error, conf config.Server
 
 func GetSystemConfig() (err error, conf config.Server) {
 	return nil, global.GVA_CONFIG
 }
 
-// @title    SetSystemConfig
-// @description   set system config, 设置配置文件
-// @auth                    (2020/04/05  20:22)
-// @param     system         model.System
-// @return    err            error
+// @description   set system config,
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: SetSystemConfig
+//@description: 设置配置文件
+//@param: system model.System
+//@return: err error
 
 func SetSystemConfig(system model.System) (err error) {
 	cs := utils.StructToMap(system.Config)
@@ -33,12 +33,10 @@ func SetSystemConfig(system model.System) (err error) {
 	return err
 }
 
-
-// @title    GetServerInfo
-// @description   get server info , 获取服务器信息
-// @auth                    (2020/04/05  20:22)
-// @return    server         *utils.Server
-// @return    err            error
+//@author: [SliverHorn](https://github.com/SliverHorn)
+//@function: GetServerInfo
+//@description: 获取服务器信息
+//@return: server *utils.Server, err error
 
 func GetServerInfo() (server *utils.Server, err error) {
 	var s utils.Server

+ 46 - 56
server/service/sys_user.go

@@ -10,12 +10,12 @@ import (
 	"gorm.io/gorm"
 )
 
-// @title    Register
-// @description   register, 用户注册
-// @auth                     (2020/04/05  20:22)
-// @param     u               model.SysUser
-// @return    err             error
-// @return    userInter       *SysUser
+
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: Register
+//@description: 用户注册
+//@param: u model.SysUser
+//@return: err error, userInter model.SysUser
 
 func Register(u model.SysUser) (err error, userInter model.SysUser) {
 	var user model.SysUser
@@ -29,12 +29,11 @@ func Register(u model.SysUser) (err error, userInter model.SysUser) {
 	return err, u
 }
 
-// @title    Login
-// @description   login, 用户登录
-// @auth                     (2020/04/05  20:22)
-// @param     u               *model.SysUser
-// @return    err             error
-// @return    userInter       *SysUser
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: Login
+//@description: 用户登录
+//@param: u *model.SysUser
+//@return: err error, userInter *model.SysUser
 
 func Login(u *model.SysUser) (err error, userInter *model.SysUser) {
 	var user model.SysUser
@@ -43,13 +42,11 @@ func Login(u *model.SysUser) (err error, userInter *model.SysUser) {
 	return err, &user
 }
 
-// @title    ChangePassword
-// @description   change the password of a certain user, 修改用户密码
-// @auth                     (2020/04/05  20:22)
-// @param     u               *model.SysUser
-// @param     newPassword     string
-// @return    err             error
-// @return    userInter       *SysUser
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: ChangePassword
+//@description: 修改用户密码
+//@param: u *model.SysUser, newPassword string
+//@return: err error, userInter *model.SysUser
 
 func ChangePassword(u *model.SysUser, newPassword string) (err error, userInter *model.SysUser) {
 	var user model.SysUser
@@ -58,13 +55,11 @@ func ChangePassword(u *model.SysUser, newPassword string) (err error, userInter
 	return err, u
 }
 
-// @title    GetInfoList
-// @description   get user list by pagination, 分页获取数据
-// @auth                      (2020/04/05  20:22)
-// @param     info             request.PageInfo
-// @return    err              error
-// @return    list             interface{}
-// @return    total            int
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: GetUserInfoList
+//@description: 分页获取数据
+//@param: info request.PageInfo
+//@return: err error, list interface{}, total int64
 
 func GetUserInfoList(info request.PageInfo) (err error, list interface{}, total int64) {
 	limit := info.PageSize
@@ -76,24 +71,22 @@ func GetUserInfoList(info request.PageInfo) (err error, list interface{}, total
 	return err, userList, total
 }
 
-// @title    SetUserAuthority
-// @description   set the authority of a certain user, 设置一个用户的权限
-// @auth                     (2020/04/05  20:22)
-// @param     uuid            UUID
-// @param     authorityId     string
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: SetUserAuthority
+//@description: 设置一个用户的权限
+//@param: uuid uuid.UUID, authorityId string
+//@return: err error
 
 func SetUserAuthority(uuid uuid.UUID, authorityId string) (err error) {
 	err = global.GVA_DB.Where("uuid = ?", uuid).First(&model.SysUser{}).Update("authority_id", authorityId).Error
 	return err
 }
 
-// @title    SetUserAuthority
-// @description   set the authority of a certain user, 设置一个用户的权限
-// @auth                     (2020/04/05  20:22)
-// @param     uuid            UUID
-// @param     authorityId     string
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: DeleteUser
+//@description: 删除用户
+//@param: id float64
+//@return: err error
 
 func DeleteUser(id float64) (err error) {
 	var user model.SysUser
@@ -101,24 +94,22 @@ func DeleteUser(id float64) (err error) {
 	return err
 }
 
-// @title    SetUserInfo
-// @description   set the authority of a certain user, 设置用户信息
-// @auth                     (2020/04/05  20:22)
-// @param     uuid            UUID
-// @param     authorityId     string
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: SetUserInfo
+//@description: 设置用户信息
+//@param: reqUser model.SysUser
+//@return: err error, user model.SysUser
 
 func SetUserInfo(reqUser model.SysUser) (err error, user model.SysUser) {
 	err = global.GVA_DB.Updates(&reqUser).Error
 	return err, reqUser
 }
 
-// @title    FindUserById
-// @description   Get user information by id, 通过id获取用户信息
-// @auth                     (2020/04/05  20:22)
-// @param     id              int
-// @return    err             error
-// @return    user            *model.SysUser
+//@author: [SliverHorn](https://github.com/SliverHorn)
+//@function: FindUserById
+//@description: 通过id获取用户信息
+//@param: id int
+//@return: err error, user *model.SysUser
 
 func FindUserById(id int) (err error, user *model.SysUser) {
 	var u model.SysUser
@@ -126,12 +117,11 @@ func FindUserById(id int) (err error, user *model.SysUser) {
 	return err, &u
 }
 
-// @title    FindUserByUuid
-// @description   Get user information by uuid, 通过uuid获取用户信息
-// @auth                     (2020/04/05  20:22)
-// @param     uuid            string
-// @return    err             error
-// @return    user            *model.SysUser
+//@author: [SliverHorn](https://github.com/SliverHorn)
+//@function: FindUserByUuid
+//@description: 通过uuid获取用户信息
+//@param: uuid string
+//@return: err error, user *model.SysUser
 
 func FindUserByUuid(uuid string) (err error, user *model.SysUser) {
 	var u model.SysUser

+ 5 - 5
server/service/sys_workflow.go

@@ -5,11 +5,11 @@ import (
 	"gin-vue-admin/model"
 )
 
-// @title    Create
-// @description   create a workflow, 创建工作流
-// @auth                     (2020/04/05  20:22)
-// @param     wk              model.SysWorkflow
-// @return                    error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: Create
+//@description: 创建工作流
+//@param: wk model.SysWorkflow
+//@return: error
 
 func Create(wk model.SysWorkflow) error {
 	err := global.GVA_DB.Create(&wk).Error

+ 30 - 0
server/utils/breakpoint_continue.go

@@ -14,6 +14,12 @@ import (
 const breakpointDir = "./breakpointDir/"
 const finishDir = "./fileDir/"
 
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: BreakPointContinue
+//@description: 断点续传
+//@param: content []byte, fileName string, contentNumber int, contentTotal int, fileMd5 string
+//@return: error, string
+
 func BreakPointContinue(content []byte, fileName string, contentNumber int, contentTotal int, fileMd5 string) (error, string) {
 	path := breakpointDir + fileMd5 + "/"
 	err := os.MkdirAll(path, os.ModePerm)
@@ -25,6 +31,12 @@ func BreakPointContinue(content []byte, fileName string, contentNumber int, cont
 
 }
 
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: CheckMd5
+//@description: 检查Md5
+//@param: content []byte, chunkMd5 string
+//@return: CanUpload bool
+
 func CheckMd5(content []byte, chunkMd5 string) (CanUpload bool) {
 	fileMd5 := MD5V(content)
 	if fileMd5 == chunkMd5 {
@@ -34,6 +46,12 @@ func CheckMd5(content []byte, chunkMd5 string) (CanUpload bool) {
 	}
 }
 
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: makeFileContent
+//@description: 创建切片内容
+//@param: content []byte, fileName string, FileDir string, contentNumber int
+//@return: error, string
+
 func makeFileContent(content []byte, fileName string, FileDir string, contentNumber int) (error, string) {
 	path := FileDir + fileName + "_" + strconv.Itoa(contentNumber)
 	f, err := os.Create(path)
@@ -49,6 +67,12 @@ func makeFileContent(content []byte, fileName string, FileDir string, contentNum
 	return nil, path
 }
 
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: makeFileContent
+//@description: 创建切片文件
+//@param: fileName string, FileMd5 string
+//@return: error, string
+
 func MakeFile(fileName string, FileMd5 string) (error, string) {
 	rd, err := ioutil.ReadDir(breakpointDir + FileMd5)
 	if err != nil {
@@ -72,6 +96,12 @@ func MakeFile(fileName string, FileMd5 string) (error, string) {
 	return nil, finishDir + fileName
 }
 
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: RemoveChunk
+//@description: 移除切片
+//@param: FileMd5 string
+//@return: error
+
 func RemoveChunk(FileMd5 string) error {
 	err := os.RemoveAll(breakpointDir + FileMd5)
 	return err

+ 204 - 0
server/utils/cmd_Task.go

@@ -0,0 +1,204 @@
+package utils
+
+import (
+	"bytes"
+	"context"
+	"fmt"
+	"io"
+	"os"
+	"os/exec"
+	"runtime"
+	"sync"
+)
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@interface_name: RunTask
+//@description: Task接口
+
+type RunTask interface {
+	AddTask()
+	RunTask()
+}
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@struct_name: T
+//@description: Task任务
+
+type T struct {
+	sync.Mutex
+
+	// 获取事件channel
+	ch chan struct{}
+
+	closeChan chan struct{}
+
+	// 记录process对象
+	p *os.Process
+
+	// 执行任务
+	f func(chan struct{}) error
+}
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@function: NewT
+//@description: T的实例化方法
+//@return: *T
+
+func NewT() *T {
+	return newT(nil)
+}
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@function: newT
+//@description:
+//@param: f func(chan struct{}) error
+//@return: *T
+
+func newT(f func(chan struct{}) error) *T {
+	t := &T{
+		Mutex:     sync.Mutex{},
+		ch:        make(chan struct{}, 1),
+		closeChan: make(chan struct{}),
+		f:         f,
+	}
+	if f == nil {
+		t.f = t.DefaultF
+	}
+	return t
+}
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@object: *T
+//@function: AddTask
+//@description: 添加任务
+
+func (t *T) AddTask() {
+	if len(t.ch) == 1 {
+		return
+	}
+	t.Lock()
+	defer t.Unlock()
+	if len(t.ch) == 1 {
+		// 代表已经有任务了
+		// 直接丢弃这次任务
+		return
+	}
+	t.ch <- struct{}{}
+}
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@object: *T
+//@function: RunTask
+//@description: 启动任务
+
+func (t *T) RunTask() {
+	fmt.Println("进入")
+	// 这里做的make 是用于关闭上一个执行的任务
+	ch := make(chan struct{})
+	// 先run服务
+	go t.f(ch)
+	for {
+		_, ok := <-t.ch
+		if !ok {
+			return
+		}
+		ch <- struct{}{}
+		// 等待上一个关闭
+		<-t.closeChan
+		go t.f(ch)
+	}
+
+}
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@object: t *T
+//@function: DefaultF
+//@description: 默认的StartFunction
+//@param: ch chan struct{}
+//@return: error
+
+func (t *T) DefaultF(ch chan struct{}) error {
+	var buildCmd *exec.Cmd
+	var cmd *exec.Cmd
+
+	// 检测系统是否有编译环境
+	_, err := exec.LookPath("go")
+	if err != nil {
+		return err
+	}
+	// build
+
+	switch runtime.GOOS {
+	case "windows":
+		buildCmd = exec.Command("go", "build", "-o", "server.exe", "main.go")
+	default:
+		buildCmd = exec.Command("go", "build", "-o", "server", "main.go")
+	}
+	//cmd = exec.Command("go", "run", "main.go")
+	err = buildCmd.Run()
+	if err != nil {
+		return err
+	}
+	fmt.Println("build 执行完成")
+	// 执行
+	switch runtime.GOOS {
+	case "windows":
+		cmd = exec.Command("server.exe")
+	default:
+		cmd = exec.Command("./server")
+	}
+
+	// 开始执行任务
+	ctx, cancel := context.WithCancel(context.Background())
+	err = t.echo(cmd, ctx)
+	<-ch
+	// 回收资源
+	fmt.Println("pid:", t.p.Pid, "->Kill")
+	err = t.p.Kill()
+	cancel()
+	// 发送关闭完成信号
+	t.closeChan <- struct{}{}
+	return err
+}
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@object: t *T
+//@function: echo
+//@description: 封装回显
+//@param: cmd *exec.Cmd, ctx context.Context
+//@return: error
+
+func (t *T) echo(cmd *exec.Cmd, ctx context.Context) error {
+	var stdoutBuf bytes.Buffer
+	stdoutIn, _ := cmd.StdoutPipe()
+	var errStdout error
+	stdout := io.MultiWriter(os.Stdout, &stdoutBuf)
+	err := cmd.Start()
+	if err != nil {
+		return err
+	}
+	go func(ctx context.Context) {
+		_, errStdout = io.Copy(stdout, stdoutIn)
+		select {
+		case <-ctx.Done():
+			return
+		default:
+		}
+	}(ctx)
+	t.p = cmd.Process
+	fmt.Println("pid", t.p.Pid)
+	go func() {
+		_ = cmd.Wait()
+		if errStdout != nil {
+			fmt.Printf("failed to capture stdout or stderr\n")
+		}
+		fmt.Printf("%s\n", string(stdoutBuf.Bytes()))
+		select {
+		case <-ctx.Done():
+			//_ = os.Stdout.Close()
+			return
+		default:
+		}
+	}()
+	return nil
+}

+ 174 - 0
server/utils/cmd_monitor.go

@@ -0,0 +1,174 @@
+package utils
+
+import (
+	"errors"
+	"fmt"
+	"github.com/fsnotify/fsnotify"
+	"io/ioutil"
+	"os"
+	"path/filepath"
+)
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@struct_name: Watch
+//@description: 监控对象
+
+type Watch struct {
+	*fsnotify.Watcher
+}
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@function: NewWatch
+//@description: Watch的实例化方法
+//@return: *Watch
+
+func NewWatch() *Watch {
+	obj, _ := fsnotify.NewWatcher()
+	return &Watch{obj}
+}
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@object: w *Watch
+//@function: Watch
+//@description: 监控对象
+//@param: path string, t *T
+//@return: error
+
+func (w *Watch) Watch(path string, t *T) error {
+	// 先转化为绝对路径
+	path, err := filepath.Abs(path)
+	if err != nil {
+		return err
+	}
+	// 判断是单个文件还是目录文件
+	fileInfo, err := os.Stat(path)
+	if err != nil {
+		return err
+	}
+	// 判断是否是目录 添加监控
+	if fileInfo.IsDir() {
+		// dir
+		err = w.watchDir(path)
+
+	} else {
+		err = w.watchFile(path)
+
+	}
+	if err != nil {
+		return err
+	}
+	c := make(chan error)
+	// 启动监控
+	go func() {
+		for {
+			select {
+			case even, ok := <-w.Events:
+				if !ok {
+					// close
+					fmt.Println("Errors close")
+					c <- errors.New("errors close")
+					return
+				}
+				// 判断事件
+				switch {
+				case even.Op&fsnotify.Create == fsnotify.Create:
+					//这里获取新创建文件的信息,如果是目录,则加入监控中
+					fmt.Println("创建文件 : ", even.Name)
+					//t.AddTask()
+					_ = w.Add(even.Name)
+				case even.Op&fsnotify.Write == fsnotify.Write:
+					fmt.Println("修改文件 : ", even.Name)
+					w.addTask(t, even.Name)
+				case even.Op&fsnotify.Remove == fsnotify.Remove || even.Op&fsnotify.Rename == fsnotify.Rename:
+					fmt.Println("删除或重命名文件 : ", even.Name)
+					_ = w.Remove(even.Name)
+					w.addTask(t, even.Name)
+				}
+			case err = <-w.Errors:
+				fmt.Println("even Error:", err)
+				c <- err
+				return
+			}
+		}
+	}()
+	return <-c
+
+}
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@object: w *Watch
+//@function: watchDir
+//@description: 处理监控目录
+//@param: path string
+//@return: error
+
+func (w *Watch) watchDir(path string) error {
+	// 先将自己添加到监控
+	err := w.Add(path)
+
+	if err != nil {
+		return err
+	}
+	fileSlice, err := ioutil.ReadDir(path)
+	if err != nil {
+		return err
+	}
+	for _, f := range fileSlice {
+		fPath := filepath.Join(path, f.Name())
+		if !f.IsDir() {
+			// 判断是否可监控的文件
+			if chickPower(fPath) {
+				err = w.watchFile(fPath)
+				if err != nil {
+					return err
+				}
+			}
+		} else {
+			err := w.watchDir(fPath)
+			if err != nil {
+				return err
+			}
+		}
+	}
+	return err
+}
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@object: w *Watch
+//@function: watchDir
+//@description: 处理监控单文件
+//@param: path string
+//@return: error
+
+func (w *Watch) watchFile(path string) error {
+	var err error
+	if chickPower(path) {
+		err = w.Add(path)
+	}
+	return err
+}
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@function: chickPower
+//@description: 判断是否在可控范围内
+//@param: path string
+//@return: error
+
+func chickPower(name string) bool {
+	name = filepath.Ext(name)
+	return name == ".go" || name == ".yaml"
+}
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@object: w *Watch
+//@function: addTask
+//@description: 偏函数 简化发送任务
+//@param: path string
+//@return: error
+
+func (w *Watch) addTask(t *T, name string) {
+	if chickPower(name) {
+		fmt.Println("Add Task->>>>>>")
+		t.AddTask()
+	}
+}

+ 10 - 10
server/utils/directory.go

@@ -6,11 +6,11 @@ import (
 	"os"
 )
 
-// @title    PathExists
-// @description   文件目录是否存在
-// @auth                     (2020/04/05  20:22)
-// @param     path            string
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: PathExists
+//@description: 文件目录是否存在
+//@param: path string
+//@return: bool, error
 
 func PathExists(path string) (bool, error) {
 	_, err := os.Stat(path)
@@ -23,11 +23,11 @@ func PathExists(path string) (bool, error) {
 	return false, err
 }
 
-// @title    createDir
-// @description   批量创建文件夹
-// @auth                     (2020/04/05  20:22)
-// @param     dirs            string
-// @return    err             error
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: CreateDir
+//@description: 批量创建文件夹
+//@param: dirs ...string
+//@return: err error
 
 func CreateDir(dirs ...string) (err error) {
 	for _, v := range dirs {

+ 24 - 1
server/utils/email.go

@@ -11,12 +11,23 @@ import (
 	"github.com/jordan-wright/email"
 )
 
+//@author: [maplepie](https://github.com/maplepie)
+//@function: Email
+//@description: Email发送方法
+//@param: subject string, body string
+//@return: error
+
 func Email(subject string, body string) error {
 	to := strings.Split(global.GVA_CONFIG.Email.To, ",")
 	return send(to, subject, body)
 }
 
-// ErrorToEmail Error 发送邮件
+//@author: [SliverHorn](https://github.com/SliverHorn)
+//@function: ErrorToEmail
+//@description: 给email中间件错误发送邮件到指定邮箱
+//@param: subject string, body string
+//@return: error
+
 func ErrorToEmail(subject string, body string) error {
 	to := strings.Split(global.GVA_CONFIG.Email.To, ",")
 	if to[len(to)-1] == "" { // 判断切片的最后一个元素是否为空,为空则移除
@@ -25,11 +36,23 @@ func ErrorToEmail(subject string, body string) error {
 	return send(to, subject, body)
 }
 
+//@author: [maplepie](https://github.com/maplepie)
+//@function: EmailTest
+//@description: Email测试方法
+//@param: subject string, body string
+//@return: error
+
 func EmailTest(subject string, body string) error {
 	to := []string{global.GVA_CONFIG.Email.From}
 	return send(to, subject, body)
 }
 
+//@author: [maplepie](https://github.com/maplepie)
+//@function: send
+//@description: Email发送方法
+//@param: subject string, body string
+//@return: error
+
 func send(to []string, subject string, body string) error {
 	from := global.GVA_CONFIG.Email.From
 	nickname := global.GVA_CONFIG.Email.Nickname

+ 41 - 0
server/utils/file_operations.go

@@ -0,0 +1,41 @@
+package utils
+
+import (
+	"os"
+	"path/filepath"
+)
+
+//@author: [songzhibin97](https://github.com/songzhibin97)
+//@function: FileMove
+//@description: 文件移动供外部调用
+//@param: src string, dst string(src: 源位置,绝对路径or相对路径, dst: 目标位置,绝对路径or相对路径,必须为文件夹)
+//@return: err error
+
+func FileMove(src string, dst string) (err error) {
+	if dst == "" {
+		return nil
+	}
+	src, err = filepath.Abs(src)
+	if err != nil {
+		return err
+	}
+	dst, err = filepath.Abs(dst)
+	if err != nil {
+		return err
+	}
+	var revoke = false
+	dir := filepath.Dir(dst)
+Redirect:
+	_, err = os.Stat(dir)
+	if err != nil {
+		err = os.MkdirAll(dir, 0755)
+		if err != nil {
+			return err
+		}
+		if !revoke {
+			revoke = true
+			goto Redirect
+		}
+	}
+	return os.Rename(src, dst)
+}

+ 12 - 2
server/utils/fmt_plus.go

@@ -6,7 +6,12 @@ import (
 	"strings"
 )
 
-// 利用反射将结构体转化为map
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: StructToMap
+//@description: 利用反射将结构体转化为map
+//@param: obj interface{}
+//@return: map[string]interface{}
+
 func StructToMap(obj interface{}) map[string]interface{} {
 	obj1 := reflect.TypeOf(obj)
 	obj2 := reflect.ValueOf(obj)
@@ -18,7 +23,12 @@ func StructToMap(obj interface{}) map[string]interface{} {
 	return data
 }
 
-//将数组格式化为字符串
+//@author: [piexlmax](https://github.com/piexlmax)
+//@function: ArrayToString
+//@description: 将数组格式化为字符串
+//@param: array []interface{}
+//@return: string
+
 func ArrayToString(array []interface{}) string {
 	return strings.Replace(strings.Trim(fmt.Sprint(array), "[]"), " ", ",", -1)
 }

Some files were not shown because too many files changed in this diff