feat: 管理员企标权限由配置文件中的adminRoleCode配置
This commit is contained in:
+15
-11
@@ -42,6 +42,13 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【laws_enterprise_standard_temp_permission(企业标准)】的数据库操作Service实现
|
||||
*
|
||||
* 权限这里分为三种权限
|
||||
* 1. 企标的查看权限 (管理员、创建人、这条企标主起草部门的其他员工、临时授权、授权部门)
|
||||
* 2. 企标的编辑权限 (管理员、创建人)
|
||||
* 3. 企标的删除权限 (管理员、创建人可以删除试用期内的企标)
|
||||
*
|
||||
*
|
||||
* @createDate 2023-09-07 11:20:30
|
||||
*/
|
||||
@Service
|
||||
@@ -70,8 +77,8 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
|
||||
@Resource
|
||||
private ILawsGradeService gradeService;
|
||||
|
||||
@Resource
|
||||
private ISysDepartService sysDepartService;
|
||||
@Value("#{'${adminRoleCode}'.split(',')}")
|
||||
private List<String> adminRoleCodeList;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -114,7 +121,7 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
|
||||
String userName = currentUser.getUsername();
|
||||
// 管理员有所有企标的权限
|
||||
List<String> roleList = sysUserRoleService.getRole(currentUser.getUsername());
|
||||
if (roleList != null && roleList.contains(FieldCommon.ROLE_ADMIN)) {
|
||||
if (roleList != null && roleList.stream().anyMatch(adminRoleCodeList :: contains)) {
|
||||
records.forEach(kv -> kv.put(FieldCommon.DETAIL_FLAG, true));
|
||||
return;
|
||||
}
|
||||
@@ -234,7 +241,7 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
|
||||
SysUser currentUser = sysUserService.getById(userId);
|
||||
// 管理员有所有企标的权限
|
||||
List<String> roleList = sysUserRoleService.getRole(currentUser.getUsername());
|
||||
if (roleList != null && roleList.contains(FieldCommon.ROLE_ADMIN)) {
|
||||
if (roleList != null && roleList.stream().anyMatch(adminRoleCodeList :: contains)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -355,12 +362,9 @@ 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());
|
||||
// 获取当前用户的角色roleCode
|
||||
List<String> roleList = sysUserRoleService.getRole(currentUser.getUsername());
|
||||
if (roleList != null && roleList.contains(FieldCommon.ROLE_ADMIN)) {
|
||||
if (roleList != null && roleList.stream().anyMatch(adminRoleCodeList :: contains)) {
|
||||
records.forEach(kv -> kv.put(FieldCommon.EDIT_FLAG, true));
|
||||
return;
|
||||
}
|
||||
@@ -397,7 +401,7 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
|
||||
// 获取当前用户的角色roleCode
|
||||
List<String> roleList = sysUserRoleService.getRole(currentUser.getUsername());
|
||||
// 管理员能够删除所有试用期的企标
|
||||
if (roleList != null && roleList.contains(FieldCommon.ROLE_ADMIN)) {
|
||||
if (roleList != null && roleList.stream().anyMatch(adminRoleCodeList :: contains)) {
|
||||
for (Map<String, Object> map : records) {
|
||||
String tryFlag = String.valueOf(map.get(FieldCommon.TRY_FLAG));
|
||||
if (tryFlag.equals(YesOrNoEnum.NO.getValue())) {
|
||||
@@ -463,7 +467,7 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
|
||||
SysUser currentUser = sysUserService.getById(userId);
|
||||
// 管理员有所有企标的权限
|
||||
List<String> roleList = sysUserRoleService.getRole(currentUser.getUsername());
|
||||
if (roleList != null && roleList.contains(FieldCommon.ROLE_ADMIN)) {
|
||||
if (roleList != null && roleList.stream().anyMatch(adminRoleCodeList :: contains)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -585,7 +589,7 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl<Enterpris
|
||||
|
||||
// 获取当前用户的角色roleCode
|
||||
List<String> roleList = sysUserRoleService.getRole(currentUser.getUsername());
|
||||
if (roleList != null && roleList.contains(FieldCommon.ROLE_ADMIN)) {
|
||||
if (roleList != null && roleList.stream().anyMatch(adminRoleCodeList :: contains)) {
|
||||
return true;
|
||||
}
|
||||
// 创建人可以删除
|
||||
|
||||
@@ -426,3 +426,6 @@ oauth:
|
||||
|
||||
# 起草部门部门名称
|
||||
draftDepartName: 起草部门
|
||||
|
||||
# 管理员权限roleCode,多填用英文逗号拼接
|
||||
adminRoleCode: admin
|
||||
|
||||
@@ -399,4 +399,7 @@ oauth:
|
||||
state: zhongQi
|
||||
|
||||
# 起草部门部门名称
|
||||
draftDepartName: 流程与标准化
|
||||
draftDepartName: 流程与标准化
|
||||
|
||||
# 管理员权限roleCode,多填用英文逗号拼接
|
||||
adminRoleCode: admin
|
||||
Reference in New Issue
Block a user