mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-13 02:57:13 +08:00
refactor: 优化部分存储管理、用户管理、菜单管理代码,消除 sonar 问题
This commit is contained in:
@@ -70,10 +70,12 @@ public class MenuController extends BaseController<MenuService, MenuResp, MenuRe
|
||||
private void checkPath(MenuReq req) {
|
||||
Boolean isExternal = ObjectUtil.defaultIfNull(req.getIsExternal(), false);
|
||||
String path = req.getPath();
|
||||
ValidationUtils.throwIf(isExternal && !URLUtils.isHttpUrl(path), "路由地址格式错误,请以 http:// 或 https:// 开头");
|
||||
if (!isExternal) {
|
||||
ValidationUtils.throwIf(Boolean.TRUE.equals(isExternal) && !URLUtils
|
||||
.isHttpUrl(path), "路由地址格式错误,请以 http:// 或 https:// 开头");
|
||||
// 非外链菜单参数修正
|
||||
if (Boolean.FALSE.equals(isExternal)) {
|
||||
ValidationUtils.throwIf(URLUtils.isHttpUrl(path), "路由地址格式错误");
|
||||
req.setPath(StrUtil.prependIfMissing(req.getPath(), StringConstants.SLASH));
|
||||
req.setPath(StrUtil.prependIfMissing(path, StringConstants.SLASH));
|
||||
req.setName(StrUtil.removePrefix(req.getName(), StringConstants.SLASH));
|
||||
req.setComponent(StrUtil.removePrefix(req.getComponent(), StringConstants.SLASH));
|
||||
}
|
||||
|
@@ -70,7 +70,7 @@ public class UserController extends BaseController<UserService, UserResp, UserDe
|
||||
|
||||
@Operation(summary = "重置密码", description = "重置用户登录密码")
|
||||
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
|
||||
@SaCheckPermission("system:user:password:reset")
|
||||
@SaCheckPermission("system:user:resetPwd")
|
||||
@PatchMapping("/{id}/password")
|
||||
public R<Void> resetPassword(@Validated @RequestBody UserPasswordResetReq req, @PathVariable Long id) {
|
||||
String rawNewPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(req.getNewPassword()));
|
||||
@@ -84,7 +84,7 @@ public class UserController extends BaseController<UserService, UserResp, UserDe
|
||||
|
||||
@Operation(summary = "分配角色", description = "为用户新增或移除角色")
|
||||
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
|
||||
@SaCheckPermission("system:user:role:update")
|
||||
@SaCheckPermission("system:user:updateRole")
|
||||
@PatchMapping("/{id}/role")
|
||||
public R<Void> updateRole(@Validated @RequestBody UserRoleUpdateReq updateReq, @PathVariable Long id) {
|
||||
baseService.updateRole(updateReq, id);
|
||||
|
Reference in New Issue
Block a user