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