Commit 5ce30c04 by chenxi

优加门店上架导入改动提交,门店上架审核角色由读取常量改为读取配置文件

1 parent ebb5e840
...@@ -32,30 +32,5 @@ public final class CommonConstants { ...@@ -32,30 +32,5 @@ public final class CommonConstants {
/** 超级管理员角色编码 */ /** 超级管理员角色编码 */
public static final String ROLE_SYS_ADMIN = "SYS_ADMIN"; public static final String ROLE_SYS_ADMIN = "SYS_ADMIN";
/** 优加商务经理角色编码(门店上架第 1 级审批) */
public static final String ROLE_YJ_BIZ_MGR = "YJ_BIZ_MGR";
/** 优加商务经理角色名称(提交时按名称查 sys_role 取 role_code) */
public static final String ROLE_NAME_YJ_BIZ_MGR = "优加商务经理";
/** 优加财务经理角色编码(门店上架第 2 级审批) */
public static final String ROLE_YJ_FINANCE_MGR = "YJ_FINANCE_MGR";
/** 线上运营角色编码 */
public static final String ROLE_ONLINE_OPS = "ONLINE_OPS";
/** 运营主管角色编码 */
public static final String ROLE_OPS_LEADER = "OPS_LEADER";
/** 只读观察者角色编码 */
public static final String ROLE_VIEWER = "VIEWER";
/** 毫秒时间戳请求头 */
public static final String HEADER_TIMESTAMP = "X-Timestamp";
/** 当前登录人透传头(网关 / 上游鉴权域透传) */
public static final String HEADER_USER_ID = "X-User-Id";
/** 当前登录人组织透传头 */
public static final String HEADER_ORG_ID = "X-Org-Id";
} }
...@@ -28,6 +28,7 @@ import com.youjia.store.mapper.StoreListingMapper; ...@@ -28,6 +28,7 @@ import com.youjia.store.mapper.StoreListingMapper;
import com.youjia.store.remote.StoreImportRemoteValidator; import com.youjia.store.remote.StoreImportRemoteValidator;
import com.youjia.store.remote.dto.GoodsCategoryDTO; import com.youjia.store.remote.dto.GoodsCategoryDTO;
import com.youjia.store.service.StoreImportService; import com.youjia.store.service.StoreImportService;
import com.youjia.store.support.StoreApprovalConfig;
import com.youjia.store.support.StoreImportCheckResult; import com.youjia.store.support.StoreImportCheckResult;
import com.youjia.store.support.StoreImportFailFileWriter; import com.youjia.store.support.StoreImportFailFileWriter;
import com.youjia.store.support.StoreImportIdempotentGuard; import com.youjia.store.support.StoreImportIdempotentGuard;
...@@ -104,6 +105,7 @@ public class StoreImportServiceImpl implements StoreImportService { ...@@ -104,6 +105,7 @@ public class StoreImportServiceImpl implements StoreImportService {
private final StoreImportRemoteValidator storeImportRemoteValidator; private final StoreImportRemoteValidator storeImportRemoteValidator;
private final SysRoleMapper sysRoleMapper; private final SysRoleMapper sysRoleMapper;
private final SysOrgMapper sysOrgMapper; private final SysOrgMapper sysOrgMapper;
private final StoreApprovalConfig storeApprovalConfig;
private final OssTemplate ossTemplate; private final OssTemplate ossTemplate;
private final TransactionTemplate transactionTemplate; private final TransactionTemplate transactionTemplate;
private final StoreImportIdempotentGuard idempotentGuard; private final StoreImportIdempotentGuard idempotentGuard;
...@@ -569,22 +571,33 @@ public class StoreImportServiceImpl implements StoreImportService { ...@@ -569,22 +571,33 @@ public class StoreImportServiceImpl implements StoreImportService {
} }
/** /**
* 第 1 级审批角色编码:按 `sys_role.role_name = '优加商务经理'` 查。 * 第 1 级审批角色编码:取 {@link StoreApprovalConfig}(Nacos `youjia.store.approval.level-role-codes`)
* 下标 0 的角色编码,并校验该角色在 sys_role 中存在且启用。
*/ */
private String resolveLevel1RoleCode() { private String resolveLevel1RoleCode() {
String roleCode = storeApprovalConfig.getRoleCode(1);
if (!StringUtils.hasText(roleCode)) {
throw new BusinessException(ResultCode.OPERATION_NOT_ALLOWED,
"第 1 级审批角色未配置,请检查配置项 youjia.store.approval.level-role-codes");
}
SysRole role = sysRoleMapper.selectOne(new LambdaQueryWrapper<SysRole>() SysRole role = sysRoleMapper.selectOne(new LambdaQueryWrapper<SysRole>()
.eq(SysRole::getRoleName, CommonConstants.ROLE_NAME_YJ_BIZ_MGR) .eq(SysRole::getRoleCode, roleCode)
.eq(SysRole::getStatus, CommonConstants.STATUS_ENABLED) .eq(SysRole::getStatus, CommonConstants.STATUS_ENABLED)
.last("limit 1")); .last("limit 1"));
if (role == null || !StringUtils.hasText(role.getRoleCode())) { if (role == null) {
throw new BusinessException(ResultCode.OPERATION_NOT_ALLOWED, throw new BusinessException(ResultCode.OPERATION_NOT_ALLOWED,
"审批角色[" + CommonConstants.ROLE_NAME_YJ_BIZ_MGR + "]未配置,请联系管理员"); "审批角色[" + roleCode + "]在系统中不存在或未启用,"
+ "请检查 sys_role 数据与配置项 youjia.store.approval.level-role-codes");
} }
return role.getRoleCode(); return role.getRoleCode();
} }
/**
* 第 1 级审批角色名称:按配置的角色编码到 sys_role 反查名称(不再写死)。
*/
private String resolveLevel1RoleName() { private String resolveLevel1RoleName() {
return CommonConstants.ROLE_NAME_YJ_BIZ_MGR; String roleCode = storeApprovalConfig.getRoleCode(1);
return StringUtils.hasText(roleCode) ? roleNameOf(roleCode) : null;
} }
private String roleNameOf(String roleCode) { private String roleNameOf(String roleCode) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!