|
@@ -67,6 +67,9 @@ public class SysAdminSetController {
|
|
|
@Resource
|
|
|
MySQLDatabaseBackup mySQLDatabaseBackup;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TSchoolRoleService tSchoolRoleService;
|
|
|
+
|
|
|
@ApiOperation(value = "数据还原")
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "数据还原信息", response = ResultUtil.class)})
|
|
|
@RequestMapping(value = "/backup", method = RequestMethod.POST)
|
|
@@ -117,7 +120,7 @@ public class SysAdminSetController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "系统试卷规格配置查询")
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "系统试卷规格配置信息", response = SysPrivilege.class)})
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "系统试卷规格配置信息", response = CustomPrivilegeResult.class)})
|
|
|
@RequestMapping(value = "/paper/sys/select", method = RequestMethod.POST)
|
|
|
public Result sysadminPaperSysSelect() {
|
|
|
SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.SYS_PDF_SIZE_LIST);
|
|
@@ -212,9 +215,9 @@ public class SysAdminSetController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "查询自定义菜单权限")
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "菜单权限信息", response = SysPrivilege.class)})
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "菜单权限信息", response = CustomPrivilegeResult.class)})
|
|
|
@RequestMapping(value = "/menu/custom/list", method = RequestMethod.POST)
|
|
|
- public Result customList() {
|
|
|
+ public Result customMenuList() {
|
|
|
List<PrivilegeDto> customPrivilegeList = sysPrivilegeService.addCustomList();
|
|
|
return ResultUtil.ok(new CustomPrivilegeResult(customPrivilegeList));
|
|
|
}
|
|
@@ -223,7 +226,7 @@ public class SysAdminSetController {
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "菜单权限信息", response = ResultUtil.class)})
|
|
|
@RequestMapping(value = "/menu/custom/save", method = RequestMethod.POST)
|
|
|
@Transactional
|
|
|
- public Result getRolePrivileges(@Valid @RequestBody SysAdminSetParam tSchoolPrivilegeParam, BindingResult bindingResult) throws NoSuchAlgorithmException {
|
|
|
+ public Result schoolPrivilegeSave(@Valid @RequestBody SysAdminSetParam tSchoolPrivilegeParam, BindingResult bindingResult) throws NoSuchAlgorithmException {
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
|
|
}
|
|
@@ -268,12 +271,8 @@ public class SysAdminSetController {
|
|
|
//清缓存
|
|
|
if (!CollectionUtils.isEmpty(roleSetIds)) {
|
|
|
for (Long l : roleSetIds) {
|
|
|
- if (Objects.isNull(commonCacheService.updateRoleCache(l))) {
|
|
|
- commonCacheService.removeRoleCache(l);
|
|
|
- }
|
|
|
- if (CollectionUtils.isEmpty(commonCacheService.updateRolePrivilegeCache(l))) {
|
|
|
- commonCacheService.removeRolePrivilegeCache(l);
|
|
|
- }
|
|
|
+ commonCacheService.removeRoleCache(l);
|
|
|
+ commonCacheService.removeRolePrivilegeCache(l);
|
|
|
//绑定该角色的用户都需要清除鉴权缓存
|
|
|
List<SysUserRole> sysUserRoleList = sysUserRoleService.listByRoleId(l);
|
|
|
for (SysUserRole s : sysUserRoleList) {
|
|
@@ -292,9 +291,91 @@ public class SysAdminSetController {
|
|
|
@ApiOperation(value = "学校已绑定自定义菜单权限列表")
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "菜单权限信息", response = SysAdminSetResult.class)})
|
|
|
@RequestMapping(value = "/menu/custom/get_school_custom_privileges", method = RequestMethod.POST)
|
|
|
- public Result getRolePrivileges(@ApiParam(value = "学校id ", required = true) @RequestParam Long schoolId) {
|
|
|
+ public Result getSchoolPrivileges(@ApiParam(value = "学校id ", required = true) @RequestParam Long schoolId) {
|
|
|
List<TSchoolPrivilege> tSchoolPrivilegeList = tSchoolPrivilegeService.findBySchoolId(schoolId);
|
|
|
List<String> privilegeIdList = tSchoolPrivilegeList.stream().map(s -> String.valueOf(s.getPrivilegeId())).collect(Collectors.toList());
|
|
|
return ResultUtil.ok(new SysAdminSetResult(schoolId, CollectionUtils.isEmpty(privilegeIdList) ? new ArrayList<>() : privilegeIdList));
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询自定义角色权限")
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "角色权限信息", response = CustomPrivilegeResult.class)})
|
|
|
+ @RequestMapping(value = "/role/custom/list", method = RequestMethod.POST)
|
|
|
+ public Result customRoleList() {
|
|
|
+ QueryWrapper<SysRole> sysRoleQueryWrapper = new QueryWrapper<>();
|
|
|
+ sysRoleQueryWrapper.lambda().eq(SysRole::getDefaultRole, true)
|
|
|
+ .eq(SysRole::getEnable, true)
|
|
|
+ .isNull(SysRole::getSchoolId)
|
|
|
+ .ne(SysRole::getType, SystemConstant.ADMIN_CODE.toUpperCase())
|
|
|
+ .orderByAsc(SysRole::getId);
|
|
|
+ List<SysRole> sysRoleList = sysRoleService.list(sysRoleQueryWrapper);
|
|
|
+ CustomPrivilegeResult customPrivilegeResult = new CustomPrivilegeResult();
|
|
|
+ customPrivilegeResult.setCustomRoleList(sysRoleList);
|
|
|
+ return ResultUtil.ok(sysRoleList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "学校新增/修改自定义角色权限")
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "角色权限信息", response = ResultUtil.class)})
|
|
|
+ @RequestMapping(value = "/role/custom/save", method = RequestMethod.POST)
|
|
|
+ @Transactional
|
|
|
+ public Result schoolRoleSave(@Valid @RequestBody SysAdminSetParam tSchoolPrivilegeParam, BindingResult bindingResult) throws NoSuchAlgorithmException {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
|
|
+ }
|
|
|
+ Set<Long> userSetIds = null;
|
|
|
+ QueryWrapper<TSchoolRole> tSchoolRoleQueryWrapper = new QueryWrapper<>();
|
|
|
+ tSchoolRoleQueryWrapper.lambda().eq(TSchoolRole::getSchoolId, tSchoolPrivilegeParam.getSchoolId());
|
|
|
+ List<TSchoolRole> tSchoolRoles = tSchoolRoleService.list(tSchoolRoleQueryWrapper);
|
|
|
+ if (!CollectionUtils.isEmpty(tSchoolRoles)) {//编辑
|
|
|
+ Set<Long> changeRoleSetIds = tSchoolRoles.stream().filter(s -> !Arrays.asList(tSchoolPrivilegeParam.getRoleIds()).contains(s.getRoleId()))
|
|
|
+ .collect(Collectors.toList())
|
|
|
+ .stream().map(s -> s.getRoleId())
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ //数据发生改变
|
|
|
+ if (!CollectionUtils.isEmpty(changeRoleSetIds)) {
|
|
|
+ //查询该角色下所有用户,删除该角色所发生改变的用户数据
|
|
|
+ List<SysUserRole> sysUserRoleList = sysUserRoleService.listByRoleIdsAndSchoolId(changeRoleSetIds, tSchoolPrivilegeParam.getSchoolId());
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(sysUserRoleList)) {
|
|
|
+ List<Long> ids = new ArrayList<>(sysUserRoleList.size());
|
|
|
+ for (SysUserRole s : sysUserRoleList) {
|
|
|
+ userSetIds.add(s.getUserId());
|
|
|
+ ids.add(s.getId());
|
|
|
+ }
|
|
|
+ sysUserRoleService.removeByIds(ids);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tSchoolRoleService.remove(tSchoolRoleQueryWrapper);
|
|
|
+ }
|
|
|
+ Long[] roleIds = tSchoolPrivilegeParam.getRoleIds();
|
|
|
+ if (Objects.nonNull(roleIds) && roleIds.length > 0) {
|
|
|
+ List<TSchoolRole> tSchoolRoleList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < roleIds.length; i++) {
|
|
|
+ tSchoolRoleList.add(new TSchoolRole(tSchoolPrivilegeParam.getSchoolId(), roleIds[i]));
|
|
|
+ }
|
|
|
+ tSchoolRoleService.saveBatch(tSchoolRoleList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //清缓存
|
|
|
+ if (!CollectionUtils.isEmpty(userSetIds)) {
|
|
|
+ for (Long l : userSetIds) {
|
|
|
+ commonCacheService.removeUserCache(l);
|
|
|
+ commonCacheService.removeUserAuthCache(l);
|
|
|
+ commonCacheService.removeUserMenuCache(l);
|
|
|
+ commonCacheService.removeUserRolePrivilegeCache(l);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultUtil.ok(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "学校已绑定自定义角色权限列表")
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "角色权限信息", response = SysAdminSetResult.class)})
|
|
|
+ @RequestMapping(value = "/role/custom/get_school_custom_roles", method = RequestMethod.POST)
|
|
|
+ public Result getSchoolRoles(@ApiParam(value = "学校id ", required = true) @RequestParam Long schoolId) {
|
|
|
+ List<TSchoolRole> tSchoolRoleList = tSchoolRoleService.findBySchoolId(schoolId);
|
|
|
+ List<String> roleIdList = tSchoolRoleList.stream().map(s -> String.valueOf(s.getRoleId())).collect(Collectors.toList());
|
|
|
+ SysAdminSetResult sysAdminSetResult = new SysAdminSetResult();
|
|
|
+ sysAdminSetResult.setSchoolId(schoolId);
|
|
|
+ sysAdminSetResult.setRoleIdList(CollectionUtils.isEmpty(roleIdList) ? new ArrayList<>() : roleIdList);
|
|
|
+ return ResultUtil.ok(sysAdminSetResult);
|
|
|
+ }
|
|
|
}
|