Helius
2021-06-16 5728be2af515b2200e782aa201ca5d4d67d9ea47
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package com.ibeetl.admin.console.service;
 
 
import com.ibeetl.admin.console.dao.XzxUserAuthInfoDao;
import com.ibeetl.admin.core.entity.CoreFunction;
import com.ibeetl.admin.core.entity.XzxUserAuthInfo;
import com.ibeetl.admin.core.rbac.tree.FunctionItem;
import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.util.FunctionBuildUtil;
import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.admin.core.web.dto.FunctionNodeView;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.ArrayList;
import java.util.List;
/**
 * XzxUserAuthInfo Service
 */
 
@Service
@Transactional
public class XzxUserAuthInfoService extends CoreBaseService<XzxUserAuthInfo>{
 
    @Autowired private XzxUserAuthInfoDao xzxUserAuthInfoDao;
 
    public PageQuery<XzxUserAuthInfo>queryByCondition(PageQuery query){
        PageQuery ret =  xzxUserAuthInfoDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }
    public List<FunctionNodeView> buildViewList() {
        List<FunctionNodeView> viewList = new ArrayList<>();
        List<XzxUserAuthInfo> list = xzxUserAuthInfoDao.all();
        //由于表设计原因前端顶层已经写死,如有需求从此次开始修改
        //客户管理
        FunctionNodeView userManager= new FunctionNodeView();
        userManager.setCode("KH");
        userManager.setName("客户管理");
        userManager.setId(Long.parseLong("10000"));
        List<FunctionNodeView> userChildren = new ArrayList<>();
        //数据统计
        FunctionNodeView dateManager= new FunctionNodeView();
        dateManager.setCode("SJ");
        dateManager.setName("数据统计");
        dateManager.setId(Long.parseLong("10001"));
        List<FunctionNodeView> dateChildren = new ArrayList<>();
        //物品价格
        FunctionNodeView productManager= new FunctionNodeView();
        productManager.setCode("WP");
        productManager.setName("物品价格");
        productManager.setId(Long.parseLong("10002"));
        List<FunctionNodeView> productChildren = new ArrayList<>();
        for (XzxUserAuthInfo authInfo:list) {
            /*FunctionNodeView view = new FunctionNodeView();
            view.setName(authInfo.getAuthName());
            view.setCode(authInfo.getAuthCode());
            view.setId(authInfo.getId());*/
 
           if(authInfo.getCategoryCode().equals(userManager.getCode())){
               FunctionNodeView uc = new FunctionNodeView();
               uc.setName(authInfo.getAuthName());
               uc.setCode(authInfo.getAuthCode());
               uc.setId(authInfo.getId());
               userChildren.add(uc);
           }else if(authInfo.getCategoryCode().equals(dateManager.getCode())){
               FunctionNodeView uc = new FunctionNodeView();
               uc.setName(authInfo.getAuthName());
               uc.setCode(authInfo.getAuthCode());
               uc.setId(authInfo.getId());
               dateChildren.add(uc);
           }else{
               FunctionNodeView uc = new FunctionNodeView();
               uc.setName(authInfo.getAuthName());
               uc.setCode(authInfo.getAuthCode());
               uc.setId(authInfo.getId());
               productChildren.add(uc);
           }
            //viewList.add(view);
        }
        userManager.setChildren(userChildren);
        dateManager.setChildren(dateChildren);
        productManager.setChildren(productChildren);
        viewList.add(userManager);
        viewList.add(dateManager);
        viewList.add(productManager);
        return viewList;
    }
 
    public void batchDelXzxUserAuthInfo(List<Long> ids){
        try {
            xzxUserAuthInfoDao.batchDelXzxUserAuthInfoByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除XzxUserAuthInfo失败", e);
        }
    }
}