package com.qianwen.smartman.modules.system.wrapper;
|
|
import java.util.List;
|
import java.util.Objects;
|
import java.util.stream.Collectors;
|
import com.qianwen.smartman.common.cache.DictCache;
|
import com.qianwen.smartman.common.cache.SysCache;
|
import com.qianwen.smartman.common.enums.DictEnum;
|
import com.qianwen.core.mp.support.BaseEntityWrapper;
|
import com.qianwen.core.tool.constant.BladeConstant;
|
import com.qianwen.core.tool.node.ForestNodeMerger;
|
import com.qianwen.core.tool.utils.BeanUtil;
|
import com.qianwen.core.tool.utils.Func;
|
import com.qianwen.smartman.modules.system.entity.Dept;
|
import com.qianwen.smartman.modules.system.vo.DeptVO;
|
|
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/system/wrapper/DeptWrapper.class */
|
public class DeptWrapper extends BaseEntityWrapper<Dept, DeptVO> {
|
public static DeptWrapper build() {
|
return new DeptWrapper();
|
}
|
|
public DeptVO entityVO(Dept dept) {
|
DeptVO deptVO = (DeptVO) Objects.requireNonNull(BeanUtil.copy(dept, DeptVO.class));
|
if (Func.equals(dept.getParentId(), BladeConstant.TOP_PARENT_ID)) {
|
deptVO.setParentName("顶级");
|
} else {
|
Dept parent = SysCache.getDept(dept.getParentId());
|
deptVO.setParentName(parent.getDeptName());
|
}
|
String category = DictCache.getValue(DictEnum.DATA_SCOPE_CATEGORY, dept.getDeptCategory());
|
deptVO.setDeptCategoryName(category);
|
return deptVO;
|
}
|
|
public List<DeptVO> listNodeVO(List<Dept> list) {
|
List<DeptVO> collect = (List) list.stream().map(dept -> {
|
DeptVO deptVO = (DeptVO) BeanUtil.copy(dept, DeptVO.class);
|
String category = DictCache.getValue(DictEnum.DATA_SCOPE_CATEGORY, dept.getDeptCategory());
|
((DeptVO) Objects.requireNonNull(deptVO)).setDeptCategoryName(category);
|
return deptVO;
|
}).collect(Collectors.toList());
|
return ForestNodeMerger.merge(collect);
|
}
|
|
public List<DeptVO> listNodeLazyVO(List<DeptVO> list) {
|
List<DeptVO> collect = (List) list.stream().peek(dept -> {
|
String category = DictCache.getValue(DictEnum.DATA_SCOPE_CATEGORY, dept.getDeptCategory());
|
((DeptVO) Objects.requireNonNull(dept)).setDeptCategoryName(category);
|
}).collect(Collectors.toList());
|
return ForestNodeMerger.merge(collect);
|
}
|
}
|