viewer权限
This commit is contained in:
+9
@@ -1752,4 +1752,13 @@ public class SysUserController {
|
||||
List<SysUser> sysUserList = sysUserService.querySysUserListByIdList(userIdList);
|
||||
return sysUserList;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户管理-查出所有部门及其用户")
|
||||
@GetMapping(value = "/queryViewerInfo")
|
||||
public ViewerInfoVo queryViewerInfoVo(@RequestParam(name = "userId", required = true) String userId){
|
||||
ViewerInfoVo viewerInfoVo = new ViewerInfoVo();
|
||||
viewerInfoVo.setBrandList(projectUserBrandService.queryBrandByUserId(userId));
|
||||
viewerInfoVo.setDutyTerritoryList(projectUserDutyTerritoryService.queryDutyTerritoryByUserId(userId));
|
||||
return viewerInfoVo;
|
||||
}
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.jero.modules.system.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ViewerInfoVo {
|
||||
|
||||
List<String> brandList;
|
||||
List<String> dutyTerritoryList;
|
||||
|
||||
public List<String> getBrandList() {
|
||||
return brandList;
|
||||
}
|
||||
|
||||
public void setBrandList(List<String> brandList) {
|
||||
this.brandList = brandList;
|
||||
}
|
||||
|
||||
public List<String> getDutyTerritoryList() {
|
||||
return dutyTerritoryList;
|
||||
}
|
||||
|
||||
public void setDutyTerritoryList(List<String> dutyTerritoryList) {
|
||||
this.dutyTerritoryList = dutyTerritoryList;
|
||||
}
|
||||
|
||||
public ViewerInfoVo() {
|
||||
}
|
||||
|
||||
public ViewerInfoVo(List<String> brandList, List<String> dutyTerritoryList) {
|
||||
this.brandList = brandList;
|
||||
this.dutyTerritoryList = dutyTerritoryList;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@ public enum ProjectRoleEnum {
|
||||
REGULATI_AND_HOMOLOGATION_ENGINEER("法规工程师/认证工程师","4","Regulatory Engineer/Certification Engineer"),
|
||||
MANAGER("领导角色","11","R&H Manager"),
|
||||
ADMIN("系统管理员","12","admin"),
|
||||
VIEWER("Viewer","","Viewer"),
|
||||
VIEWER("Viewer","13","Viewer"),
|
||||
;
|
||||
|
||||
String name;
|
||||
|
||||
+2
@@ -42,4 +42,6 @@ public interface IProjectUserBrandService extends IService<ProjectUserBrand> {
|
||||
* @return
|
||||
*/
|
||||
List<ProjectUserBrand> queryList();
|
||||
|
||||
List<String> queryBrandByUserId(String userId);
|
||||
}
|
||||
|
||||
+8
@@ -42,4 +42,12 @@ public interface IProjectUserDutyTerritoryService extends IService<ProjectUserDu
|
||||
* @return
|
||||
*/
|
||||
List<ProjectUserDutyTerritory> queryList();
|
||||
|
||||
/**
|
||||
* 根据id查询对应的dutyTerritory集合
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<String> queryDutyTerritoryByUserId(String userId);
|
||||
|
||||
}
|
||||
|
||||
+14
@@ -1,10 +1,13 @@
|
||||
package com.jero.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jero.modules.system.entity.ProjectUserBrand;
|
||||
import com.jero.modules.system.mapper.ProjectUserBrandMapper;
|
||||
import com.jero.modules.system.service.IProjectUserBrandService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
@@ -59,4 +62,15 @@ public class ProjectUserBrandServiceImpl extends ServiceImpl<ProjectUserBrandMap
|
||||
public List<ProjectUserBrand> queryList() {
|
||||
return list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryBrandByUserId(String userId) {
|
||||
QueryWrapper<ProjectUserBrand> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", userId);
|
||||
List<ProjectUserBrand> list = list(queryWrapper);
|
||||
if (ObjectUtils.isNotEmpty(list)) {
|
||||
return list.stream().map(ProjectUserBrand::getBrandType).collect(Collectors.toList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+21
@@ -1,10 +1,15 @@
|
||||
package com.jero.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jero.modules.system.entity.ProjectUserDutyTerritory;
|
||||
import com.jero.modules.system.mapper.ProjectUserDutyTerritoryMapper;
|
||||
import com.jero.modules.system.service.IProjectUserDutyTerritoryService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
@@ -59,4 +64,20 @@ public class ProjectUserDutyTerritoryServiceImpl extends ServiceImpl<ProjectUser
|
||||
public List<ProjectUserDutyTerritory> queryList() {
|
||||
return list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询对应的dutyTerritory集合
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> queryDutyTerritoryByUserId(String userId) {
|
||||
QueryWrapper<ProjectUserDutyTerritory> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", userId);
|
||||
List<ProjectUserDutyTerritory> list = list(queryWrapper);
|
||||
if (ObjectUtils.isNotEmpty(list)) {
|
||||
return list.stream().map(ProjectUserDutyTerritory::getDutyTerritory).collect(Collectors.toList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ public enum ProjectRoleEnum {
|
||||
VERIFYDUTY("验证符合性确认-责任人","10",""),
|
||||
MANAGER("验证符合性确认-责任人","11",""),
|
||||
ADMIN("系统管理员","12",""),
|
||||
VIEWER("Viewer","",""),
|
||||
VIEWER("Viewer","13",""),
|
||||
;
|
||||
|
||||
String name;
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package com.jero.modules.project.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.jero.modules.project.entity.ProjectUserPermission;
|
||||
@@ -15,5 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
public interface ProjectUserPermissionMapper extends BaseMapper<ProjectUserPermission> {
|
||||
|
||||
|
||||
List<String> queryProjectIdsByUserId(@Param("userId") String userId);
|
||||
Set<String> queryProjectIdsByUserId(@Param("userId") String userId);
|
||||
}
|
||||
|
||||
+15
-1
@@ -58,6 +58,7 @@ import com.jero.modules.system.mapper.SysCategoryMapper;
|
||||
import com.jero.modules.system.mapper.SysDictItemMapper;
|
||||
import com.jero.modules.system.mapper.SysRoleMapper;
|
||||
import com.jero.modules.system.mapper.SysUserMapper;
|
||||
import com.jero.modules.system.service.IProjectUserDutyTerritoryService;
|
||||
import com.jero.modules.system.service.ISysAnnouncementService;
|
||||
import com.jero.modules.system.service.ISysUserService;
|
||||
import com.jero.modules.system.service.impl.SysCategoryServiceImpl;
|
||||
@@ -242,6 +243,9 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
|
||||
@Autowired
|
||||
private IProjectUserPermissionService projectUserPermissionService;
|
||||
|
||||
@Autowired
|
||||
private IProjectUserDutyTerritoryService projectUserDutyTerritoryService;
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
@@ -843,13 +847,23 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
|
||||
|
||||
if(isProjectRole != Integer.parseInt(ProjectRoleEnum.STUDIO_ENGINEER.getValue())
|
||||
&& isProjectRole != Integer.parseInt(ProjectRoleEnum.MANAGER.getValue())
|
||||
&& isProjectRole != Integer.parseInt(ProjectRoleEnum.ADMIN.getValue())){
|
||||
&& isProjectRole != Integer.parseInt(ProjectRoleEnum.ADMIN.getValue())
|
||||
&& isProjectRole != Integer.parseInt(ProjectRoleEnum.VIEWER.getValue())){
|
||||
projectLawsInventoryEOQueryWrapper.and(queryWrapper ->{
|
||||
queryWrapper.eq("regulation_owner_id",currentUser.getId()).
|
||||
or().eq("homologation_engineer_id",currentUser.getId());
|
||||
});
|
||||
}
|
||||
List<ProjectLawsInventoryEO> result = super.baseMapper.selectList(projectLawsInventoryEOQueryWrapper);
|
||||
if (isProjectRole == Integer.parseInt(ProjectRoleEnum.VIEWER.getValue())) {
|
||||
//查当前用户Viewer对应责任领域
|
||||
List<String> dutyTerritoryList = projectUserDutyTerritoryService.queryDutyTerritoryByUserId(currentUser.getId());
|
||||
if (ObjectUtils.isNotEmpty(dutyTerritoryList)) {
|
||||
result = result.stream().filter(e -> dutyTerritoryList.contains(e.getDutyTerritory())).collect(Collectors.toList());
|
||||
} else {
|
||||
result = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
dataDispose(result,currentUser,isProjectRole,projectLawsInventoryEO.getCut());
|
||||
long startTime = System.currentTimeMillis();
|
||||
dataDictDispose(result,projectLawsInventoryEO.getCut());
|
||||
|
||||
+17
-13
@@ -24,6 +24,7 @@ import com.jero.modules.system.enums.DicCodeEnum;
|
||||
import com.jero.modules.system.mapper.SysDictItemMapper;
|
||||
import com.jero.modules.system.mapper.SysRoleMapper;
|
||||
import com.jero.modules.system.mapper.SysUserMapper;
|
||||
import com.jero.modules.system.service.IProjectUserBrandService;
|
||||
import com.jero.modules.system.service.ISysDictService;
|
||||
import com.jero.modules.system.service.ISysUserService;
|
||||
import com.jero.modules.system.service.impl.SysDictItemServiceImpl;
|
||||
@@ -46,15 +47,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -126,6 +119,9 @@ public class ProjectLibraryBaseServiceImpl extends ServiceImpl<ProjectLibraryBas
|
||||
@Autowired
|
||||
private ProjectUserPermissionMapper projectUserPermissionMapper;
|
||||
|
||||
@Autowired
|
||||
private IProjectUserBrandService projectUserBrandService;
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
@@ -725,10 +721,18 @@ public class ProjectLibraryBaseServiceImpl extends ServiceImpl<ProjectLibraryBas
|
||||
@Override
|
||||
public List<ProjectLibraryBase> queryPageList(Map<String,Object> params) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
List<String> projectIds = new ArrayList<>();
|
||||
if (sysRoleMapper.queryUserRoleByCode(ProjectRoleEnum.VIEWER.getName(), loginUser.getId()) == 0) {
|
||||
//如果不是Viewer,根据项目用户权限表筛选有权访问的项目
|
||||
projectIds = projectUserPermissionMapper.queryProjectIdsByUserId(loginUser.getId());
|
||||
//根据项目用户权限表筛选有权访问的项目
|
||||
Set<String> projectIds = projectUserPermissionMapper.queryProjectIdsByUserId(loginUser.getId());
|
||||
if (sysRoleMapper.queryUserRoleByCode(ProjectRoleEnum.VIEWER.getName(), loginUser.getId()) > 0) {
|
||||
//如果是Viewer,根据配置的品牌筛选可访问的项目
|
||||
List<String> brandTypes = projectUserBrandService.queryBrandByUserId(loginUser.getId());
|
||||
if (ObjectUtils.isNotEmpty(brandTypes)) {
|
||||
QueryWrapper<ProjectLibraryBase> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("brand",brandTypes);
|
||||
if (ObjectUtils.isNotEmpty(list(queryWrapper))) {
|
||||
projectIds.addAll(list(queryWrapper).stream().map(ProjectLibraryBase::getId).collect(Collectors.toSet()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<ProjectLibraryBase> result = projectLibraryBaseMapper.queryPageList(params);
|
||||
|
||||
Reference in New Issue
Block a user