系统管理员可以看见所有项目

项目可见性去掉系统管理员
master
xxssyyyyssxx 2021-11-30 18:35:04 +08:00
parent 1e0899891c
commit a3a344f8c9
2 changed files with 13 additions and 12 deletions

View File

@ -6,16 +6,10 @@ import java.util.Date;
@Entity
@Table(name = "sys_role")
public class SysRole {
//智慧工地系统管理员
public static final int ROLE_TYPE_1 = 1;
//市级管理员
public static final int ROLE_TYPE_2 = 2;
//环保局管理员
public static final int ROLE_TYPE_3 = 3;
//网格管理员
public static final int ROLE_TYPE_4 = 4;
//工地巡查员
public static final int ROLE_TYPE_8 = 8;
//系统管理员
public static final int ROLE_TYPE_SYSTEM = 0;
//普通管理员
public static final int ROLE_TYPE_NORMAL = 1;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)

View File

@ -105,8 +105,11 @@ public class ProjectService {
Admin admin = InterfaceUtil.getAdmin();
int roleId = admin.getRoleId();
Integer adminId = admin.getId();
//自己创建的肯定能看见
//自己创建的肯定能看见,配置的可以看见,系统管理员可以看见
SysRole sysRole = sysRoleRepository.findSysRoleById(roleId);
if(SysRole.ROLE_TYPE_SYSTEM != sysRole.getType()){
queryHelper.addCondition("(p.creator_id=? OR p.id in (SELECT pv1.project_id FROM project_visible pv1 WHERE pv1.type=1 AND pv1.tid=? UNION SELECT pv2.project_id FROM project_visible pv2 WHERE pv2.type=2 AND pv2.tid=?))", adminId, roleId, adminId);
}
queryHelper.addDescOrderProperty("p.last_update_time");
@ -239,6 +242,10 @@ public class ProjectService {
*/
public List<ZTreeNode> getZTreeNodes(int projectId){
List<SysRole> roleList = sysRoleRepository.findAllRole();
//过滤掉系统管理员角色
roleList = roleList.stream().filter(sysRole -> sysRole.getType()!=SysRole.ROLE_TYPE_SYSTEM).collect(Collectors.toList());
List<Admin> adminList = adminRepository.getAllEnable();
List<ZTreeNode> zTreeNodes = new ArrayList<>(roleList.size()+adminList.size());