|
@@ -16,15 +16,13 @@ import com.dayou.constants.JwtConstants;
|
|
|
import com.dayou.dto.LoginDTO;
|
|
|
import com.dayou.dto.UpdatePasswordDTO;
|
|
|
import com.dayou.dto.UserBaseDetailDTO;
|
|
|
+import com.dayou.entity.Post;
|
|
|
import com.dayou.entity.PostPrivilege;
|
|
|
import com.dayou.entity.User;
|
|
|
import com.dayou.entity.UserPost;
|
|
|
import com.dayou.exception.ErrorCode;
|
|
|
import com.dayou.mapper.UserMapper;
|
|
|
-import com.dayou.service.IMenuService;
|
|
|
-import com.dayou.service.IPostPrivilegeService;
|
|
|
-import com.dayou.service.IUserPostService;
|
|
|
-import com.dayou.service.IUserService;
|
|
|
+import com.dayou.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.dayou.utils.*;
|
|
|
import com.dayou.vo.IdNameVO;
|
|
@@ -49,6 +47,7 @@ import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.text.BreakIterator;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -103,6 +102,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
@Autowired
|
|
|
private IMenuService menuService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IPostService postService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
@SuppressWarnings("unchecked")
|
|
@@ -389,4 +391,42 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
.eq(BaseEntity::getId, user.getId()));
|
|
|
return update;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Set<Long> getJuniorUserId(Long userId) {
|
|
|
+ Set<Long> juniorUser = new HashSet<>();
|
|
|
+ Set<Long> juniorPost = new HashSet<>();
|
|
|
+ //当前登录人拥有的岗位集合
|
|
|
+ Set<Long> postIds = userPostService.getPostList(userId).stream().map(SimpleListModel::getId).collect(Collectors.toSet());
|
|
|
+ if (CollectionUtils.isNotEmpty(postIds)){
|
|
|
+ //获取登录人岗位的下属岗位
|
|
|
+ juniorPost = findJuniorPost(postIds,juniorPost);
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(juniorPost)){
|
|
|
+ //获取下属岗位的员工
|
|
|
+ juniorUser = userPostService.list(new LambdaQueryWrapper<UserPost>().select(UserPost::getUserId).in(UserPost::getPostId, juniorPost)
|
|
|
+ .eq(BaseEntity::getDeleted,Boolean.FALSE))
|
|
|
+ .stream().map(UserPost::getUserId).collect(Collectors.toSet());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return juniorUser;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 递归查询下级岗位
|
|
|
+ * @param postIds
|
|
|
+ * @param juniorPost
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Set<Long> findJuniorPost(Set<Long> postIds,Set<Long> juniorPost){
|
|
|
+ Set<Long> collect = postService.list(new LambdaQueryWrapper<Post>().select(BaseEntity::getId)
|
|
|
+ .in(Post::getParentId, postIds).eq(BaseEntity::getDeleted, Boolean.FALSE)).stream().map(BaseEntity::getId).collect(Collectors.toSet());
|
|
|
+ if (CollectionUtils.isEmpty(collect)){
|
|
|
+ return juniorPost;
|
|
|
+ }else {
|
|
|
+ juniorPost.addAll(collect);
|
|
|
+ findJuniorPost(collect,juniorPost);
|
|
|
+ }
|
|
|
+ return juniorPost;
|
|
|
+ }
|
|
|
}
|