From ed4a5236bab800094be4a8378f5098eebe3de6ac Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期四, 04 四月 2024 23:30:30 +0800
Subject: [PATCH] 清楚不不要的mapstruct文件
---
smart-man-boot/src/main/java/com/qianwen/smartman/modules/system/service/impl/RoleServiceImpl.java | 245 +++++++++---------------------------------------
1 files changed, 48 insertions(+), 197 deletions(-)
diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/system/service/impl/RoleServiceImpl.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/system/service/impl/RoleServiceImpl.java
index 980db71..d4b2848 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/system/service/impl/RoleServiceImpl.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/system/service/impl/RoleServiceImpl.java
@@ -1,25 +1,27 @@
package com.qianwen.smartman.modules.system.service.impl;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import java.lang.invoke.SerializedLambda;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
+
import javax.validation.constraints.NotEmpty;
-import com.qianwen.smartman.common.cache.RegionCache;
-import com.qianwen.smartman.common.constant.CommonConstant;
+
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.annotation.Validated;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qianwen.core.log.exception.ServiceException;
import com.qianwen.core.secure.utils.AuthUtil;
import com.qianwen.core.tool.constant.BladeConstant;
import com.qianwen.core.tool.node.ForestNodeMerger;
import com.qianwen.core.tool.utils.CollectionUtil;
import com.qianwen.core.tool.utils.Func;
+import com.qianwen.smartman.common.constant.CommonConstant;
import com.qianwen.smartman.modules.system.entity.Role;
import com.qianwen.smartman.modules.system.entity.RoleMenu;
import com.qianwen.smartman.modules.system.entity.RoleScope;
@@ -29,9 +31,6 @@
import com.qianwen.smartman.modules.system.service.IRoleService;
import com.qianwen.smartman.modules.system.vo.RoleVO;
import com.qianwen.smartman.modules.system.wrapper.RoleWrapper;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.validation.annotation.Validated;
@Service
@Validated
@@ -39,165 +38,6 @@
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {
private final IRoleMenuService roleMenuService;
private final IRoleScopeService roleScopeService;
-
- private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
- String implMethodName = lambda.getImplMethodName();
- boolean z = true;
- switch (implMethodName.hashCode()) {
- case -1041904421:
- if (implMethodName.equals("getParentId")) {
- z = true;
- break;
- }
- break;
- case -787052612:
- if (implMethodName.equals("getScopeCategory")) {
- z = true;
- break;
- }
- break;
- case 98245393:
- if (implMethodName.equals("getId")) {
- z = true;
- break;
- }
- break;
- case 298479812:
- if (implMethodName.equals("getRoleAlias")) {
- z = true;
- break;
- }
- break;
- case 618292688:
- if (implMethodName.equals("getMenuId")) {
- z = true;
- break;
- }
- break;
- case 770598695:
- if (implMethodName.equals("getRoleId")) {
- z = true;
- break;
- }
- break;
- case 771206363:
- if (implMethodName.equals("getTenantId")) {
- z = true;
- break;
- }
- break;
- case 1811120535:
- if (implMethodName.equals("getRoleName")) {
- z = false;
- break;
- }
- break;
- }
- switch (z) {
- case false:
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Role") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
- return (v0) -> {
- return v0.getRoleName();
- };
- }
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Role") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
- return (v0) -> {
- return v0.getRoleName();
- };
- }
- break;
- case true:
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/RoleMenu") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
- return (v0) -> {
- return v0.getRoleId();
- };
- }
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/RoleMenu") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
- return (v0) -> {
- return v0.getRoleId();
- };
- }
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/RoleMenu") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
- return (v0) -> {
- return v0.getRoleId();
- };
- }
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/RoleScope") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
- return (v0) -> {
- return v0.getRoleId();
- };
- }
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/RoleScope") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
- return (v0) -> {
- return v0.getRoleId();
- };
- }
- break;
- case true:
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Role") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
- return (v0) -> {
- return v0.getId();
- };
- }
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Role") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
- return (v0) -> {
- return v0.getId();
- };
- }
- break;
- case true:
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/RoleMenu") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
- return (v0) -> {
- return v0.getMenuId();
- };
- }
- break;
- case true:
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/RoleScope") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
- return (v0) -> {
- return v0.getScopeCategory();
- };
- }
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/RoleScope") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
- return (v0) -> {
- return v0.getScopeCategory();
- };
- }
- break;
- case RegionCache.VILLAGE_LEVEL /* 5 */:
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Role") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
- return (v0) -> {
- return v0.getTenantId();
- };
- }
- break;
- case true:
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Role") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
- return (v0) -> {
- return v0.getRoleAlias();
- };
- }
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Role") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
- return (v0) -> {
- return v0.getRoleAlias();
- };
- }
- break;
- case true:
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Role") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
- return (v0) -> {
- return v0.getParentId();
- };
- }
- if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Role") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
- return (v0) -> {
- return v0.getParentId();
- };
- }
- break;
- }
- throw new IllegalArgumentException("Invalid lambda deserialization");
- }
public RoleServiceImpl(final IRoleMenuService roleMenuService, final IRoleScopeService roleScopeService) {
this.roleMenuService = roleMenuService;
@@ -229,25 +69,31 @@
}
private boolean grantRoleMenu(List<Long> roleIds, List<Long> menuIds) {
+ Long administratorCount = this.baseMapper.selectCount(Wrappers.<Role>query().lambda().eq(Role::getRoleAlias, "administrator").in(Role::getId, roleIds));
+ /*
Long administratorCount = ((RoleMapper) this.baseMapper).selectCount((Wrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> {
return v0.getRoleAlias();
}, "administrator")).in((v0) -> {
return v0.getId();
- }, roleIds));
+ }, roleIds));*/
if (!AuthUtil.isAdministrator() && administratorCount.longValue() > 0) {
throw new ServiceException("鏃犳潈閰嶇疆瓒呯瑙掕壊!");
}
+ Long adminCount = this.baseMapper.selectCount(Wrappers.<Role>query().lambda().eq(Role::getRoleAlias, "admin").in(Role::getId, roleIds));
+ /*
Long adminCount = ((RoleMapper) this.baseMapper).selectCount((Wrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> {
return v0.getRoleAlias();
}, "admin")).in((v0) -> {
return v0.getId();
- }, roleIds));
+ }, roleIds));*/
if (!AuthUtil.isAdmin() && adminCount.longValue() > 0) {
throw new ServiceException("鏃犳潈閰嶇疆绠$悊鍛樿鑹�!");
}
+ this.roleMenuService.remove(Wrappers.<RoleMenu>update().lambda().in(RoleMenu::getRoleId, roleIds));
+ /*
this.roleMenuService.remove((Wrapper) Wrappers.update().lambda().in((v0) -> {
return v0.getRoleId();
- }, roleIds));
+ }, roleIds));*/
List<RoleMenu> roleMenus = new ArrayList<>();
roleIds.forEach(roleId -> {
menuIds.forEach(menuId -> {
@@ -263,36 +109,33 @@
}
private void recursionRoleMenu(List<Long> roleIds, List<Long> menuIds) {
+ //Role::getParentId RoleMenu::getRoleId RoleMenu::getMenuId
roleIds.forEach(roleId -> {
- ((RoleMapper) this.baseMapper).selectList((Wrapper) Wrappers.query().lambda().eq((v0) -> {
- return v0.getParentId();
- }, roleId)).forEach(role -> {
- List<RoleMenu> roleMenuList = this.roleMenuService.list((Wrapper) Wrappers.query().lambda().eq((v0) -> {
- return v0.getRoleId();
- }, role.getId()));
- List<Long> collectRoleMenuIds = (List) roleMenuList.stream().map((v0) -> {
- return v0.getMenuId();
- }).filter(menuId -> {
- return !menuIds.contains(menuId);
- }).collect(Collectors.toList());
- if (collectRoleMenuIds.size() > 0) {
- this.roleMenuService.remove((Wrapper) ((LambdaUpdateWrapper) Wrappers.update().lambda().eq((v0) -> {
- return v0.getRoleId();
- }, role.getId())).in((v0) -> {
- return v0.getMenuId();
- }, collectRoleMenuIds));
- recursionRoleMenu(Collections.singletonList(role.getId()), menuIds);
- }
+ this.baseMapper.selectList( Wrappers.<Role>query().lambda().eq(Role::getParentId, roleId)).forEach(role -> {
+ List<RoleMenu> roleMenuList = this.roleMenuService.list(Wrappers.<RoleMenu>query().lambda().eq(RoleMenu::getRoleId, role.getId()));
+ List<Long> collectRoleMenuIds = roleMenuList.stream().map((v0) -> {
+ return v0.getMenuId();
+ }).filter(menuId -> {
+ return !menuIds.contains(menuId);
+ }).collect(Collectors.toList());
+
+ if (collectRoleMenuIds.size() > 0) {
+ this.roleMenuService.remove(Wrappers.<RoleMenu>update().lambda().eq(RoleMenu::getRoleId, role.getId()).in(RoleMenu::getMenuId, collectRoleMenuIds));
+ recursionRoleMenu(Collections.singletonList(role.getId()), menuIds);
+ }
});
});
}
private boolean grantDataScope(List<Long> roleIds, List<Long> dataScopeIds) {
+ this.roleScopeService.remove(Wrappers.<RoleScope>update().lambda()
+ .eq(RoleScope::getScopeCategory, CommonConstant.DATA_SCOPE_CATEGORY).in(RoleScope::getRoleId, roleIds));
+ /*
this.roleScopeService.remove((Wrapper) ((LambdaUpdateWrapper) Wrappers.update().lambda().eq((v0) -> {
return v0.getScopeCategory();
}, CommonConstant.DATA_SCOPE_CATEGORY)).in((v0) -> {
return v0.getRoleId();
- }, roleIds));
+ }, roleIds));*/
List<RoleScope> roleDataScopes = new ArrayList<>();
roleIds.forEach(roleId -> {
dataScopeIds.forEach(scopeId -> {
@@ -308,11 +151,14 @@
}
private boolean grantApiScope(List<Long> roleIds, List<Long> apiScopeIds) {
+ this.roleScopeService.remove(Wrappers.<RoleScope>update().lambda()
+ .eq(RoleScope::getScopeCategory, CommonConstant.API_SCOPE_CATEGORY).in(RoleScope::getRoleId, roleIds));
+ /*
this.roleScopeService.remove((Wrapper) ((LambdaUpdateWrapper) Wrappers.update().lambda().eq((v0) -> {
return v0.getScopeCategory();
}, CommonConstant.API_SCOPE_CATEGORY)).in((v0) -> {
return v0.getRoleId();
- }, roleIds));
+ }, roleIds));*/
List<RoleScope> roleApiScopes = new ArrayList<>();
roleIds.forEach(roleId -> {
apiScopeIds.forEach(scopeId -> {
@@ -329,11 +175,14 @@
@Override // org.springblade.modules.system.service.IRoleService
public String getRoleIds(String tenantId, String roleNames) {
+ List<Role> roleList = this.baseMapper.selectList(Wrappers.<Role>query().lambda().eq(Role::getTenantId, tenantId).in(Role::getRoleName, Func.toStrList(roleNames)));
+
+ /*
List<Role> roleList = ((RoleMapper) this.baseMapper).selectList((Wrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> {
return v0.getTenantId();
}, tenantId)).in((v0) -> {
return v0.getRoleName();
- }, Func.toStrList(roleNames)));
+ }, Func.toStrList(roleNames)));*/
if (roleList != null && roleList.size() > 0) {
return (String) roleList.stream().map(role -> {
return Func.toStr(role.getId());
@@ -375,7 +224,9 @@
@Override // org.springblade.modules.system.service.IRoleService
public List<RoleVO> search(String roleName, Long parentId) {
- Wrapper lambda = Wrappers.query().lambda();
+ LambdaQueryWrapper<Role> lambda = Wrappers.<Role>query().lambda();
+
+ //Wrapper lambda = Wrappers.query().lambda();
if (Func.isNotEmpty(roleName)) {
lambda.like((v0) -> {
return v0.getRoleName();
--
Gitblit v1.9.3