diff --git a/server/config.yaml b/server/config.yaml index 1d38f0463bc00930fe6b326767c57503dca0fe2b..b336c7cce9daea6b9ae6f2d413b50887c13e0cc7 100644 --- a/server/config.yaml +++ b/server/config.yaml @@ -56,7 +56,7 @@ mysql: config: 'charset=utf8mb4&parseTime=True&loc=Local' db-name: 'qmPlus' username: 'root' - password: 'root123' + password: 'Aa@6447985' max-idle-conns: 10 max-open-conns: 100 log-mode: false diff --git a/server/core/server.go b/server/core/server.go index 3bbba3c4963a4c83bd96a682eb754ec08909e6df..65d22a2070a8888293db174913f267e7584b736a 100644 --- a/server/core/server.go +++ b/server/core/server.go @@ -29,7 +29,7 @@ func RunWindowsServer() { fmt.Printf(` 欢迎使用 Gin-Vue-Admin - 当前版本:V2.3.6 + 当前版本: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 diff --git a/server/initialize/router.go b/server/initialize/router.go index 59e246de1e1695702e39bdd0717a05429b3f2e5e..9751770e09e12745693c9a7919787a3cad05a278 100644 --- a/server/initialize/router.go +++ b/server/initialize/router.go @@ -29,7 +29,7 @@ func Routers() *gin.Engine { router.InitBaseRouter(PublicGroup) // 注册基础功能路由 不做鉴权 } PrivateGroup := Router.Group("") - PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()).Use(middleware.OperationRecord()) + PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()) { router.InitApiRouter(PrivateGroup) // 注册功能api路由 router.InitJwtRouter(PrivateGroup) // jwt相关路由 diff --git a/server/middleware/operation.go b/server/middleware/operation.go index 41bcb883c958af2c62e176e89f0322f0ab3f68d7..3c4ea2b63d70a091d440b19ad8b29dc1d08a3192 100644 --- a/server/middleware/operation.go +++ b/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{}, diff --git a/server/router/exp_customer.go b/server/router/exp_customer.go index 8195d0924eb54bb6ac32ab82bc7455718f9b1ccc..b0ae657b9b3977e9c8b449a2e4e103f55c55abaa 100644 --- a/server/router/exp_customer.go +++ b/server/router/exp_customer.go @@ -2,11 +2,12 @@ package router import ( "gin-vue-admin/api/v1" + "gin-vue-admin/middleware" "github.com/gin-gonic/gin" ) func InitCustomerRouter(Router *gin.RouterGroup) { - ApiRouter := Router.Group("customer") + ApiRouter := Router.Group("customer").Use(middleware.OperationRecord()) { ApiRouter.POST("customer", v1.CreateExaCustomer) // 创建客户 ApiRouter.PUT("customer", v1.UpdateExaCustomer) // 更新客户 diff --git a/server/router/sys_api.go b/server/router/sys_api.go index ffc6b7e6bfd7227329fec182df6204629482446b..8bb7f2d402acd67e9214b85c506881d9a258bccd 100644 --- a/server/router/sys_api.go +++ b/server/router/sys_api.go @@ -2,11 +2,12 @@ package router import ( "gin-vue-admin/api/v1" + "gin-vue-admin/middleware" "github.com/gin-gonic/gin" ) func InitApiRouter(Router *gin.RouterGroup) { - ApiRouter := Router.Group("api") + ApiRouter := Router.Group("api").Use(middleware.OperationRecord()) { ApiRouter.POST("createApi", v1.CreateApi) // 创建Api ApiRouter.POST("deleteApi", v1.DeleteApi) // 删除Api diff --git a/server/router/sys_authority.go b/server/router/sys_authority.go index 313981ebf69de8903ea92b65a48599fbea0d97a8..ccbdd3358f51a1df3e5fe11698b026ae79296ba2 100644 --- a/server/router/sys_authority.go +++ b/server/router/sys_authority.go @@ -2,11 +2,12 @@ package router import ( "gin-vue-admin/api/v1" + "gin-vue-admin/middleware" "github.com/gin-gonic/gin" ) func InitAuthorityRouter(Router *gin.RouterGroup) { - AuthorityRouter := Router.Group("authority") + AuthorityRouter := Router.Group("authority").Use(middleware.OperationRecord()) { AuthorityRouter.POST("createAuthority", v1.CreateAuthority) // 创建角色 AuthorityRouter.POST("deleteAuthority", v1.DeleteAuthority) // 删除角色 diff --git a/server/router/sys_casbin.go b/server/router/sys_casbin.go index f69c575b60ec91514a12d3679cd0c167c79a44ef..6896af8ac74b63c4884c43b7881a828f71a39852 100644 --- a/server/router/sys_casbin.go +++ b/server/router/sys_casbin.go @@ -2,11 +2,12 @@ package router import ( "gin-vue-admin/api/v1" + "gin-vue-admin/middleware" "github.com/gin-gonic/gin" ) func InitCasbinRouter(Router *gin.RouterGroup) { - CasbinRouter := Router.Group("casbin") + CasbinRouter := Router.Group("casbin").Use(middleware.OperationRecord()) { CasbinRouter.POST("updateCasbin", v1.UpdateCasbin) CasbinRouter.POST("getPolicyPathByAuthorityId", v1.GetPolicyPathByAuthorityId) diff --git a/server/router/sys_dictionary.go b/server/router/sys_dictionary.go index 261de76279aac23e7e1a6453affb858cd629accc..c9007642c2b02dd14e1e69c8e9fd38b56ea411c3 100644 --- a/server/router/sys_dictionary.go +++ b/server/router/sys_dictionary.go @@ -2,11 +2,12 @@ package router import ( "gin-vue-admin/api/v1" + "gin-vue-admin/middleware" "github.com/gin-gonic/gin" ) func InitSysDictionaryRouter(Router *gin.RouterGroup) { - SysDictionaryRouter := Router.Group("sysDictionary") + SysDictionaryRouter := Router.Group("sysDictionary").Use(middleware.OperationRecord()) { SysDictionaryRouter.POST("createSysDictionary", v1.CreateSysDictionary) // 新建SysDictionary SysDictionaryRouter.DELETE("deleteSysDictionary", v1.DeleteSysDictionary) // 删除SysDictionary diff --git a/server/router/sys_dictionary_detail.go b/server/router/sys_dictionary_detail.go index b83d80a7a7821ec40d4897425a9382d1ad06ba4d..b324b32202e8da4756d6b5ebf97e60b4259b0e7d 100644 --- a/server/router/sys_dictionary_detail.go +++ b/server/router/sys_dictionary_detail.go @@ -2,11 +2,12 @@ package router import ( "gin-vue-admin/api/v1" + "gin-vue-admin/middleware" "github.com/gin-gonic/gin" ) func InitSysDictionaryDetailRouter(Router *gin.RouterGroup) { - SysDictionaryDetailRouter := Router.Group("sysDictionaryDetail") + SysDictionaryDetailRouter := Router.Group("sysDictionaryDetail").Use(middleware.OperationRecord()) { SysDictionaryDetailRouter.POST("createSysDictionaryDetail", v1.CreateSysDictionaryDetail) // 新建SysDictionaryDetail SysDictionaryDetailRouter.DELETE("deleteSysDictionaryDetail", v1.DeleteSysDictionaryDetail) // 删除SysDictionaryDetail diff --git a/server/router/sys_email.go b/server/router/sys_email.go index 8b0acc2193411f7d8c9af19fa61eb3e11f0eb991..5f215dd738de2983906b9f037fbe83a0cc7f38fe 100644 --- a/server/router/sys_email.go +++ b/server/router/sys_email.go @@ -2,11 +2,12 @@ package router import ( "gin-vue-admin/api/v1" + "gin-vue-admin/middleware" "github.com/gin-gonic/gin" ) func InitEmailRouter(Router *gin.RouterGroup) { - UserRouter := Router.Group("email") + UserRouter := Router.Group("email").Use(middleware.OperationRecord()) { UserRouter.POST("emailTest", v1.EmailTest) // 发送测试邮件 } diff --git a/server/router/sys_jwt.go b/server/router/sys_jwt.go index 1d69c524229509f462c6b40332d0687effe8f993..f2a33caff25283e38815d1ebac544a43543b3cdd 100644 --- a/server/router/sys_jwt.go +++ b/server/router/sys_jwt.go @@ -2,11 +2,12 @@ package router import ( "gin-vue-admin/api/v1" + "gin-vue-admin/middleware" "github.com/gin-gonic/gin" ) func InitJwtRouter(Router *gin.RouterGroup) { - ApiRouter := Router.Group("jwt") + ApiRouter := Router.Group("jwt").Use(middleware.OperationRecord()) { ApiRouter.POST("jsonInBlacklist", v1.JsonInBlacklist) // jwt加入黑名单 } diff --git a/server/router/sys_menu.go b/server/router/sys_menu.go index 0bef2edab1d52650eebd89ef665f2f2c16adb578..3fdc177363691891e531bad4efbe8a4abf2fa2ca 100644 --- a/server/router/sys_menu.go +++ b/server/router/sys_menu.go @@ -2,11 +2,12 @@ package router import ( "gin-vue-admin/api/v1" + "gin-vue-admin/middleware" "github.com/gin-gonic/gin" ) func InitMenuRouter(Router *gin.RouterGroup) (R gin.IRoutes) { - MenuRouter := Router.Group("menu") + MenuRouter := Router.Group("menu").Use(middleware.OperationRecord()) { MenuRouter.POST("getMenu", v1.GetMenu) // 获取菜单树 MenuRouter.POST("getMenuList", v1.GetMenuList) // 分页获取基础menu列表 diff --git a/server/router/sys_operation_record.go b/server/router/sys_operation_record.go index 07b175a6a5eb228ed0aeda7663be26abf27d69e8..972ecbb19996267a4324beb579cb2eae4451729f 100644 --- a/server/router/sys_operation_record.go +++ b/server/router/sys_operation_record.go @@ -2,17 +2,18 @@ package router import ( "gin-vue-admin/api/v1" + "gin-vue-admin/middleware" "github.com/gin-gonic/gin" ) func InitSysOperationRecordRouter(Router *gin.RouterGroup) { - SysOperationRecordRouter := Router.Group("sysOperationRecord") + 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列表 } } diff --git a/server/router/sys_system.go b/server/router/sys_system.go index 215af6995c8196eb8f934a7b991350dd41f8dc15..d6c2e5a42c15090ef5cc0db2c6035b3a7fa42312 100644 --- a/server/router/sys_system.go +++ b/server/router/sys_system.go @@ -2,11 +2,12 @@ package router import ( "gin-vue-admin/api/v1" + "gin-vue-admin/middleware" "github.com/gin-gonic/gin" ) func InitSystemRouter(Router *gin.RouterGroup) { - SystemRouter := Router.Group("system") + SystemRouter := Router.Group("system").Use(middleware.OperationRecord()) { SystemRouter.POST("getSystemConfig", v1.GetSystemConfig) // 获取配置文件内容 SystemRouter.POST("setSystemConfig", v1.SetSystemConfig) // 设置配置文件内容 diff --git a/server/router/sys_user.go b/server/router/sys_user.go index 88c258dcdd07ac194e4866bb7b310fcfcadadfe4..d6d22a8ab3de50943f1155c07c47fa573b19c7d9 100644 --- a/server/router/sys_user.go +++ b/server/router/sys_user.go @@ -2,11 +2,12 @@ package router import ( "gin-vue-admin/api/v1" + "gin-vue-admin/middleware" "github.com/gin-gonic/gin" ) func InitUserRouter(Router *gin.RouterGroup) { - UserRouter := Router.Group("user") + UserRouter := Router.Group("user").Use(middleware.OperationRecord()) { UserRouter.POST("register", v1.Register) UserRouter.POST("changePassword", v1.ChangePassword) // 修改密码 diff --git a/server/router/sys_workflow.go b/server/router/sys_workflow.go index cad92d574e03ac4b1aa5885e17cb1a98d877c236..6bfa3376b75adfc5817e911b4ccd418134e91514 100644 --- a/server/router/sys_workflow.go +++ b/server/router/sys_workflow.go @@ -2,11 +2,12 @@ package router import ( "gin-vue-admin/api/v1" + "gin-vue-admin/middleware" "github.com/gin-gonic/gin" ) func InitWorkflowRouter(Router *gin.RouterGroup) { - WorkflowRouter := Router.Group("workflow") + WorkflowRouter := Router.Group("workflow").Use(middleware.OperationRecord()) { WorkflowRouter.POST("createWorkFlow", v1.CreateWorkFlow) // 创建工作流 } diff --git a/server/service/sys_auto_code.go b/server/service/sys_auto_code.go index afeca1ebf6c4d9f333f02b1ef79b476f094eb247..d6fdf0b3e92e012028742a56594f12f3bf820cb5 100644 --- a/server/service/sys_auto_code.go +++ b/server/service/sys_auto_code.go @@ -209,7 +209,6 @@ func addAutoMoveFile(data *tplData) { } } - //@author: [piexlmax](https://github.com/piexlmax) //@author: [SliverHorn](https://github.com/SliverHorn) //@function: CreateApi @@ -259,14 +258,13 @@ func AutoCreateApi(a *model.AutoCodeStruct) (err error) { err = global.GVA_DB.Transaction(func(tx *gorm.DB) error { for _, v := range apiList { var api model.SysApi - if err := tx.Where("path = ? AND method = ?", v.Path, v.Method).First(&api).Error; err != nil { - return err - } - if err := tx.Create(&v).Error; err != nil { // 遇到错误时回滚事务 - return err + 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 -} \ No newline at end of file +} diff --git a/web/src/main.js b/web/src/main.js index 0e6cca6ff92da2e63b49299ec8c460ebcf17efc5..c1cdb6fadc9acec08bd30f5492e0f9285d4a07c9 100644 --- a/web/src/main.js +++ b/web/src/main.js @@ -66,7 +66,7 @@ Vue.prototype.$echarts = echarts; console.log(` 欢迎使用 Gin-Vue-Admin - 当前版本:V2.3.6 + 当前版本: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