|
@@ -54,21 +54,41 @@ public class SysPersonController extends BaseController {
|
|
|
startPage();
|
|
startPage();
|
|
|
// 支持 fullName 模糊查询;其他字段保持按传入条件精确匹配
|
|
// 支持 fullName 模糊查询;其他字段保持按传入条件精确匹配
|
|
|
Long filterDeptId = person != null ? person.getDeptId() : null;
|
|
Long filterDeptId = person != null ? person.getDeptId() : null;
|
|
|
|
|
+ Long filterUserId = person != null ? person.getUserId() : null;
|
|
|
|
|
|
|
|
SysPerson queryEntity = new SysPerson();
|
|
SysPerson queryEntity = new SysPerson();
|
|
|
if (person != null) {
|
|
if (person != null) {
|
|
|
BeanUtils.copyProperties(person, queryEntity);
|
|
BeanUtils.copyProperties(person, queryEntity);
|
|
|
// fullName 用 like 查询,避免 Wrappers.query(entity) 产生 fullName=xxx 的精确条件
|
|
// fullName 用 like 查询,避免 Wrappers.query(entity) 产生 fullName=xxx 的精确条件
|
|
|
queryEntity.setFullName(null);
|
|
queryEntity.setFullName(null);
|
|
|
- // 部门、岗位以关联用户为准,不作为人员表列条件;部门筛选见下方按用户 dept_id 关联
|
|
|
|
|
|
|
+ // 部门、岗位、用户以关联表为准,不作为人员表列条件
|
|
|
queryEntity.setDeptId(null);
|
|
queryEntity.setDeptId(null);
|
|
|
queryEntity.setPostId(null);
|
|
queryEntity.setPostId(null);
|
|
|
|
|
+ queryEntity.setUserId(null);
|
|
|
}
|
|
}
|
|
|
QueryWrapper<SysPerson> queryWrapper = Wrappers.query(queryEntity);
|
|
QueryWrapper<SysPerson> queryWrapper = Wrappers.query(queryEntity);
|
|
|
queryWrapper.lambda()
|
|
queryWrapper.lambda()
|
|
|
.like(person != null && StringUtils.isNotBlank(person.getFullName()),
|
|
.like(person != null && StringUtils.isNotBlank(person.getFullName()),
|
|
|
SysPerson::getFullName, person.getFullName());
|
|
SysPerson::getFullName, person.getFullName());
|
|
|
|
|
|
|
|
|
|
+ // 按 userId 筛选:通过用户-人员关联表
|
|
|
|
|
+ if (filterUserId != null) {
|
|
|
|
|
+ List<SysUserPerson> userRelations = sysUserPersonService.list(
|
|
|
|
|
+ Wrappers.<SysUserPerson>lambdaQuery()
|
|
|
|
|
+ .eq(SysUserPerson::getUserId, filterUserId)
|
|
|
|
|
+ );
|
|
|
|
|
+ if (userRelations == null || userRelations.isEmpty()) {
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 按部门筛选:关联用户的 dept_id = filterDeptId
|
|
// 按部门筛选:关联用户的 dept_id = filterDeptId
|
|
|
if (filterDeptId != null) {
|
|
if (filterDeptId != null) {
|
|
|
LambdaQueryWrapper<SysUser> userQuery = Wrappers.<SysUser>lambdaQuery()
|
|
LambdaQueryWrapper<SysUser> userQuery = Wrappers.<SysUser>lambdaQuery()
|