feat: 起草部门的人员具有所有企标的查看编辑权限

This commit is contained in:
2023-11-01 18:35:43 +08:00
parent 1ebe423593
commit 6d8b0a28f1
2 changed files with 17 additions and 4 deletions
@@ -149,7 +149,10 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
// 筛选出用于查询的字段
List<LawsTag> fieldListCondition = fieldList.stream().filter(lawsTag -> YesOrNoEnum.YES.getValue()
.equals(lawsTag.getIsQuery().toString())).collect(Collectors.toList());
// 加一个create_by字段
LawsTag createByTag = new LawsTag();
createByTag.setDbFieldName(FieldCommon.CREATE_BY);
fieldListSelect.add(createByTag);
// 获取分页参数
Integer pageNo = Integer.valueOf(parameterMap.get("pageNo").toString());
Integer pageSize = Integer.valueOf(parameterMap.get("pageSize").toString());
@@ -156,6 +156,7 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
// 只有创建人和管理员才有维护的权限
String userId = UserUtils.getUserId();
SysUser currentUser = sysUserService.getById(userId);
String username = currentUser.getUsername();
// 起草部门的人也有维护的权限
List<DepartIdModel> departIdModels = sysUserDepartService.queryDepartIdsOfUser(userId);
List<String> departNames = departIdModels.stream().map(DepartIdModel::getTitle).collect(Collectors.toList());
@@ -172,7 +173,7 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
}
for (Map<String, Object> map : records) {
String createBy = (String) map.get(FieldCommon.CREATE_BY);
if (userId.equals(createBy)) {
if (username.equals(createBy)) {
map.put(FieldCommon.EDIT_FLAG, true);
} else {
map.put(FieldCommon.EDIT_FLAG, false);
@@ -245,18 +246,27 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
if (StringUtils.isBlank(ids)) {
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "ids不能为空");
}
List<String> idList = Arrays.asList(ids.split(","));
// 管理员有所有权限
SysUser currentUser = sysUserService.getById(userId);
String username = currentUser.getUsername();
// 起草部门的人有所有权限
List<DepartIdModel> departIdModels = sysUserDepartService.queryDepartIdsOfUser(userId);
List<String> departNames = departIdModels.stream().map(DepartIdModel::getTitle).collect(Collectors.toList());
if (departNames.contains(draftDepartName)) {
return true;
}
// 获取当前用户的角色roleCode
List<String> roleList = sysUserRoleService.getRole(currentUser.getUsername());
if (roleList != null && roleList.contains(FieldCommon.ROLE_ADMIN)) {
return true;
}
// 创建人可以删除
List<LawsEnterpriseStandard> list = enterpriseStandardService.list(new LambdaQueryWrapper<LawsEnterpriseStandard>().in(LawsEnterpriseStandard::getId, ids));
List<LawsEnterpriseStandard> list = enterpriseStandardService.list(new LambdaQueryWrapper<LawsEnterpriseStandard>().in(LawsEnterpriseStandard::getId, idList));
// 如果不是创建人,则直接返回false
for (LawsEnterpriseStandard es : list) {
if (!es.getCreateBy().equals(userId)) {
if (!es.getCreateBy().equals(username)) {
return false;
}
}