feat:add multiple dept support
This commit is contained in:
parent
f89381d318
commit
3edae0ce7e
@ -59,7 +59,7 @@ public class AuthPermissionInfoRespVO {
|
||||
* 枚举 {@link com.ensign.crm.framework.common.enums.CrmFunctionEnum}
|
||||
*/
|
||||
@Schema(description = "CRM职能", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
||||
private Integer crmUserFunction;
|
||||
private String crmUserFunction;
|
||||
}
|
||||
|
||||
@Schema(description = "管理后台 - 登录用户的菜单信息 Response VO")
|
||||
|
@ -109,5 +109,10 @@ public class AdminUserDO extends TenantBaseDO {
|
||||
* CRM职能
|
||||
* 枚举 {@link com.ensign.crm.framework.common.enums.CrmFunctionEnum}
|
||||
*/
|
||||
private Integer crmUserFunction;
|
||||
private String crmUserFunction;
|
||||
|
||||
/**
|
||||
* 部门id,拼接
|
||||
*/
|
||||
private String deptIdColl;
|
||||
}
|
||||
|
@ -26,13 +26,35 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
|
||||
}
|
||||
|
||||
default PageResult<AdminUserDO> selectPage(UserPageReqVO reqVO, Collection<Long> deptIds) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<AdminUserDO>()
|
||||
|
||||
LambdaQueryWrapperX<AdminUserDO> queryWrapper = new LambdaQueryWrapperX<>();
|
||||
|
||||
queryWrapper
|
||||
.likeIfPresent(AdminUserDO::getUsername, reqVO.getUsername())
|
||||
.likeIfPresent(AdminUserDO::getMobile, reqVO.getMobile())
|
||||
.eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime())
|
||||
.inIfPresent(AdminUserDO::getDeptId, deptIds)
|
||||
.orderByDesc(AdminUserDO::getId));
|
||||
.betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime());
|
||||
|
||||
if (deptIds != null && !deptIds.isEmpty()) {
|
||||
StringBuilder likeCondition = new StringBuilder();
|
||||
for (Long deptId : deptIds) {
|
||||
if (likeCondition.length() > 0) {
|
||||
likeCondition.append(" OR ");
|
||||
}
|
||||
likeCondition.append("dept_id_coll LIKE '%").append(deptId).append("%'");
|
||||
}
|
||||
queryWrapper.and(q -> q.apply(likeCondition.toString()));
|
||||
}
|
||||
|
||||
return selectPage(reqVO, queryWrapper.orderByDesc(AdminUserDO::getId));
|
||||
|
||||
// return selectPage(reqVO, new LambdaQueryWrapperX<AdminUserDO>()
|
||||
// .likeIfPresent(AdminUserDO::getUsername, reqVO.getUsername())
|
||||
// .likeIfPresent(AdminUserDO::getMobile, reqVO.getMobile())
|
||||
// .eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus())
|
||||
// .betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime())
|
||||
// .inIfPresent(AdminUserDO::getDeptId, deptIds)
|
||||
// .orderByDesc(AdminUserDO::getId));
|
||||
}
|
||||
|
||||
default List<AdminUserDO> selectListByNickname(String nickname) {
|
||||
|
@ -26,6 +26,7 @@ import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
@ -35,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.ensign.crm.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static com.ensign.crm.framework.common.util.json.JsonUtils.toJsonString;
|
||||
@ -344,13 +346,10 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
@Override
|
||||
@CacheEvict(value = RedisKeyConstants.USER_ROLE_ID_LIST, key = "#user.id")
|
||||
public void assignPermissions(AdminUserDO user) {
|
||||
Integer userFunction = user.getCrmUserFunction();
|
||||
String userFunction = user.getCrmUserFunction();
|
||||
if (userFunction == null) {
|
||||
return;
|
||||
}
|
||||
if (!"12345".contains(userFunction.toString())) {
|
||||
return;
|
||||
}
|
||||
Long userId = user.getId();
|
||||
List<String> rules = getRoleList(userFunction);
|
||||
Set<String> noRoles = new HashSet<>();
|
||||
@ -371,26 +370,27 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
assignUserRole(user.getId(), ids);
|
||||
}
|
||||
|
||||
private List<String> getRoleList(Integer userFunction) {
|
||||
List<String> roles = new ArrayList<>();
|
||||
private List<String> getRoleList(String userFunction) {
|
||||
Set<String> roles = new HashSet<>();
|
||||
roles.add("crmuser");
|
||||
switch (userFunction) {
|
||||
case 1:
|
||||
roles.addAll(UserFunctionRoleEnum.get(1, 2, 3, 4, 5));
|
||||
break;
|
||||
case 2:
|
||||
roles.addAll(UserFunctionRoleEnum.get(2, 3, 4, 5));
|
||||
break;
|
||||
case 3:
|
||||
roles.addAll(UserFunctionRoleEnum.get(3, 4, 5));
|
||||
break;
|
||||
case 4:
|
||||
roles.addAll(UserFunctionRoleEnum.get(4, 5));
|
||||
break;
|
||||
case 5:
|
||||
roles.addAll(UserFunctionRoleEnum.get(5));
|
||||
break;
|
||||
String[] split = userFunction.split(",");
|
||||
List<String> funcs = Arrays.stream(split).filter(StringUtils::isNoneBlank).collect(Collectors.toList());
|
||||
if (funcs.contains("1")) {
|
||||
roles.addAll(UserFunctionRoleEnum.get(1, 2, 3, 4, 5));
|
||||
}
|
||||
return roles;
|
||||
if (funcs.contains("2")) {
|
||||
roles.addAll(UserFunctionRoleEnum.get(2, 3, 4, 5));
|
||||
}
|
||||
if (funcs.contains("3")) {
|
||||
roles.addAll(UserFunctionRoleEnum.get(3, 4, 5));
|
||||
}
|
||||
if (funcs.contains("4")) {
|
||||
roles.addAll(UserFunctionRoleEnum.get(4, 5));
|
||||
}
|
||||
if (funcs.contains("5")) {
|
||||
roles.addAll(UserFunctionRoleEnum.get(5));
|
||||
}
|
||||
|
||||
return new ArrayList<>(roles);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user