[代码优化](v2.6):update UserController

pull/605/head^2
Zheng Jie 2021-03-02 21:39:40 +08:00
parent 162cff269b
commit d8a458cafa
1 changed files with 5 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import me.zhengjie.config.RsaProperties;
import me.zhengjie.modules.system.domain.Dept;
import me.zhengjie.modules.system.service.DataService;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.exception.BadRequestException;
@ -79,7 +80,10 @@ public class UserController {
public ResponseEntity<Object> query(UserQueryCriteria criteria, Pageable pageable){
if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
criteria.getDeptIds().add(criteria.getDeptId());
criteria.getDeptIds().addAll(deptService.getDeptChildren(deptService.findByPid(criteria.getDeptId())));
// 先查找是否存在子节点
List<Dept> data = deptService.findByPid(criteria.getDeptId());
// 然后把子节点的ID都加入到集合中
criteria.getDeptIds().addAll(deptService.getDeptChildren(data));
}
// 数据权限
List<Long> dataScopes = dataService.getDeptIds(userService.findByName(SecurityUtils.getCurrentUsername()));