角色和区域关联 sys_role_area

This commit is contained in:
sxu 2025-03-10 16:57:36 +08:00
parent 1b54186938
commit fff2578651
4 changed files with 37 additions and 14 deletions

View File

@ -161,6 +161,23 @@ public class SysRoleController extends BaseController
}
}
/**
* 修改保存数据权限
*/
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:role:edit"))
@PostMapping("/roleArea/edit")
@SysLog(title = "角色管理", businessType = OperaType.UPDATE,logType = 0,module = "系统管理->角色管理",details = "修改权限")
public AjaxResult rebuildRoleAreaScope(@RequestBody SysRole role) {
try{
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
return toAjax(roleService.rebuildRoleAreaScope(role));
}catch (Exception e){
logger.error(e.toString(),e);
return error(e.getMessage());
}
}
/**
* 状态修改
*/

View File

@ -14,7 +14,7 @@ public class SysRoleArea
/** 角色ID */
private Long roleId;
/** 部门ID */
/** 区域ID */
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long areaId;

View File

@ -129,6 +129,8 @@ public interface ISysRoleService
*/
public int authDataScope(SysRole role);
public int rebuildRoleAreaScope(SysRole role);
/**
* 通过角色ID删除角色
*

View File

@ -309,20 +309,24 @@ public class SysRoleServiceImpl implements ISysRoleService
public int authDataScope(SysRole role)
{
// 修改角色信息
int count = roleMapper.updateRole(role);
if (DataTypeEnum.PERMISSION_ORG.getKey().equals(role.getDataType())) {
roleMapper.updateRole(role);
// 删除角色与部门关联
roleDeptMapper.deleteRoleDeptByRoleId(role.getRoleId());
// 新增角色和部门信息数据权限
return insertRoleDept(role);
} else if (DataTypeEnum.PERMISSION_AREA.getKey().equals(role.getDataType())) {
}
@Override
@Transactional(rollbackFor = Exception.class)
public int rebuildRoleAreaScope(SysRole role)
{
// 修改角色信息
roleMapper.updateRole(role);
// 删除角色与区域关联
roleAreaMapper.deleteRoleAreaByRoleId(role.getRoleId());
// 新增角色和区域信息数据权限
return insertRoleArea(role);
}
return count;
}
/**
* 新增角色菜单信息