载入菜单修改
This commit is contained in:
@@ -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<Boolean> 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<Boolean> delete(@RequestParam Long id) {
|
||||
return CzgResult.success(roleTemplateService.removeById(id));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<Row> 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");
|
||||
|
||||
Reference in New Issue
Block a user