diff --git a/cash-api/account-server/src/main/java/com/czg/controller/admin/RoleTemplateController.java b/cash-api/account-server/src/main/java/com/czg/controller/admin/RoleTemplateController.java index 3d9d52051..5716ed854 100644 --- a/cash-api/account-server/src/main/java/com/czg/controller/admin/RoleTemplateController.java +++ b/cash-api/account-server/src/main/java/com/czg/controller/admin/RoleTemplateController.java @@ -1,6 +1,7 @@ package com.czg.controller.admin; import com.czg.account.dto.RoleTemplateDTO; +import com.czg.annotation.SaAdminCheckPermission; import com.czg.market.entity.SysRoleTemplate; import com.czg.market.service.SysRoleTemplateService; import com.czg.resp.CzgResult; @@ -22,6 +23,7 @@ public class RoleTemplateController { /** * 添加 */ + @SaAdminCheckPermission(value = "roleTemplate:add", name = "角色模板添加") @PostMapping public CzgResult save(@RequestBody @Validated RoleTemplateDTO dto) { return CzgResult.success(roleTemplateService.saveInfo(dto)); @@ -30,6 +32,7 @@ public class RoleTemplateController { /** * 删除 */ + @SaAdminCheckPermission(value = "roleTemplate:delete", name = "角色模板删除") @DeleteMapping public CzgResult delete(@RequestParam Long id) { return CzgResult.success(roleTemplateService.removeById(id)); diff --git a/cash-api/account-server/src/main/java/com/czg/controller/user/UShopUserController.java b/cash-api/account-server/src/main/java/com/czg/controller/user/UShopUserController.java index f171892a7..92e579b09 100644 --- a/cash-api/account-server/src/main/java/com/czg/controller/user/UShopUserController.java +++ b/cash-api/account-server/src/main/java/com/czg/controller/user/UShopUserController.java @@ -14,6 +14,7 @@ import com.czg.account.vo.MemberPointsLogVO; import com.czg.account.vo.PointsShopListVO; import com.czg.account.vo.ShopUserFlowInfoVO; import com.czg.annotation.Debounce; +import com.czg.annotation.SaAdminCheckPermission; import com.czg.resp.CzgResult; import com.czg.sa.StpKit; import com.czg.utils.MyQueryWrapper; diff --git a/cash-common/cash-common-tools/src/main/java/com/czg/LoadingRole.java b/cash-common/cash-common-tools/src/main/java/com/czg/LoadingRole.java index e97378b81..5c71ea845 100644 --- a/cash-common/cash-common-tools/src/main/java/com/czg/LoadingRole.java +++ b/cash-common/cash-common-tools/src/main/java/com/czg/LoadingRole.java @@ -88,27 +88,26 @@ public class LoadingRole implements CommandLineRunner { Method parentNameMethod = annotationClass.getMethod("parentName"); String parentName = (String) parentNameMethod.invoke(annotation); + String parentId; + String parentMenuSql = "select * from sys_menu where title=?"; // 查询菜单是否存在 + Row parentMenu; if (StrUtil.isNotBlank(parentName)) { - String menuSql = "select * from sys_menu where title=?"; // 查询菜单是否存在 - Row menu1 = Db.selectOneBySql(menuSql, parentName); - if (menu1 == null) { + parentMenu = Db.selectOneBySql(parentMenuSql, parentName); + if (parentMenu == null) { throw new RuntimeException(StrUtil.format("上级菜单不存在, 方法名{}, 方法路径:{}", method.getName(), fullPath)); } - parentId = menu1.getString("menu_id"); }else { - String menuSql = "select * from sys_menu where title=?"; // 查询菜单是否存在 - Row menu1 = Db.selectOneBySql(menuSql, "默认接口目录"); - if (menu1 == null) { - menuSql = "INSERT INTO `sys_menu` (`type`, `title`) VALUES (?, ?);"; - Db.insertBySql(menuSql, 0, "默认接口目录"); + parentMenu = Db.selectOneBySql(parentMenuSql, "默认接口目录"); + if (parentMenu == null) { + Db.insertBySql("INSERT INTO `sys_menu` (`type`, `title`) VALUES (?, ?);", 0, "默认接口目录"); } - menu1 = Db.selectOneBySql(menuSql, "默认接口目录"); - parentId = menu1.getString("menu_id"); - + parentMenu = Db.selectOneBySql(parentMenuSql, "默认接口目录"); } + parentId = parentMenu.getString("menu_id"); for (String s : permissions) { String sql = "select * from sys_menu where permission=?"; + Row menu1 = Db.selectOneBySql(sql, s); if (menu1 != null) { Long menuId = menu1.getLong("menu_id"); @@ -119,23 +118,25 @@ public class LoadingRole implements CommandLineRunner { String listSql = "select * from sys_roles_menus where menu_id=? and role_id=?"; List count1 = Db.selectListBySql(listSql, menuId, 1L); + + if (count1.isEmpty()) { - sql = "INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`, `pid`) VALUES (?, ?, ?);"; + sql = "INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES (?, ?);"; Db.insertBySql(sql, menuId, 1L); - log.info("接口菜单添加成功, 菜单名称: {}, 菜单权限: {}", title, permission, parentId); + log.info("接口菜单添加成功, 菜单名称: {}, 菜单权限: {}", title, permission); } if (!title.equals(permissionName) || !fullPath.equals(url) || !httpMethod.equals(method1)) { - sql = "update sys_menu set title=?, url=?, method=? where menu_id=?"; - Db.updateBySql(sql, permissionName, fullPath, httpMethod, menuId); + sql = "update sys_menu set title=?, url=?, method=?, pid=? where menu_id=?"; + Db.updateBySql(sql, permissionName, fullPath, httpMethod, parentId, menuId); log.info("接口菜单修改成功, 旧名称: {}, 新菜单名称: {}", title, permissionName); } continue; } - sql = "INSERT INTO `czg_cashier`.`sys_menu` ( `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`, `active_menu`, `is_shop`, `url`, `method`) VALUES " + - "(0, 2, ?, NULL, '', 2, '', '', b'0', b'0', b'0', ?, NULL, NULL, ?, NULL, NULL, 0, ?, ?);"; - Db.insertBySql(sql, StrUtil.isNotBlank(permissionName) ? permissionName : s, s, DateUtil.date(), fullPath, httpMethod); + sql = "INSERT INTO `czg_cashier`.`sys_menu` ( `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`, `active_menu`, `is_shop`, `url`, `method`, `pid`) VALUES " + + "(0, 2, ?, NULL, '', 2, '', '', b'0', b'0', b'0', ?, NULL, NULL, ?, NULL, NULL, 0, ?, ?, ?);"; + Db.insertBySql(sql, StrUtil.isNotBlank(permissionName) ? permissionName : s, s, DateUtil.date(), fullPath, httpMethod, parentId); sql = "select * from sys_menu where permission=?"; Row info = Db.selectOneBySql(sql, s); Long menuId = info.getLong("menu_id");