From 696f394041688debe4c99db2ea6b75c9c719653c Mon Sep 17 00:00:00 2001 From: SliverHorn <503551462@qq.com> Date: Mon, 31 Aug 2020 16:05:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3,=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=96=B0=E5=A2=9E=E8=8F=9C=E5=8D=95=E7=9A=84name?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98,=E4=BF=AE=E5=A4=8Dsys=5Fus?= =?UTF-8?q?er=E6=B3=A8=E5=86=8C,=E5=88=A0=E9=99=A4=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E4=B8=8Ecasb=20RBAC=20RESTFUL=E6=B5=8B?= =?UTF-8?q?=E8=AF=95,=E5=A4=9A=E4=BD=99=E6=95=B0=E6=8D=AE=E7=9A=84?= =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/GORMV2接口测试文档.md | 47 +++++++------- server/api/v1/sys_casbin.go | 14 ----- server/api/v1/sys_operation_record.go | 19 ------ server/model/sys_api.go | 86 +++++++++++++------------- server/model/sys_casbin.go | 3 - server/router/sys_casbin.go | 1 - server/router/sys_operation_record.go | 1 - server/service/sys_menu.go | 7 +-- server/service/sys_operation_record.go | 11 ---- server/service/sys_user.go | 14 ++--- 10 files changed, 71 insertions(+), 132 deletions(-) diff --git a/server/GORMV2接口测试文档.md b/server/GORMV2接口测试文档.md index 6e9a1a4a..1e926003 100644 --- a/server/GORMV2接口测试文档.md +++ b/server/GORMV2接口测试文档.md @@ -13,16 +13,15 @@ | /authority/getAuthorityList | 获取角色列表 | √ | SliverHorn | | /menu/getMenu | 获取菜单树 | √ | SliverHorn | | /menu/getMenuList | 分页获取基础menu列表 | √ | SliverHorn | -| /menu/addBaseMenu | 新增菜单 | | | +| /menu/addBaseMenu | 新增菜单 | √ | SliverHorn | | /menu/getBaseMenuTree | 获取用户动态路由 | √ | SliverHorn | | /menu/addMenuAuthority | 增加menu和角色关联关系 | √ | SliverHorn | | /menu/getMenuAuthority | 获取指定角色menu | √ | SliverHorn | -| /menu/deleteBaseMenu | 删除菜单 | | | -| /menu/updateBaseMenu | 更新菜单 | | | +| /menu/deleteBaseMenu | 删除菜单 | √ | SliverHorn | +| /menu/updateBaseMenu | 更新菜单 | √ | SliverHorn | | /menu/getBaseMenuById | 根据id获取菜单 | √ | SliverHorn | -| /user/changePassword | 修改密码 | | | +| /user/changePassword | 修改密码 | √ | SliverHorn | | /user/uploadHeaderImg | 上传头像 | √ | SliverHorn | -| /user/getInfoList | 分页获取用户列表 | | | | /user/getUserList | 获取用户列表 | √ | SliverHorn | | /user/setUserAuthority | 修改用户角色 | √ | SliverHorn | | /fileUploadAndDownload/upload | 文件上传示例 | √ | SliverHorn | @@ -30,17 +29,17 @@ | /casbin/updateCasbin | 更改角色api权限 | √ | SliverHorn | | /casbin/getPolicyPathByAuthorityId | 获取权限列表 | √ | SliverHorn | | /fileUploadAndDownload/deleteFile | 删除文件 | √ | SliverHorn | -| /jwt/jsonInBlacklist | jwt加入黑名单 | | | +| /jwt/jsonInBlacklist | jwt加入黑名单 | √ | SliverHorn | | /authority/setDataAuthority | 设置角色资源权限 | √ | SliverHorn | -| /system/getSystemConfig | 获取配置文件内容 | | | -| /system/setSystemConfig | 设置配置文件内容 | | | +| /system/getSystemConfig | 获取配置文件内容 | √ | SliverHorn | +| /system/setSystemConfig | 设置配置文件内容 | √ | SliverHorn | | /customer/customer | 创建客户 | √ | SliverHorn | -| /customer/customer | 更新客户 | | | +| /customer/customer | 更新客户 | √ | SliverHorn | | /customer/customer | 删除客户 | √ | SliverHorn | -| /customer/customer | 获取单一客户 | | | +| /customer/customer | 获取单一客户 | √ | SliverHorn | | /customer/customerList | 获取客户列表 | √ | SliverHorn | | /casbin/casbinTest/:pathParam | RESTFUL模式测试 | | | -| /autoCode/createTemp | 自动化代码 | | | +| /autoCode/createTemp | 自动化代码 | √ | SliverHorn | | /authority/updateAuthority | 更新角色信息 | √ | SliverHorn | | /authority/copyAuthority | 拷贝角色 | √ | SliverHorn | | /user/deleteUser | 删除用户 | √ | SliverHorn | @@ -62,10 +61,10 @@ | /autoCode/getTables | 获取数据库表 | √ | SliverHorn | | /autoCode/getDB | 获取所有数据库 | √ | SliverHorn | | /autoCode/getColume | 获取所选table的所有字段 | √ | SliverHorn | -| /sysOperationRecord/deleteSysOperationRecordByIds | 批量删除操作历史 | | | -| /simpleUploader/upload | 插件版分片上传 | | | -| /simpleUploader/checkFileMd5 | 文件完整度验证 | | | -| /simpleUploader/mergeFileMd5 | 上传完成合并文件 | | | +| /sysOperationRecord/deleteSysOperationRecordByIds | 批量删除操作历史 | √ | SliverHorn | +| /simpleUploader/upload | 插件版分片上传 | √ | SliverHorn | +| /simpleUploader/checkFileMd5 | 文件完整度验证 | √ | SliverHorn | +| /simpleUploader/mergeFileMd5 | 上传完成合并文件 | √ | SliverHorn | ### Gorm V2 Vs Gorm V1 - in查询,v2不需要括号了 @@ -87,17 +86,13 @@ db.Where("name IN (?)", []string{"jinzhu", "jinzhu 2"}).Find(&users) // V2版本代码(https://github.com/flipped-aurora/gin-vue-admin/blob/gva_gormv2_dev/server/service/sys_user.go) func Register(u model.SysUser) (err error, userInter model.SysUser) { var user model.SysUser - // 判断用户名是否注册 - notRegister := errors.Is(global.GVA_DB.Where("username = ?", u.Username).First(&user).Error, gorm.ErrRecordNotFound) - // notRegister为false表明读取到了 不能注册 - if !notRegister { - return errors.New("用户名已注册"), userInter - } else { - // 否则 附加uuid 密码md5简单加密 注册 - u.Password = utils.MD5V([]byte(u.Password)) - u.UUID = uuid.NewV4() - err = global.GVA_DB.Create(&u).Error - } + if !errors.Is(global.GVA_DB.Where("username = ?", u.Username).First(&user).Error, gorm.ErrRecordNotFound){ // 判断用户名是否注册 + return errors.New("用户名已注册"), userInter + } + // 否则 附加uuid 密码md5简单加密 注册 + u.Password = utils.MD5V([]byte(u.Password)) + u.UUID = uuid.NewV4() + err = global.GVA_DB.Create(&u).Error return err, u } // V1版本Register(https://github.com/flipped-aurora/gin-vue-admin/blob/master/server/service/sys_user.go) diff --git a/server/api/v1/sys_casbin.go b/server/api/v1/sys_casbin.go index abe0c65e..96d087b9 100644 --- a/server/api/v1/sys_casbin.go +++ b/server/api/v1/sys_casbin.go @@ -54,17 +54,3 @@ func GetPolicyPathByAuthorityId(c *gin.Context) { response.OkWithData(resp.PolicyPathResponse{Paths: paths}, c) } -// @Tags casbin -// @Summary casb RBAC RESTFUL测试路由 -// @Security ApiKeyAuth -// @accept application/json -// @Produce application/json -// @Param data body request.CasbinInReceive true "获取权限列表" -// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" -// @Router /casbin/CasbinTest [get] -func CasbinTest(c *gin.Context) { - // 测试restful以及占位符代码 随意书写 - pathParam := c.Param("pathParam") - query := c.Query("query") - response.OkDetailed(gin.H{"pathParam": pathParam, "query": query}, "获取规则成功", c) -} diff --git a/server/api/v1/sys_operation_record.go b/server/api/v1/sys_operation_record.go index 35b95788..cedb027b 100644 --- a/server/api/v1/sys_operation_record.go +++ b/server/api/v1/sys_operation_record.go @@ -67,25 +67,6 @@ func DeleteSysOperationRecordByIds(c *gin.Context) { } } -// @Tags SysOperationRecord -// @Summary 更新SysOperationRecord -// @Security ApiKeyAuth -// @accept application/json -// @Produce application/json -// @Param data body model.SysOperationRecord true "更新SysOperationRecord" -// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" -// @Router /sysOperationRecord/updateSysOperationRecord [put] -func UpdateSysOperationRecord(c *gin.Context) { - var sysOperationRecord model.SysOperationRecord - _ = c.ShouldBindJSON(&sysOperationRecord) - err := service.UpdateSysOperationRecord(&sysOperationRecord) - if err != nil { - response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c) - } else { - response.OkWithMessage("更新成功", c) - } -} - // @Tags SysOperationRecord // @Summary 用id查询SysOperationRecord // @Security ApiKeyAuth diff --git a/server/model/sys_api.go b/server/model/sys_api.go index d454b303..2ad4c400 100644 --- a/server/model/sys_api.go +++ b/server/model/sys_api.go @@ -37,49 +37,47 @@ func SysApiData() []SysApi { {gorm.Model{ID: 20, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getBaseMenuById", "根据id获取菜单", "menu", "POST"}, {gorm.Model{ID: 21, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/changePassword", "修改密码", "user", "POST"}, {gorm.Model{ID: 22, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/uploadHeaderImg", "上传头像", "user", "POST"}, - {gorm.Model{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/getInfoList", "分页获取用户列表", "user", "POST"}, - {gorm.Model{ID: 24, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/getUserList", "获取用户列表", "user", "POST"}, - {gorm.Model{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/setUserAuthority", "修改用户角色", "user", "POST"}, - {gorm.Model{ID: 26, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/upload", "文件上传示例", "fileUploadAndDownload", "POST"}, - {gorm.Model{ID: 27, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/getFileList", "获取上传文件列表", "fileUploadAndDownload", "POST"}, - {gorm.Model{ID: 28, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/updateCasbin", "更改角色api权限", "casbin", "POST"}, - {gorm.Model{ID: 29, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/getPolicyPathByAuthorityId", "获取权限列表", "casbin", "POST"}, - {gorm.Model{ID: 30, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/deleteFile", "删除文件", "fileUploadAndDownload", "POST"}, - {gorm.Model{ID: 31, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/jwt/jsonInBlacklist", "jwt加入黑名单", "jwt", "POST"}, - {gorm.Model{ID: 32, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/setDataAuthority", "设置角色资源权限", "authority", "POST"}, - {gorm.Model{ID: 33, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/getSystemConfig", "获取配置文件内容", "system", "POST"}, - {gorm.Model{ID: 34, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/setSystemConfig", "设置配置文件内容", "system", "POST"}, - {gorm.Model{ID: 35, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "创建客户", "customer", "POST"}, - {gorm.Model{ID: 36, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "更新客户", "customer", "PUT"}, - {gorm.Model{ID: 37, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "删除客户", "customer", "DELETE"}, - {gorm.Model{ID: 38, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "获取单一客户", "customer", "GET"}, - {gorm.Model{ID: 39, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customerList", "获取客户列表", "customer", "GET"}, - {gorm.Model{ID: 40, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/casbinTest/:pathParam", "RESTFUL模式测试", "casbin", "GET"}, - {gorm.Model{ID: 41, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/createTemp", "自动化代码", "autoCode", "POST"}, - {gorm.Model{ID: 42, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/updateAuthority", "更新角色信息", "authority", "PUT"}, - {gorm.Model{ID: 43, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/copyAuthority", "拷贝角色", "authority", "POST"}, - {gorm.Model{ID: 44, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/deleteUser", "删除用户", "user", "DELETE"}, - {gorm.Model{ID: 45, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/createSysDictionaryDetail", "新增字典内容", "sysDictionaryDetail", "POST"}, - {gorm.Model{ID: 46, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/deleteSysDictionaryDetail", "删除字典内容", "sysDictionaryDetail", "DELETE"}, - {gorm.Model{ID: 47, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/updateSysDictionaryDetail", "更新字典内容", "sysDictionaryDetail", "PUT"}, - {gorm.Model{ID: 48, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/findSysDictionaryDetail", "根据ID获取字典内容", "sysDictionaryDetail", "GET"}, - {gorm.Model{ID: 49, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/getSysDictionaryDetailList", "获取字典内容列表", "sysDictionaryDetail", "GET"}, - {gorm.Model{ID: 50, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/createSysDictionary", "新增字典", "sysDictionary", "POST"}, - {gorm.Model{ID: 51, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/deleteSysDictionary", "删除字典", "sysDictionary", "DELETE"}, - {gorm.Model{ID: 52, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/updateSysDictionary", "更新字典", "sysDictionary", "PUT"}, - {gorm.Model{ID: 53, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/findSysDictionary", "根据ID获取字典", "sysDictionary", "GET"}, - {gorm.Model{ID: 54, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/getSysDictionaryList", "获取字典列表", "sysDictionary", "GET"}, - {gorm.Model{ID: 55, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/createSysOperationRecord", "新增操作记录", "sysOperationRecord", "POST"}, - {gorm.Model{ID: 56, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/deleteSysOperationRecord", "删除操作记录", "sysOperationRecord", "DELETE"}, - {gorm.Model{ID: 57, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/updateSysOperationRecord", "更新操作记录", "sysOperationRecord", "PUT"}, - {gorm.Model{ID: 58, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/findSysOperationRecord", "根据ID获取操作记录", "sysOperationRecord", "GET"}, - {gorm.Model{ID: 59, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/getSysOperationRecordList", "获取操作记录列表", "sysOperationRecord", "GET"}, - {gorm.Model{ID: 60, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getTables", "获取数据库表", "autoCode", "GET"}, - {gorm.Model{ID: 61, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getDB", "获取所有数据库", "autoCode", "GET"}, - {gorm.Model{ID: 62, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getColume", "获取所选table的所有字段", "autoCode", "GET"}, - {gorm.Model{ID: 63, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/deleteSysOperationRecordByIds", "批量删除操作历史", "sysOperationRecord", "DELETE"}, - {gorm.Model{ID: 64, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/upload", "插件版分片上传", "simpleUploader", "POST"}, - {gorm.Model{ID: 65, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/checkFileMd5", "文件完整度验证", "simpleUploader", "GET"}, - {gorm.Model{ID: 66, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/mergeFileMd5", "上传完成合并文件", "simpleUploader", "GET"}, + {gorm.Model{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/getUserList", "获取用户列表", "user", "POST"}, + {gorm.Model{ID: 24, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/setUserAuthority", "修改用户角色", "user", "POST"}, + {gorm.Model{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/upload", "文件上传示例", "fileUploadAndDownload", "POST"}, + {gorm.Model{ID: 26, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/getFileList", "获取上传文件列表", "fileUploadAndDownload", "POST"}, + {gorm.Model{ID: 27, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/updateCasbin", "更改角色api权限", "casbin", "POST"}, + {gorm.Model{ID: 28, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/getPolicyPathByAuthorityId", "获取权限列表", "casbin", "POST"}, + {gorm.Model{ID: 29, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/deleteFile", "删除文件", "fileUploadAndDownload", "POST"}, + {gorm.Model{ID: 30, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/jwt/jsonInBlacklist", "jwt加入黑名单", "jwt", "POST"}, + {gorm.Model{ID: 31, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/setDataAuthority", "设置角色资源权限", "authority", "POST"}, + {gorm.Model{ID: 32, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/getSystemConfig", "获取配置文件内容", "system", "POST"}, + {gorm.Model{ID: 33, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/setSystemConfig", "设置配置文件内容", "system", "POST"}, + {gorm.Model{ID: 34, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "创建客户", "customer", "POST"}, + {gorm.Model{ID: 35, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "更新客户", "customer", "PUT"}, + {gorm.Model{ID: 36, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "删除客户", "customer", "DELETE"}, + {gorm.Model{ID: 37, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "获取单一客户", "customer", "GET"}, + {gorm.Model{ID: 38, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customerList", "获取客户列表", "customer", "GET"}, + {gorm.Model{ID: 39, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/casbinTest/:pathParam", "RESTFUL模式测试", "casbin", "GET"}, + {gorm.Model{ID: 40, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/createTemp", "自动化代码", "autoCode", "POST"}, + {gorm.Model{ID: 41, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/updateAuthority", "更新角色信息", "authority", "PUT"}, + {gorm.Model{ID: 42, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/copyAuthority", "拷贝角色", "authority", "POST"}, + {gorm.Model{ID: 43, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/deleteUser", "删除用户", "user", "DELETE"}, + {gorm.Model{ID: 44, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/createSysDictionaryDetail", "新增字典内容", "sysDictionaryDetail", "POST"}, + {gorm.Model{ID: 45, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/deleteSysDictionaryDetail", "删除字典内容", "sysDictionaryDetail", "DELETE"}, + {gorm.Model{ID: 46, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/updateSysDictionaryDetail", "更新字典内容", "sysDictionaryDetail", "PUT"}, + {gorm.Model{ID: 47, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/findSysDictionaryDetail", "根据ID获取字典内容", "sysDictionaryDetail", "GET"}, + {gorm.Model{ID: 48, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/getSysDictionaryDetailList", "获取字典内容列表", "sysDictionaryDetail", "GET"}, + {gorm.Model{ID: 49, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/createSysDictionary", "新增字典", "sysDictionary", "POST"}, + {gorm.Model{ID: 50, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/deleteSysDictionary", "删除字典", "sysDictionary", "DELETE"}, + {gorm.Model{ID: 51, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/updateSysDictionary", "更新字典", "sysDictionary", "PUT"}, + {gorm.Model{ID: 52, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/findSysDictionary", "根据ID获取字典", "sysDictionary", "GET"}, + {gorm.Model{ID: 53, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/getSysDictionaryList", "获取字典列表", "sysDictionary", "GET"}, + {gorm.Model{ID: 54, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/createSysOperationRecord", "新增操作记录", "sysOperationRecord", "POST"}, + {gorm.Model{ID: 55, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/deleteSysOperationRecord", "删除操作记录", "sysOperationRecord", "DELETE"}, + {gorm.Model{ID: 56, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/findSysOperationRecord", "根据ID获取操作记录", "sysOperationRecord", "GET"}, + {gorm.Model{ID: 57, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/getSysOperationRecordList", "获取操作记录列表", "sysOperationRecord", "GET"}, + {gorm.Model{ID: 58, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getTables", "获取数据库表", "autoCode", "GET"}, + {gorm.Model{ID: 59, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getDB", "获取所有数据库", "autoCode", "GET"}, + {gorm.Model{ID: 60, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getColume", "获取所选table的所有字段", "autoCode", "GET"}, + {gorm.Model{ID: 61, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/deleteSysOperationRecordByIds", "批量删除操作历史", "sysOperationRecord", "DELETE"}, + {gorm.Model{ID: 62, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/upload", "插件版分片上传", "simpleUploader", "POST"}, + {gorm.Model{ID: 63, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/checkFileMd5", "文件完整度验证", "simpleUploader", "GET"}, + {gorm.Model{ID: 64, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/mergeFileMd5", "上传完成合并文件", "simpleUploader", "GET"}, } } diff --git a/server/model/sys_casbin.go b/server/model/sys_casbin.go index cee0f25a..2dc5d64c 100644 --- a/server/model/sys_casbin.go +++ b/server/model/sys_casbin.go @@ -34,7 +34,6 @@ func CasbinModelData() []CasbinModel { {"p", "888", "/menu/getBaseMenuById", "POST"}, {"p", "888", "/user/changePassword", "POST"}, {"p", "888", "/user/uploadHeaderImg", "POST"}, - {"p", "888", "/user/getInfoList", "POST"}, {"p", "888", "/user/getUserList", "POST"}, {"p", "888", "/user/setUserAuthority", "POST"}, {"p", "888", "/user/deleteUser", "DELETE"}, @@ -95,7 +94,6 @@ func CasbinModelData() []CasbinModel { {"p", "8881", "/menu/getBaseMenuById", "POST"}, {"p", "8881", "/user/changePassword", "POST"}, {"p", "8881", "/user/uploadHeaderImg", "POST"}, - {"p", "8881", "/user/getInfoList", "POST"}, {"p", "8881", "/user/getUserList", "POST"}, {"p", "8881", "/user/setUserAuthority", "POST"}, {"p", "8881", "/fileUploadAndDownload/upload", "POST"}, @@ -134,7 +132,6 @@ func CasbinModelData() []CasbinModel { {"p", "9528", "/menu/getBaseMenuById", "POST"}, {"p", "9528", "/user/changePassword", "POST"}, {"p", "9528", "/user/uploadHeaderImg", "POST"}, - {"p", "9528", "/user/getInfoList", "POST"}, {"p", "9528", "/user/getUserList", "POST"}, {"p", "9528", "/user/setUserAuthority", "POST"}, {"p", "9528", "/fileUploadAndDownload/upload", "POST"}, diff --git a/server/router/sys_casbin.go b/server/router/sys_casbin.go index da8ccf20..c0f5d2e3 100644 --- a/server/router/sys_casbin.go +++ b/server/router/sys_casbin.go @@ -14,6 +14,5 @@ func InitCasbinRouter(Router *gin.RouterGroup) { { CasbinRouter.POST("updateCasbin", v1.UpdateCasbin) CasbinRouter.POST("getPolicyPathByAuthorityId", v1.GetPolicyPathByAuthorityId) - CasbinRouter.GET("casbinTest/:pathParam", v1.CasbinTest) } } diff --git a/server/router/sys_operation_record.go b/server/router/sys_operation_record.go index a9751f7c..59ffff59 100644 --- a/server/router/sys_operation_record.go +++ b/server/router/sys_operation_record.go @@ -14,7 +14,6 @@ func InitSysOperationRecordRouter(Router *gin.RouterGroup) { SysOperationRecordRouter.POST("createSysOperationRecord", v1.CreateSysOperationRecord) // 新建SysOperationRecord SysOperationRecordRouter.DELETE("deleteSysOperationRecord", v1.DeleteSysOperationRecord) // 删除SysOperationRecord SysOperationRecordRouter.DELETE("deleteSysOperationRecordByIds", v1.DeleteSysOperationRecordByIds) // 批量删除SysOperationRecord - SysOperationRecordRouter.PUT("updateSysOperationRecord", v1.UpdateSysOperationRecord) // 更新SysOperationRecord SysOperationRecordRouter.GET("findSysOperationRecord", v1.FindSysOperationRecord) // 根据ID获取SysOperationRecord SysOperationRecordRouter.GET("getSysOperationRecordList", v1.GetSysOperationRecordList) // 获取SysOperationRecord列表 diff --git a/server/service/sys_menu.go b/server/service/sys_menu.go index 146a6c63..573ab915 100644 --- a/server/service/sys_menu.go +++ b/server/service/sys_menu.go @@ -4,6 +4,7 @@ import ( "errors" "gin-vue-admin/global" "gin-vue-admin/model" + "gorm.io/gorm" "strconv" ) @@ -94,12 +95,10 @@ func getBaseChildrenList(menu *model.SysBaseMenu, treeMap map[string][]model.Sys // 增加基础路由 func AddBaseMenu(menu model.SysBaseMenu) (err error) { - findOne := global.GVA_DB.Where("name = ?", menu.Name).Find(&model.SysBaseMenu{}).Error - if findOne != nil { - err = global.GVA_DB.Create(&menu).Error - } else { + if !errors.Is(global.GVA_DB.Where("name = ?", menu.Name).First(&model.SysBaseMenu{}).Error, gorm.ErrRecordNotFound) { err = errors.New("存在重复name,请修改name") } + err = global.GVA_DB.Create(&menu).Error return err } diff --git a/server/service/sys_operation_record.go b/server/service/sys_operation_record.go index 9080333b..558a428e 100644 --- a/server/service/sys_operation_record.go +++ b/server/service/sys_operation_record.go @@ -39,17 +39,6 @@ func DeleteSysOperationRecord(sysOperationRecord model.SysOperationRecord) (err return err } -// @title UpdateSysOperationRecord -// @description update a SysOperationRecord -// @param sysOperationRecord *model.SysOperationRecord -// @auth (2020/04/05 20:22) -// @return error - -func UpdateSysOperationRecord(sysOperationRecord *model.SysOperationRecord) (err error) { - err = global.GVA_DB.Save(sysOperationRecord).Error - return err -} - // @title GetSysOperationRecord // @description get the info of a SysOperationRecord // @auth (2020/04/05 20:22) diff --git a/server/service/sys_user.go b/server/service/sys_user.go index 454cea12..0fc6a04a 100644 --- a/server/service/sys_user.go +++ b/server/service/sys_user.go @@ -19,17 +19,13 @@ import ( func Register(u model.SysUser) (err error, userInter model.SysUser) { var user model.SysUser - // 判断用户名是否注册 - notRegister := errors.Is(global.GVA_DB.Where("username = ?", u.Username).First(&user).Error, gorm.ErrRecordNotFound) - // notRegister为false表明读取到了 不能注册 - if !notRegister { + if !errors.Is(global.GVA_DB.Where("username = ?", u.Username).First(&user).Error, gorm.ErrRecordNotFound){ // 判断用户名是否注册 return errors.New("用户名已注册"), userInter - } else { - // 否则 附加uuid 密码md5简单加密 注册 - u.Password = utils.MD5V([]byte(u.Password)) - u.UUID = uuid.NewV4() - err = global.GVA_DB.Create(&u).Error } + // 否则 附加uuid 密码md5简单加密 注册 + u.Password = utils.MD5V([]byte(u.Password)) + u.UUID = uuid.NewV4() + err = global.GVA_DB.Create(&u).Error return err, u }