Browse Source

Merge branches 'develop' and 'wxz_permission_async' of http://git.elinkit.com.cn:7070/r/epmet-cloud into develop

dev_shibei_match
wxz 4 years ago
parent
commit
aacefc07f1
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 7
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/AccessConfigAdd4RoletFormDTO.java
  3. 16
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessConfigController.java
  4. 2
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessConfigService.java
  5. 21
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessConfigServiceImpl.java

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -129,6 +129,7 @@ public enum EpmetErrorCode {
OPER_UPLOAD_IMG_TYPE_ERROR(8716, "请上传PNG格式的图片"),
OPER_UPLOAD_IMG_SIZE_ERROR(8717, "请上传200*200的图片"),
OPER_CORS_CONFIG_ERROR(8718, "跨域配置错误"),
ACCESS_CONFIG_ERROR(8719, "权限配置错误"),
// 党建声音 前端提示 88段
DRAFT_CONTENT_IS_NULL(8801, "至少需要添加一个段落"),

7
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/AccessConfigAdd4RoletFormDTO.java

@ -18,10 +18,13 @@ public class AccessConfigAdd4RoletFormDTO {
// 为角色添加多个操作
public interface AddMultiOperations4RoleGroup {}
@NotBlank(message = "角色Key不能为空", groups = { AddSingleOperation4RoleGroup.class })
//为角色添加单个操作,从默认配置里面查询,而不从前端传
public interface AddSingleOperations4RoleByDefault {}
@NotBlank(message = "角色Key不能为空", groups = { AddSingleOperation4RoleGroup.class, AddSingleOperations4RoleByDefault.class })
private String roleKey;
@NotBlank(message = "操作Key不能为空", groups = { AddSingleOperation4RoleGroup.class })
@NotBlank(message = "操作Key不能为空", groups = { AddSingleOperation4RoleGroup.class, AddSingleOperations4RoleByDefault.class })
private String operationKey;
private List<String> scopeKeys;

16
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessConfigController.java

@ -135,6 +135,22 @@ public class AccessConfigController {
return new Result();
}
/**
* @Description 根据默认配置为所有客户的某角色配置某操作及其范围
* @return
* @author wxz
* @date 2021.07.01 16:07
*/
@PostMapping("add-ope-and-scopes-4role/by-default-conf")
public Result addOpeAndScopes4RoleByDefaultConf(@RequestBody AccessConfigAdd4RoletFormDTO form) {
ValidatorUtils.validateEntity(form, AccessConfigAdd4RoletFormDTO.AddSingleOperations4RoleByDefault.class);
String roleKey = form.getRoleKey();
String operationKey = form.getOperationKey();
accessConfigService.addOpeAndScopes4RoleByDefaultConf(roleKey, operationKey);
return new Result();
}
/**
* @Description 给角色添加单个操作权限和操作范围
* @return

2
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessConfigService.java

@ -29,4 +29,6 @@ public interface AccessConfigService {
void addOpeAndScopes4Role(String roleKey, String operationKey, List<String> scopeKeys);
void addOpesAndScopes4Role(String roleKey, List<AccessConfigAdd4RoletFormDTO.OperationsAndScopes> operations);
void addOpeAndScopes4RoleByDefaultConf(String roleKey, String operationKey);
}

21
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessConfigServiceImpl.java

@ -1,5 +1,6 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result;
@ -276,4 +277,24 @@ public class AccessConfigServiceImpl implements AccessConfigService {
addOpeAndScopes4Role(roleKey, operationKey, scopeKeys);
}
}
@Override
public void addOpeAndScopes4RoleByDefaultConf(String roleKey, String operationKey) {
// 1.先判断该角色是否已经为该操作配做了默认配置
LambdaQueryWrapper<RoleOperationDefaultEntity> rodw = new LambdaQueryWrapper<>();
rodw.eq(RoleOperationDefaultEntity::getRoleKey, roleKey);
rodw.eq(RoleOperationDefaultEntity::getOperationKey, operationKey);
rodw.eq(RoleOperationDefaultEntity::getDelFlag, 0);
Integer roleOperationCount = roleOperationDefaultDao.selectCount(rodw);
List<OperationScopeDefaultEntity> scopes = operationScopeDefaultDao.listOpeDefaultScopesByRoleAndOpeKey(roleKey, operationKey);
if (roleOperationCount == 0 || CollectionUtils.isEmpty(scopes)) {
throw new RenException(EpmetErrorCode.ACCESS_CONFIG_ERROR.getCode(), String.format("为所有客户同步%s的%s配置权限默认失败,请先保存默认权限配置再重试", roleKey, operationKey));
}
// 2.开始执行同步
List<String> scopeKeys = scopes.stream().map(s -> s.getScopeKey()).collect(Collectors.toList());
logger.info(String.format("为所有客户同步%s的%s配置权限,范围列表:" + scopeKeys, roleKey, operationKey));
addOpeAndScopes4Role(roleKey, operationKey, scopeKeys);
logger.info("同步完成");
}
}

Loading…
Cancel
Save