Commit 6e0e1234 authored by huyuchen's avatar huyuchen

菜单权限修改

parent e4785ef0
......@@ -60,6 +60,12 @@ public class SysMenu extends BaseEntity {
@Schema(description = "视图ID")
private String viewId;
/**
* 权限维度
*/
@Schema(description = "权限维度")
private String permissionType;
/**
* 授权状态(0启用、1禁用)
*/
......
......@@ -49,7 +49,7 @@ public class SysMenuController {
*/
@Operation(description = "新增新权限-菜单表:hasPermission('permission_sysmenu_add')")
@SysLog("新增新权限-菜单表")
@PostMapping
@PostMapping("/addMenu")
@PreAuthorize("@pms.hasPermission('permission_sysmenu_add')")
public R<Boolean> save(@RequestBody SysMenu sysMenu) {
return sysMenuService.saveMenu(sysMenu);
......@@ -66,7 +66,18 @@ public class SysMenuController {
@PostMapping("/updateMenu")
@PreAuthorize("@pms.hasPermission('permission_sysmenu_edit')")
public R<Boolean> updateById(@RequestBody SysMenu sysMenu) {
return R.ok(sysMenuService.updateById(sysMenu));
return sysMenuService.updateMenu(sysMenu);
}
/**
* 通过id查询新权限-菜单表
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
public R<SysMenu> getById(@PathVariable("id") String id) {
return R.ok(sysMenuService.getById(id));
}
}
......@@ -28,4 +28,11 @@ public interface SysMenuService extends IService<SysMenu> {
* @return
*/
R<Boolean> saveMenu(SysMenu menu);
/**
* 更新菜单表
* @param menu 新权限-菜单表
* @return
*/
R<Boolean> updateMenu(SysMenu menu);
}
......@@ -67,6 +67,38 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
}
//错误信息
StringBuilder errorStr = new StringBuilder();
//权限维度
StringBuilder permissionType = new StringBuilder();
this.check(menu,errorStr,permissionType);
//权限维度的控件id填写错误的话统一返回
if (errorStr.length() > 0) {
return R.failed(errorStr.substring(0, errorStr.lastIndexOf(";")));
}
menu.setPermissionType(permissionType.substring(0, errorStr.lastIndexOf("、")));
int res = baseMapper.insert(menu);
if (res <= CommonConstants.ZERO_INT) {
return R.failed();
}
return R.ok();
}
@Override
public R<Boolean> updateMenu(SysMenu menu) {
//错误信息
StringBuilder errorStr = new StringBuilder();
//权限维度
StringBuilder permissionType = new StringBuilder();
this.check(menu,errorStr,permissionType);
//权限维度的控件id填写错误的话统一返回
if (errorStr.length() > 0) {
return R.failed(errorStr.substring(0, errorStr.lastIndexOf(";")));
}
menu.setPermissionType(permissionType.substring(0, errorStr.lastIndexOf("、")));
baseMapper.updateById(menu);
return R.ok();
}
public void check(SysMenu menu,StringBuilder errorStr,StringBuilder permissionType) {
//权限类型
String name;
//判断填写的控件id 是否属于表单的字段
......@@ -74,23 +106,14 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
if (!menu.getColumnIdList().isEmpty()) {
for (String columnId : menu.getColumnIdList()) {
name = columnId.substring(0, columnId.indexOf(";"));
//label为控件id;columnId格式为【客户权限_fd_3ae495ff53c560】
permissionType.append(name).append("、");
//label为控件id;columnId格式为【客户权限;fd_3ae495ff53c560】
String label = columnId.substring(columnId.indexOf(";") + 1);
if (list.stream().noneMatch(e -> e.equals(label))) {
errorStr.append(name).append("的控件id填写有误;");
}
}
}
//权限维度的控件id填写错误的话统一返回
if (errorStr.length() > 0) {
return R.failed(errorStr.substring(0, errorStr.lastIndexOf(";")));
}
int res = baseMapper.insert(menu);
if (res <= CommonConstants.ZERO_INT) {
return R.failed();
}
return R.ok();
}
}
......@@ -10,6 +10,7 @@
<result property="menuParentId" column="MENU_PARENT_ID"/>
<result property="modelId" column="MODEL_ID"/>
<result property="viewId" column="VIEW_ID"/>
<result property="permissionType" column="PERMISSION_TYPE"/>
<result property="permissionStatus" column="PERMISSION_STATUS"/>
<result property="deleteStatus" column="DELETE_STATUS"/>
<result property="incomeId" column="INCOME_ID"/>
......@@ -32,6 +33,7 @@
a.MENU_NAME,
a.MENU_NAME_PARENT,
a.MENU_PARENT_ID,
a.PERMISSION_TYPE,
a.PERMISSION_STATUS,
a.DELETE_STATUS,
a.CREATE_TIME
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment