|
@@ -1,106 +1,106 @@
|
|
-package com.backendsys.controller.Systems;
|
|
|
|
-
|
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
|
-import com.backendsys.aspect.QueryNullCheck;
|
|
|
|
-import com.backendsys.aspect.QueryNullCheckAspect;
|
|
|
|
-import com.backendsys.entity.System.SysUserRoleDTO;
|
|
|
|
-import com.backendsys.service.System.SysUserRoleModuleService;
|
|
|
|
-import com.backendsys.service.System.SysUserRoleService;
|
|
|
|
-import com.backendsys.utils.response.Result;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
-
|
|
|
|
-import java.util.List;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * 系统用户角色
|
|
|
|
- */
|
|
|
|
-@Validated
|
|
|
|
-@RestController
|
|
|
|
-public class SysUserRoleV1Controller {
|
|
|
|
- @Autowired
|
|
|
|
- private SysUserRoleService sysUserRoleService;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private SysUserRoleModuleService sysUserRoleModuleService;
|
|
|
|
-
|
|
|
|
- // 判断 role.modules: [{ id: 1 }, { id: 2 }],是否有重复值
|
|
|
|
- //public boolean hasDuplicateIds(List<LinkedHashMap<String, Object>> modules) {
|
|
|
|
- // List<Object> ids = CollUtil.getFieldValues(modules, "id");
|
|
|
|
- // return CollUtil.isNotEmpty(ids) && ids.size() != CollUtil.distinct(ids).size();
|
|
|
|
- //}
|
|
|
|
- public boolean hasDuplicateIds(List<Object> ids) {
|
|
|
|
- return CollUtil.isNotEmpty(ids) && ids.size() != CollUtil.distinct(ids).size();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-// // @Operation(summary = "系统用户角色列表")
|
|
|
|
-// @PreAuthorize("@ss.hasPermi('4.1')")
|
|
|
|
-// @GetMapping("/api/system/user/getUserRole")
|
|
|
|
-// public Result getUserRole(@Validated PageDTO pageDTO, @Validated SysUserRoleDTO sysUserRoleDTO) {
|
|
|
|
-// return Result.success(sysUserRoleService.queryUserRole(pageDTO.getPage_num(), pageDTO.getPage_size(), sysUserRoleDTO));
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
- //@Operation(summary = "系统用户角色详情")
|
|
|
|
- @PreAuthorize("@ss.hasPermi('4.1.1')")
|
|
|
|
- @QueryNullCheck(serviceClass = SysUserRoleService.class, serviceMethod = "queryUserRoleDetail", argField = "role_id", message = "用户角色不存在")
|
|
|
|
- @GetMapping("/api/v1/system/user/getUserRoleDetail")
|
|
|
|
- public Result getUserRoleDetail(@Validated(SysUserRoleDTO.Detail.class) SysUserRoleDTO sysUserRoleDTO) {
|
|
|
|
- return Result.success(QueryNullCheckAspect.getQueryResult());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-// //@Operation(summary = "创建系统用户角色")
|
|
|
|
-// @PreAuthorize("@ss.hasPermi('4.1.2')")
|
|
|
|
-// @PostMapping("/api/system/user/createUserRole")
|
|
|
|
-// public Result createUserRole(@Validated(SysUserRoleDTO.Create.class) @RequestBody SysUserRoleDTO sysUserRoleDTO) {
|
|
|
|
-// // 判断 role.modules 是否重复
|
|
|
|
-// if (hasDuplicateIds(sysUserRoleDTO.getModules())) {
|
|
|
|
-// return Result.error(ResultEnum.DATABASE_OPERATION_FAILED.getCode(), "模块ID出现重复值");
|
|
|
|
-// }
|
|
|
|
-// // 创建
|
|
|
|
-// return Result.success(sysUserRoleService.insertUserRole(sysUserRoleDTO), "创建成功");
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// //@Operation(summary = "更新系统用户角色")
|
|
|
|
-// @PreAuthorize("@ss.hasPermi('4.1.3')")
|
|
|
|
-// @QueryNullCheck(serviceClass = SysUserRoleService.class, serviceMethod = "queryUserRoleDetail", argField = "role_id", message = "用户角色不存在")
|
|
|
|
-// @PutMapping("/api/system/user/updateUserRole")
|
|
|
|
-// public Result updateUserRole(@Validated(SysUserRoleDTO.Update.class) @RequestBody SysUserRoleDTO sysUserRoleDTO) {
|
|
|
|
-// // 判断 role.modules 是否重复
|
|
|
|
-// if (hasDuplicateIds(sysUserRoleDTO.getModules())) {
|
|
|
|
-// return Result.error(ResultEnum.DATABASE_OPERATION_FAILED.getCode(), "模块ID出现重复值");
|
|
|
|
-// }
|
|
|
|
-// // 更新
|
|
|
|
-// return Result.success(sysUserRoleService.updateUserRole(sysUserRoleDTO), "更新成功");
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// //@Operation(summary = "删除系统用户角色")
|
|
|
|
-// @PreAuthorize("@ss.hasPermi('4.1.4')")
|
|
|
|
-// @QueryNullCheck(serviceClass = SysUserRoleService.class, serviceMethod = "queryUserRoleDetail", argField = "role_id", message = "用户角色不存在")
|
|
|
|
-// @DeleteMapping("/api/system/user/deleteUserRole")
|
|
|
|
-// public Result deleteUserRole(@Validated(SysUserRoleDTO.Delete.class) @RequestBody SysUserRoleDTO sysUserRoleDTO) {
|
|
|
|
|
|
+//package com.backendsys.controller.Systems;
|
|
//
|
|
//
|
|
-// // 如果角色ID: 1管理员, 2游客,则不可删除
|
|
|
|
-// Long role_id = sysUserRoleDTO.getRole_id();
|
|
|
|
-// Set<Long> filterRoles = new HashSet<>(Arrays.asList(1L, 2L));
|
|
|
|
-// if (filterRoles.contains(role_id)) {
|
|
|
|
-// return Result.error(ResultEnum.DATABASE_OPERATION_FAILED.getCode(), "该角色不可删除");
|
|
|
|
-// }
|
|
|
|
|
|
+//import cn.hutool.core.collection.CollUtil;
|
|
|
|
+//import com.backendsys.aspect.QueryNullCheck;
|
|
|
|
+//import com.backendsys.aspect.QueryNullCheckAspect;
|
|
|
|
+//import com.backendsys.entity.System.SysUserRoleDTO;
|
|
|
|
+//import com.backendsys.service.System.SysUserRoleModuleService;
|
|
|
|
+//import com.backendsys.service.System.SysUserRoleService;
|
|
|
|
+//import com.backendsys.utils.response.Result;
|
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+//import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
+//import org.springframework.validation.annotation.Validated;
|
|
|
|
+//import org.springframework.web.bind.annotation.*;
|
|
//
|
|
//
|
|
-// // 判断角色是否有关联用户,如有则不可删除
|
|
|
|
-// Map<String, Object> query = QueryNullCheckAspect.getQueryResult();
|
|
|
|
-// Long user_count = (Long) query.get("user_count");
|
|
|
|
-// if (user_count != 0) {
|
|
|
|
-// return Result.error(ResultEnum.DATABASE_OPERATION_FAILED.getCode(), "角色已关联 " + user_count + " 个用户,请解除关联后再删除");
|
|
|
|
-// }
|
|
|
|
-// // 删除用户 (物理删除)
|
|
|
|
-// return Result.success(sysUserRoleService.deleteUserRole(sysUserRoleDTO), "删除成功");
|
|
|
|
-// }
|
|
|
|
|
|
+//import java.util.List;
|
|
|
|
+//
|
|
|
|
+///**
|
|
|
|
+// * 系统用户角色
|
|
|
|
+// */
|
|
|
|
+//@Validated
|
|
|
|
+//@RestController
|
|
|
|
+//public class SysUserRoleV1Controller {
|
|
|
|
+// @Autowired
|
|
|
|
+// private SysUserRoleService sysUserRoleService;
|
|
|
|
+//
|
|
|
|
+// @Autowired
|
|
|
|
+// private SysUserRoleModuleService sysUserRoleModuleService;
|
|
//
|
|
//
|
|
-// @PreAuthorize("@ss.hasPermi('4.1.5')")
|
|
|
|
-// @GetMapping("/api/system/user/getUserRoleModule")
|
|
|
|
-// public Result getUserRoleModule() {
|
|
|
|
-// return Result.success(sysUserRoleModuleService.queryUserRoleModule());
|
|
|
|
|
|
+// // 判断 role.modules: [{ id: 1 }, { id: 2 }],是否有重复值
|
|
|
|
+// //public boolean hasDuplicateIds(List<LinkedHashMap<String, Object>> modules) {
|
|
|
|
+// // List<Object> ids = CollUtil.getFieldValues(modules, "id");
|
|
|
|
+// // return CollUtil.isNotEmpty(ids) && ids.size() != CollUtil.distinct(ids).size();
|
|
|
|
+// //}
|
|
|
|
+// public boolean hasDuplicateIds(List<Object> ids) {
|
|
|
|
+// return CollUtil.isNotEmpty(ids) && ids.size() != CollUtil.distinct(ids).size();
|
|
// }
|
|
// }
|
|
-}
|
|
|
|
|
|
+//
|
|
|
|
+//// // @Operation(summary = "系统用户角色列表")
|
|
|
|
+//// @PreAuthorize("@ss.hasPermi('4.1')")
|
|
|
|
+//// @GetMapping("/api/system/user/getUserRole")
|
|
|
|
+//// public Result getUserRole(@Validated PageDTO pageDTO, @Validated SysUserRoleDTO sysUserRoleDTO) {
|
|
|
|
+//// return Result.success(sysUserRoleService.queryUserRole(pageDTO.getPage_num(), pageDTO.getPage_size(), sysUserRoleDTO));
|
|
|
|
+//// }
|
|
|
|
+//
|
|
|
|
+// //@Operation(summary = "系统用户角色详情")
|
|
|
|
+//// @PreAuthorize("@ss.hasPermi('4.1.1')")
|
|
|
|
+//// @QueryNullCheck(serviceClass = SysUserRoleService.class, serviceMethod = "queryUserRoleDetail", argField = "role_id", message = "用户角色不存在")
|
|
|
|
+//// @GetMapping("/api/v1/system/user/getUserRoleDetail")
|
|
|
|
+//// public Result getUserRoleDetail(@Validated(SysUserRoleDTO.Detail.class) SysUserRoleDTO sysUserRoleDTO) {
|
|
|
|
+//// return Result.success(QueryNullCheckAspect.getQueryResult());
|
|
|
|
+//// }
|
|
|
|
+//
|
|
|
|
+//// //@Operation(summary = "创建系统用户角色")
|
|
|
|
+//// @PreAuthorize("@ss.hasPermi('4.1.2')")
|
|
|
|
+//// @PostMapping("/api/system/user/createUserRole")
|
|
|
|
+//// public Result createUserRole(@Validated(SysUserRoleDTO.Create.class) @RequestBody SysUserRoleDTO sysUserRoleDTO) {
|
|
|
|
+//// // 判断 role.modules 是否重复
|
|
|
|
+//// if (hasDuplicateIds(sysUserRoleDTO.getModules())) {
|
|
|
|
+//// return Result.error(ResultEnum.DATABASE_OPERATION_FAILED.getCode(), "模块ID出现重复值");
|
|
|
|
+//// }
|
|
|
|
+//// // 创建
|
|
|
|
+//// return Result.success(sysUserRoleService.insertUserRole(sysUserRoleDTO), "创建成功");
|
|
|
|
+//// }
|
|
|
|
+//
|
|
|
|
+//// //@Operation(summary = "更新系统用户角色")
|
|
|
|
+//// @PreAuthorize("@ss.hasPermi('4.1.3')")
|
|
|
|
+//// @QueryNullCheck(serviceClass = SysUserRoleService.class, serviceMethod = "queryUserRoleDetail", argField = "role_id", message = "用户角色不存在")
|
|
|
|
+//// @PutMapping("/api/system/user/updateUserRole")
|
|
|
|
+//// public Result updateUserRole(@Validated(SysUserRoleDTO.Update.class) @RequestBody SysUserRoleDTO sysUserRoleDTO) {
|
|
|
|
+//// // 判断 role.modules 是否重复
|
|
|
|
+//// if (hasDuplicateIds(sysUserRoleDTO.getModules())) {
|
|
|
|
+//// return Result.error(ResultEnum.DATABASE_OPERATION_FAILED.getCode(), "模块ID出现重复值");
|
|
|
|
+//// }
|
|
|
|
+//// // 更新
|
|
|
|
+//// return Result.success(sysUserRoleService.updateUserRole(sysUserRoleDTO), "更新成功");
|
|
|
|
+//// }
|
|
|
|
+//
|
|
|
|
+//// //@Operation(summary = "删除系统用户角色")
|
|
|
|
+//// @PreAuthorize("@ss.hasPermi('4.1.4')")
|
|
|
|
+//// @QueryNullCheck(serviceClass = SysUserRoleService.class, serviceMethod = "queryUserRoleDetail", argField = "role_id", message = "用户角色不存在")
|
|
|
|
+//// @DeleteMapping("/api/system/user/deleteUserRole")
|
|
|
|
+//// public Result deleteUserRole(@Validated(SysUserRoleDTO.Delete.class) @RequestBody SysUserRoleDTO sysUserRoleDTO) {
|
|
|
|
+////
|
|
|
|
+//// // 如果角色ID: 1管理员, 2游客,则不可删除
|
|
|
|
+//// Long role_id = sysUserRoleDTO.getRole_id();
|
|
|
|
+//// Set<Long> filterRoles = new HashSet<>(Arrays.asList(1L, 2L));
|
|
|
|
+//// if (filterRoles.contains(role_id)) {
|
|
|
|
+//// return Result.error(ResultEnum.DATABASE_OPERATION_FAILED.getCode(), "该角色不可删除");
|
|
|
|
+//// }
|
|
|
|
+////
|
|
|
|
+//// // 判断角色是否有关联用户,如有则不可删除
|
|
|
|
+//// Map<String, Object> query = QueryNullCheckAspect.getQueryResult();
|
|
|
|
+//// Long user_count = (Long) query.get("user_count");
|
|
|
|
+//// if (user_count != 0) {
|
|
|
|
+//// return Result.error(ResultEnum.DATABASE_OPERATION_FAILED.getCode(), "角色已关联 " + user_count + " 个用户,请解除关联后再删除");
|
|
|
|
+//// }
|
|
|
|
+//// // 删除用户 (物理删除)
|
|
|
|
+//// return Result.success(sysUserRoleService.deleteUserRole(sysUserRoleDTO), "删除成功");
|
|
|
|
+//// }
|
|
|
|
+////
|
|
|
|
+//// @PreAuthorize("@ss.hasPermi('4.1.5')")
|
|
|
|
+//// @GetMapping("/api/system/user/getUserRoleModule")
|
|
|
|
+//// public Result getUserRoleModule() {
|
|
|
|
+//// return Result.success(sysUserRoleModuleService.queryUserRoleModule());
|
|
|
|
+//// }
|
|
|
|
+//}
|