|
|
@@ -77,14 +77,15 @@ public class SysPersonController extends BaseController {
|
|
|
Wrappers.<SysUserPerson>lambdaQuery()
|
|
|
.eq(SysUserPerson::getUserId, filterUserId)
|
|
|
);
|
|
|
- if (userRelations == null || userRelations.isEmpty()) {
|
|
|
+ List<Integer> userPersonIds = userRelations == null ? null : userRelations.stream()
|
|
|
+ .map(SysUserPerson::getPersonId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (userPersonIds == null || userPersonIds.isEmpty()) {
|
|
|
+ // 避免 MyBatis-Plus 生成 id IN () 语法错误
|
|
|
queryWrapper.apply("1 = 0");
|
|
|
} else {
|
|
|
- List<Integer> userPersonIds = userRelations.stream()
|
|
|
- .map(SysUserPerson::getPersonId)
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .distinct()
|
|
|
- .collect(Collectors.toList());
|
|
|
queryWrapper.lambda().in(SysPerson::getId, userPersonIds);
|
|
|
}
|
|
|
}
|
|
|
@@ -99,26 +100,26 @@ public class SysPersonController extends BaseController {
|
|
|
userQuery.eq(SysUser::getTenantId, tenantId);
|
|
|
}
|
|
|
List<SysUser> deptUsers = sysUserService.list(userQuery);
|
|
|
- if (deptUsers == null || deptUsers.isEmpty()) {
|
|
|
+ List<Long> userIds = deptUsers == null ? null : deptUsers.stream()
|
|
|
+ .map(SysUser::getUserId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (userIds == null || userIds.isEmpty()) {
|
|
|
queryWrapper.apply("1 = 0");
|
|
|
} else {
|
|
|
- List<Long> userIds = deptUsers.stream()
|
|
|
- .map(SysUser::getUserId)
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .distinct()
|
|
|
- .collect(Collectors.toList());
|
|
|
List<SysUserPerson> deptRelations = sysUserPersonService.list(
|
|
|
Wrappers.<SysUserPerson>lambdaQuery()
|
|
|
.in(SysUserPerson::getUserId, userIds)
|
|
|
);
|
|
|
- if (deptRelations == null || deptRelations.isEmpty()) {
|
|
|
+ List<Integer> deptPersonIds = deptRelations == null ? null : deptRelations.stream()
|
|
|
+ .map(SysUserPerson::getPersonId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (deptPersonIds == null || deptPersonIds.isEmpty()) {
|
|
|
queryWrapper.apply("1 = 0");
|
|
|
} else {
|
|
|
- List<Integer> deptPersonIds = deptRelations.stream()
|
|
|
- .map(SysUserPerson::getPersonId)
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .distinct()
|
|
|
- .collect(Collectors.toList());
|
|
|
queryWrapper.lambda().in(SysPerson::getId, deptPersonIds);
|
|
|
}
|
|
|
}
|