项目库-认证清单-分页查询接口开发查询权限。
This commit is contained in:
+11
@@ -1,5 +1,7 @@
|
||||
package com.jero.modules.system.enums;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 项目角色枚举类
|
||||
*/
|
||||
@@ -27,6 +29,15 @@ public enum ProjectRoleEnum {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public static ProjectRoleEnum getByValue(String value) {
|
||||
for (ProjectRoleEnum projectRoleEnum : ProjectRoleEnum.values()) {
|
||||
if(StringUtils.equals(value,projectRoleEnum.getValue())){
|
||||
return projectRoleEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
+1
-2
@@ -59,8 +59,7 @@ public class ProjectCertificationInventoryEOController extends JeroController<Pr
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<ProjectCertificationInventoryEO> queryWrapper = QueryGenerator.initQueryWrapper(projectCertificationInventoryEO, req.getParameterMap());
|
||||
Page<ProjectCertificationInventoryEO> page = new Page<ProjectCertificationInventoryEO>(pageNo, pageSize);
|
||||
IPage<ProjectCertificationInventoryEO> pageList = projectCertificationInventoryEOService.page(page, queryWrapper);
|
||||
this.projectCertificationInventoryEOService.disposeData(pageList.getRecords(),cut);
|
||||
IPage<ProjectCertificationInventoryEO> pageList = this.projectCertificationInventoryEOService.queryPage(queryWrapper,page,projectCertificationInventoryEO,cut);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -183,4 +183,7 @@ public class ProjectCertificationInventoryEO implements Serializable {
|
||||
|
||||
@TableField(exist = false)
|
||||
private String ids;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String roleCode;
|
||||
}
|
||||
|
||||
+10
@@ -1,6 +1,9 @@
|
||||
package com.jero.modules.project.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.project.entity.ProjectCertificationInventoryEO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
@@ -104,4 +107,11 @@ public interface IProjectCertificationInventoryEOService extends IService<Projec
|
||||
Result<List<SysRole>> getRoleByUserId(Map<String, Object> params);
|
||||
|
||||
Result<?> getFlowStatusList(String cut);
|
||||
|
||||
IPage<ProjectCertificationInventoryEO> queryPage(QueryWrapper<ProjectCertificationInventoryEO> queryWrapper,
|
||||
Page<ProjectCertificationInventoryEO> page,
|
||||
ProjectCertificationInventoryEO projectCertificationInventoryEO,
|
||||
String cut);
|
||||
|
||||
void createQueryPermission(QueryWrapper<ProjectCertificationInventoryEO> queryWrapper, String roleCode);
|
||||
}
|
||||
|
||||
+70
@@ -3,6 +3,8 @@ package com.jero.modules.project.service.impl;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.constant.enums.CutEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
@@ -545,4 +547,72 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
|
||||
}
|
||||
return Result.OK(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<ProjectCertificationInventoryEO> queryPage(QueryWrapper<ProjectCertificationInventoryEO> queryWrapper,
|
||||
Page<ProjectCertificationInventoryEO> page,
|
||||
ProjectCertificationInventoryEO projectCertificationInventoryEO,
|
||||
String cut) {
|
||||
|
||||
String roleCode = projectCertificationInventoryEO.getRoleCode();
|
||||
// 创建查询权限
|
||||
this.createQueryPermission(queryWrapper,roleCode);
|
||||
IPage<ProjectCertificationInventoryEO> pageList = this.page(page, queryWrapper);
|
||||
this.disposeData(pageList.getRecords(),cut);
|
||||
return pageList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createQueryPermission(QueryWrapper<ProjectCertificationInventoryEO> queryWrapper, String roleCode) {
|
||||
/**
|
||||
* 处理查询权限
|
||||
* studio、法规工程师、领导、系统管理员、Viewer、品牌管理员: 可以查询所有数据
|
||||
* 认证工程师:可以查询所有数据
|
||||
* 接口人:可查看所有接口人为自己的数据
|
||||
* 责任人:可以查看流程状态为:任务待确认、结果待提交 、审查通过(并且责任人为自己)
|
||||
*/
|
||||
ProjectRoleEnum projectRoleEnum = ProjectRoleEnum.getByValue(roleCode);
|
||||
if(ObjectUtils.isEmpty(projectRoleEnum)){
|
||||
throw new JeroBootException("当前用户角色有误,请重新选择后角色进行操作!");
|
||||
}
|
||||
|
||||
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
switch (projectRoleEnum){
|
||||
case STUDIO_ENGINEER:
|
||||
break;
|
||||
case REGULATI_ENGINEER:
|
||||
break;
|
||||
case MANAGER:
|
||||
break;
|
||||
case ADMIN:
|
||||
break;
|
||||
case VIEWER:
|
||||
break;
|
||||
case BRAND_ADMINISTRATOR:
|
||||
break;
|
||||
case HOMOLOGATION_ENGINEER:
|
||||
break;
|
||||
case INTERFACE_PERSON:
|
||||
queryWrapper.lambda().eq(ProjectCertificationInventoryEO::getSdt,currentUser.getId());
|
||||
break;
|
||||
case PERSON_LIABLE:
|
||||
List<String> flowStatusList = new ArrayList<>();
|
||||
flowStatusList.add(CertificationInventoryFlowStatusEnum.TASK_TO_BE_CONFIRMED.getValue());
|
||||
flowStatusList.add(CertificationInventoryFlowStatusEnum.RESULTS_TO_BE_SUBMITTED.getValue());
|
||||
|
||||
queryWrapper.lambda().and(queryWrap -> {
|
||||
queryWrap.and(query -> {
|
||||
query.eq(ProjectCertificationInventoryEO::getDutyPerson,currentUser.getId());
|
||||
query.in(ProjectCertificationInventoryEO::getFlowStatus,flowStatusList);
|
||||
}).or(query -> {
|
||||
query.eq(ProjectCertificationInventoryEO::getSdt,currentUser.getId());
|
||||
query.eq(ProjectCertificationInventoryEO::getFlowStatus,CertificationInventoryFlowStatusEnum.REVIEW_AND_PASS.getValue());
|
||||
});
|
||||
});
|
||||
break;
|
||||
default:
|
||||
throw new JeroBootException("当前用户角色有误,请重新选择后角色进行操作!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user