wzy
2022-08-14 b141df9bf9764db8567efebed48006e12ab1f657
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
package com.xzx.gc.role.rbac.da;
 
 
import com.xzx.gc.role.rbac.AccessType;
import com.xzx.gc.role.rbac.DataAccess;
import com.xzx.gc.role.rbac.DataAccessResullt;
import com.xzx.gc.role.rbac.tree.OrgItem;
import com.xzx.gc.role.service.CorePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * 集团公司所有,但不包含集团下的公司,仅仅集团职能部门
 * @author lijiazhi
 *
 */
@Component
public class GroupOnlyDataAccess implements DataAccess {
    
    @Autowired
    CorePlatformService platformService;
 
    @Override
    public DataAccessResullt getOrg(Long userId, Long orgId) {
        OrgItem root = platformService.buildOrg();
        OrgItem company  = root.findChild(orgId);
        OrgItem group = root.findParentOrgItem(DefaultDataAccessFactory.GROUP_TYPE);
        //排除集团下的所有公司
        List<OrgItem> all = group.findAllChildOrgItem(null,DefaultDataAccessFactory.COMPANY_TYPE);
        List<Long> list = new ArrayList<Long>(all.size());
        for(OrgItem org:all){
            list.add(org.getId());
        }
        
        DataAccessResullt ret = new DataAccessResullt();
        ret.setStatus(AccessType.OnlyOrg);
        ret.setOrgIds(list);
        return ret;
        
    }
 
    @Override
    public String getName() {
        return "仅集团部门";
    }
 
    @Override
    public Integer getType() {
        return 8;
    }
 
}