调整组织结构展示
This commit is contained in:
parent
869914819c
commit
0a23640a0f
|
|
@ -196,20 +196,27 @@ public class DepartmentController extends ControllerBase {
|
|||
* @param id 部门id
|
||||
*/
|
||||
@GetMapping("getChildren")
|
||||
public ApiResult<DepartmentChildVO> getChildren(@RequestParam Long id) {
|
||||
public ApiResult<List<DepartmentChildItemVO>> getChildren(@RequestParam Long id) {
|
||||
List<TBaseDepartment> departments = departmentService.lambdaQuery().eq(TBaseDepartment::getDataValidStatus, 1).list();
|
||||
TBaseDepartment department = departments.stream().filter(u -> u.getId().equals(id)).findFirst().orElse(null);
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(department)).throwMessage("部门不存在");
|
||||
List<DepartmentChildItemVO> itemVOS = new ArrayList<>();
|
||||
List<DepartmentChildItemVO> vos = new ArrayList<>();
|
||||
List<DepartmentChildItemVO> users = departmentService.getUsers(id);
|
||||
if (CollUtil.isNotEmpty(users)) {
|
||||
itemVOS.addAll(users);
|
||||
List<DepartmentSimpleVO> paths = new ArrayList<>();
|
||||
paths.add(new DepartmentSimpleVO()
|
||||
.setId(department.getId())
|
||||
.setName(department.getDeptName())
|
||||
);
|
||||
bindParent(paths, department, departments);
|
||||
users.forEach(u->u.setPaths(paths));
|
||||
vos.addAll(users);
|
||||
}
|
||||
List<TBaseDepartment> childs = departments.stream()
|
||||
.filter(di -> Objects.equals(di.getDeptParentId(), id))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(childs)) {
|
||||
itemVOS.addAll(
|
||||
vos.addAll(
|
||||
childs.stream().map(c -> new DepartmentChildItemVO()
|
||||
.setId(c.getId())
|
||||
.setName(c.getDeptName())
|
||||
|
|
@ -223,16 +230,7 @@ public class DepartmentController extends ControllerBase {
|
|||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
List<DepartmentSimpleVO> paths = new ArrayList<>();
|
||||
paths.add(new DepartmentSimpleVO()
|
||||
.setId(department.getId())
|
||||
.setName(department.getDeptName())
|
||||
);
|
||||
bindParent(paths, department, departments);
|
||||
return ApiResult.success(new DepartmentChildVO()
|
||||
.setPaths(paths)
|
||||
.setItems(itemVOS)
|
||||
);
|
||||
return ApiResult.success(vos);
|
||||
}
|
||||
|
||||
private void bindParent(List<DepartmentSimpleVO> paths, TBaseDepartment department, List<TBaseDepartment> departments) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import lombok.Data;
|
|||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
|
|
@ -47,4 +48,9 @@ public class DepartmentChildItemVO {
|
|||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
private List<DepartmentSimpleVO> paths;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,6 @@ import java.util.List;
|
|||
@Accessors(chain = true)
|
||||
public class DepartmentChildVO {
|
||||
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
private List<DepartmentSimpleVO> paths;
|
||||
|
||||
/**
|
||||
* 子级
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,15 +19,7 @@
|
|||
<include refid="whr"/>
|
||||
</select>
|
||||
<select id="getUsers" resultType="com.nflg.mobilebroken.common.pojo.vo.DepartmentChildItemVO">
|
||||
SELECT id,
|
||||
user_name as 'name',
|
||||
1 as 'type',
|
||||
type as 'userType',
|
||||
state,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time
|
||||
SELECT id,user_name as 'name',1 as 'type',type as 'userType',state,create_by,create_time,update_by,update_time
|
||||
FROM v_all_user
|
||||
WHERE department_id = #{id}
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in New Issue