修改角色问题
This commit is contained in:
@@ -28,6 +28,11 @@ public @interface SaAdminCheckPermission {
|
|||||||
|
|
||||||
String name() default "";
|
String name() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上级菜单名称
|
||||||
|
*/
|
||||||
|
String parentName() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证模式:AND | OR,默认AND
|
* 验证模式:AND | OR,默认AND
|
||||||
* @return 验证模式
|
* @return 验证模式
|
||||||
|
|||||||
@@ -85,6 +85,28 @@ public class LoadingRole implements CommandLineRunner {
|
|||||||
Method nameMethod = annotationClass.getMethod("name");
|
Method nameMethod = annotationClass.getMethod("name");
|
||||||
String permissionName = (String) nameMethod.invoke(annotation);
|
String permissionName = (String) nameMethod.invoke(annotation);
|
||||||
|
|
||||||
|
Method parentNameMethod = annotationClass.getMethod("parentName");
|
||||||
|
String parentName = (String) parentNameMethod.invoke(annotation);
|
||||||
|
|
||||||
|
String parentId;
|
||||||
|
if (StrUtil.isNotBlank(parentName)) {
|
||||||
|
String menuSql = "select * from sys_menu where title=?"; // 查询菜单是否存在
|
||||||
|
Row menu1 = Db.selectOneBySql(menuSql, parentName);
|
||||||
|
if (menu1 == 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, "默认接口目录");
|
||||||
|
}
|
||||||
|
menu1 = Db.selectOneBySql(menuSql, "默认接口目录");
|
||||||
|
parentId = menu1.getString("menu_id");
|
||||||
|
|
||||||
|
}
|
||||||
for (String s : permissions) {
|
for (String s : permissions) {
|
||||||
String sql = "select * from sys_menu where permission=?";
|
String sql = "select * from sys_menu where permission=?";
|
||||||
Row menu1 = Db.selectOneBySql(sql, s);
|
Row menu1 = Db.selectOneBySql(sql, s);
|
||||||
@@ -98,9 +120,9 @@ public class LoadingRole implements CommandLineRunner {
|
|||||||
List<Row> count1 = Db.selectListBySql(listSql, menuId, 1L);
|
List<Row> count1 = Db.selectListBySql(listSql, menuId, 1L);
|
||||||
|
|
||||||
if (count1.isEmpty()) {
|
if (count1.isEmpty()) {
|
||||||
sql = "INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`) VALUES (?, ?);";
|
sql = "INSERT INTO `sys_roles_menus` (`menu_id`, `role_id`, `pid`) VALUES (?, ?, ?);";
|
||||||
Db.insertBySql(sql, menuId, 1L);
|
Db.insertBySql(sql, menuId, 1L);
|
||||||
log.info("接口菜单添加成功, 菜单名称: {}, 菜单权限: {}", title, permission);
|
log.info("接口菜单添加成功, 菜单名称: {}, 菜单权限: {}", title, permission, parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!title.equals(permissionName) || !fullPath.equals(url) || !httpMethod.equals(method1)) {
|
if (!title.equals(permissionName) || !fullPath.equals(url) || !httpMethod.equals(method1)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user