mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
5.0
This commit is contained in:
@@ -9,9 +9,21 @@ import lombok.Getter;
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum StatusEnum {
|
||||
NONE(0),
|
||||
ENABLE(1),
|
||||
DISABLE(2);
|
||||
|
||||
private final int value;
|
||||
|
||||
public static StatusEnum of(Number number) {
|
||||
if (number == null) {
|
||||
return NONE;
|
||||
}
|
||||
for (StatusEnum value : StatusEnum.values()) {
|
||||
if (value.value == number.intValue()) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
|
@@ -35,8 +35,8 @@ public class RedisIsvApiPermissionManagerImpl extends LocalIsvApiPermissionManag
|
||||
|
||||
@Override
|
||||
public boolean doCheck(Long isvId, ApiInfoDTO apiInfoDTO) {
|
||||
BoundHashOperations<String, Object, String> operations = stringRedisTemplate.boundHashOps(CACHE_KEY);
|
||||
String value = operations.get(isvId);
|
||||
BoundHashOperations<String, String, String> operations = stringRedisTemplate.boundHashOps(CACHE_KEY);
|
||||
String value = operations.get(String.valueOf(isvId));
|
||||
if (Objects.equals(value, SopConstants.NULL)) {
|
||||
return false;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class RedisIsvApiPermissionManagerImpl extends LocalIsvApiPermissionManag
|
||||
|
||||
@Override
|
||||
protected void cache(Long isvId, List<Long> apiIdList) {
|
||||
stringRedisTemplate.opsForHash().put(CACHE_KEY, isvId, JsonUtil.toJSONString(apiIdList));
|
||||
stringRedisTemplate.opsForHash().put(CACHE_KEY, String.valueOf(isvId), JsonUtil.toJSONString(apiIdList));
|
||||
log.info("更新isv接口id redis缓存, isvId={}, apiIdList={}", isvId, apiIdList);
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,7 @@ public class RedisIsvManagerImpl extends LocalIsvManagerImpl {
|
||||
@Override
|
||||
protected void cache(String appId, IsvDTO isvDTO) {
|
||||
stringRedisTemplate.opsForHash().put(KEY_ISV, appId, JsonUtil.toJSONString(isvDTO));
|
||||
log.info("更新isv redis缓存, isvDTO={}", isvDTO);
|
||||
log.debug("更新isv redis缓存, isvDTO={}", isvDTO);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
|
@@ -27,7 +27,7 @@ public class RedisSecretManager extends LocalSecretManagerImpl {
|
||||
@Override
|
||||
public String getIsvPublicKey(Long isvId) {
|
||||
try {
|
||||
Object value = stringRedisTemplate.opsForHash().get(KEY_SEC, isvId);
|
||||
Object value = stringRedisTemplate.opsForHash().get(KEY_SEC, buildHashKey(isvId));
|
||||
if (Objects.equals(value, SopConstants.NULL)) {
|
||||
return null;
|
||||
}
|
||||
@@ -47,8 +47,13 @@ public class RedisSecretManager extends LocalSecretManagerImpl {
|
||||
if (publicKey == null) {
|
||||
publicKey = SopConstants.NULL;
|
||||
}
|
||||
stringRedisTemplate.opsForHash().put(KEY_SEC, isvId, publicKey);
|
||||
log.info("更新isv秘钥redis缓存, isvId={}", isvId);
|
||||
stringRedisTemplate.opsForHash().put(KEY_SEC, buildHashKey(isvId), publicKey);
|
||||
log.debug("更新isv秘钥redis缓存, isvId={}", isvId);
|
||||
}
|
||||
|
||||
|
||||
private String buildHashKey(Long isvId) {
|
||||
return String.valueOf(isvId);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
|
@@ -111,7 +111,7 @@ public class ApiValidator implements Validator {
|
||||
throw new ApiException(ErrorEnum.ISV_INVALID_METHOD, apiRequestContext.getLocale());
|
||||
}
|
||||
// 检查路由是否启用
|
||||
if (!BooleanUtils.toBoolean(apiInfoDTO.getStatus())) {
|
||||
if (StatusEnum.of(apiInfoDTO.getStatus()) != StatusEnum.ENABLE) {
|
||||
throw new ApiException(ErrorEnum.ISP_API_DISABLED, apiRequestContext.getLocale());
|
||||
}
|
||||
// 校验是否需要授权访问
|
||||
|
Reference in New Issue
Block a user