yangys
2024-04-04 ed4a5236bab800094be4a8378f5098eebe3de6ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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);
    }
}