开启 Dubbo Consumer 参数校验
This commit is contained in:
parent
3b5199b60b
commit
d619f0fae8
@ -27,9 +27,9 @@ import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeEnum.OAUTH_USER
|
|||||||
|
|
||||||
public class AdminSecurityInterceptor extends HandlerInterceptorAdapter {
|
public class AdminSecurityInterceptor extends HandlerInterceptorAdapter {
|
||||||
|
|
||||||
@Reference(validation = "true", version = "${dubbo.consumer.OAuth2Rpc.version}")
|
@Reference(version = "${dubbo.consumer.OAuth2Rpc.version}")
|
||||||
private OAuth2Rpc oauth2Rpc;
|
private OAuth2Rpc oauth2Rpc;
|
||||||
@Reference(validation = "true", version = "${dubbo.consumer.PermissionRpc.version}")
|
@Reference(version = "${dubbo.consumer.PermissionRpc.version}")
|
||||||
private PermissionRpc permissionRpc;
|
private PermissionRpc permissionRpc;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,7 +23,7 @@ import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeEnum.OAUTH_USER
|
|||||||
|
|
||||||
public class UserSecurityInterceptor extends HandlerInterceptorAdapter {
|
public class UserSecurityInterceptor extends HandlerInterceptorAdapter {
|
||||||
|
|
||||||
@Reference(validation = "true", version = "${dubbo.consumer.OAuth2Rpc.version}")
|
@Reference(version = "${dubbo.consumer.OAuth2Rpc.version}")
|
||||||
private OAuth2Rpc oauth2Rpc;
|
private OAuth2Rpc oauth2Rpc;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,7 +51,7 @@ public class GlobalExceptionHandler {
|
|||||||
private String applicationName;
|
private String applicationName;
|
||||||
|
|
||||||
// TODO 目前存在一个问题,如果未引入 system-rpc-api 依赖,GlobalExceptionHandler 会报类不存在。未来封装出 Repository 解决该问题
|
// TODO 目前存在一个问题,如果未引入 system-rpc-api 依赖,GlobalExceptionHandler 会报类不存在。未来封装出 Repository 解决该问题
|
||||||
@Reference(validation = "true", version = "${dubbo.consumer.SystemExceptionLogRpc.version}")
|
@Reference(version = "${dubbo.consumer.SystemExceptionLogRpc.version}")
|
||||||
private SystemExceptionLogRpc systemExceptionLogRpc;
|
private SystemExceptionLogRpc systemExceptionLogRpc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,6 +199,7 @@ public class GlobalExceptionHandler {
|
|||||||
.setExceptionTime(new Date());
|
.setExceptionTime(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO 优化点:后续可以增加事件
|
||||||
@Async
|
@Async
|
||||||
public void addExceptionLog(SystemExceptionLogCreateDTO exceptionLog) {
|
public void addExceptionLog(SystemExceptionLogCreateDTO exceptionLog) {
|
||||||
try {
|
try {
|
||||||
|
@ -26,7 +26,7 @@ public class AccessLogInterceptor extends HandlerInterceptorAdapter {
|
|||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
@Reference(validation = "false", version = "${dubbo.consumer.SystemAccessLogRpc.version}")
|
@Reference(version = "${dubbo.consumer.SystemAccessLogRpc.version}")
|
||||||
private SystemAccessLogRpc systemAccessLogRpc;
|
private SystemAccessLogRpc systemAccessLogRpc;
|
||||||
|
|
||||||
@Value("${spring.application.name}")
|
@Value("${spring.application.name}")
|
||||||
@ -77,6 +77,7 @@ public class AccessLogInterceptor extends HandlerInterceptorAdapter {
|
|||||||
.setResponseTime((int) (System.currentTimeMillis() - accessLog.getStartTime().getTime())); // 默认响应时间设为 0
|
.setResponseTime((int) (System.currentTimeMillis() - accessLog.getStartTime().getTime())); // 默认响应时间设为 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO 优化点:后续可以增加事件
|
||||||
@Async // 异步入库
|
@Async // 异步入库
|
||||||
public void addAccessLog(SystemAccessLogCreateDTO accessLog) {
|
public void addAccessLog(SystemAccessLogCreateDTO accessLog) {
|
||||||
try {
|
try {
|
||||||
|
@ -10,6 +10,12 @@ Content-Type: application/x-www-form-urlencoded
|
|||||||
|
|
||||||
username=admin&password=1024
|
username=admin&password=1024
|
||||||
|
|
||||||
|
### /passport/login 少传参数
|
||||||
|
POST {{baseUrl}}/passport/login
|
||||||
|
Content-Type: application/x-www-form-urlencoded
|
||||||
|
|
||||||
|
username=admin
|
||||||
|
|
||||||
### /passport/info 成功
|
### /passport/info 成功
|
||||||
GET {{baseUrl}}/passport/info
|
GET {{baseUrl}}/passport/info
|
||||||
Authorization: Bearer {{accessToken}}
|
Authorization: Bearer {{accessToken}}
|
||||||
|
@ -27,13 +27,13 @@ import java.util.*;
|
|||||||
@Validated
|
@Validated
|
||||||
public class AdminManager {
|
public class AdminManager {
|
||||||
|
|
||||||
@Reference(version = "${dubbo.consumer.AdminRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.AdminRpc.version}")
|
||||||
private AdminRpc adminRpc;
|
private AdminRpc adminRpc;
|
||||||
@Reference(version = "${dubbo.consumer.RoleRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.RoleRpc.version}")
|
||||||
private RoleRpc roleRpc;
|
private RoleRpc roleRpc;
|
||||||
@Reference(version = "${dubbo.consumer.DepartmentRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.DepartmentRpc.version}")
|
||||||
private DepartmentRpc departmentRpc;
|
private DepartmentRpc departmentRpc;
|
||||||
@Reference(version = "${dubbo.consumer.PermissionRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.PermissionRpc.version}")
|
||||||
private PermissionRpc permissionRpc;
|
private PermissionRpc permissionRpc;
|
||||||
|
|
||||||
public PageResult<AdminPageItemVO> pageAdmin(AdminPageDTO pageDTO) {
|
public PageResult<AdminPageItemVO> pageAdmin(AdminPageDTO pageDTO) {
|
||||||
|
@ -22,7 +22,7 @@ import java.util.stream.Collectors;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class DepartmentManager {
|
public class DepartmentManager {
|
||||||
|
|
||||||
@Reference(version = "${dubbo.consumer.DepartmentRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.DepartmentRpc.version}")
|
||||||
private DepartmentRpc departmentRpc;
|
private DepartmentRpc departmentRpc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,15 +19,11 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class DataDictManager {
|
public class DataDictManager {
|
||||||
|
|
||||||
private static final Comparator<cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO> COMPARATOR_ENUM_VALUE_SORT = (o1, o2) -> {
|
private static final Comparator<cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO> COMPARATOR_ENUM_VALUE_SORT = Comparator
|
||||||
int cmp = o1.getEnumValue().compareTo(o2.getEnumValue());
|
.comparing(cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO::getEnumValue)
|
||||||
if (cmp != 0) {
|
.thenComparingInt(cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO::getSort);
|
||||||
return cmp;
|
|
||||||
}
|
|
||||||
return o1.getSort().compareTo(o2.getSort());
|
|
||||||
};
|
|
||||||
|
|
||||||
@Reference(version = "${dubbo.consumer.DataDictRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.DataDictRpc.version}")
|
||||||
private DataDictRpc dataDictRpc;
|
private DataDictRpc dataDictRpc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,13 +30,13 @@ import java.util.Set;
|
|||||||
@Service
|
@Service
|
||||||
public class PassportManager {
|
public class PassportManager {
|
||||||
|
|
||||||
@Reference(version = "${dubbo.consumer.AdminRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.AdminRpc.version}")
|
||||||
private AdminRpc adminRpc;
|
private AdminRpc adminRpc;
|
||||||
@Reference(version = "${dubbo.consumer.OAuth2Rpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.OAuth2Rpc.version}")
|
||||||
private OAuth2Rpc oauth2Rpc;
|
private OAuth2Rpc oauth2Rpc;
|
||||||
@Reference(version = "${dubbo.consumer.RoleRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.RoleRpc.version}")
|
||||||
private RoleRpc roleRpc;
|
private RoleRpc roleRpc;
|
||||||
@Reference(version = "${dubbo.consumer.ResourceRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.ResourceRpc.version}")
|
||||||
private ResourceRpc resourceRpc;
|
private ResourceRpc resourceRpc;
|
||||||
|
|
||||||
public PassportAccessTokenVO login(PassportLoginDTO loginDTO, String ip) {
|
public PassportAccessTokenVO login(PassportLoginDTO loginDTO, String ip) {
|
||||||
|
@ -16,7 +16,7 @@ import java.util.Set;
|
|||||||
@Service
|
@Service
|
||||||
public class PermissionManager {
|
public class PermissionManager {
|
||||||
|
|
||||||
@Reference(version = "${dubbo.consumer.PermissionRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.PermissionRpc.version}")
|
||||||
private PermissionRpc permissionRpc;
|
private PermissionRpc permissionRpc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,9 +23,9 @@ import java.util.stream.Collectors;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ResourceManager {
|
public class ResourceManager {
|
||||||
|
|
||||||
@Reference(version = "${dubbo.consumer.ResourceRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.ResourceRpc.version}")
|
||||||
private ResourceRpc resourceRpc;
|
private ResourceRpc resourceRpc;
|
||||||
@Reference(version = "${dubbo.consumer.RoleRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.RoleRpc.version}")
|
||||||
private RoleRpc roleRpc;
|
private RoleRpc roleRpc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,7 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class RoleManager {
|
public class RoleManager {
|
||||||
|
|
||||||
@Reference(version = "${dubbo.consumer.RoleRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.RoleRpc.version}")
|
||||||
private RoleRpc roleRpc;
|
private RoleRpc roleRpc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,7 +15,7 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class SystemAccessLogManager {
|
public class SystemAccessLogManager {
|
||||||
|
|
||||||
@Reference(version = "${dubbo.consumer.SystemAccessLogRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.SystemAccessLogRpc.version}")
|
||||||
private SystemAccessLogRpc systemAccessLogRpc;
|
private SystemAccessLogRpc systemAccessLogRpc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,9 +19,9 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class SystemExceptionLogManager {
|
public class SystemExceptionLogManager {
|
||||||
|
|
||||||
@Reference(version = "${dubbo.consumer.SystemExceptionLogRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.SystemExceptionLogRpc.version}")
|
||||||
private SystemExceptionLogRpc systemExceptionLogRpc;
|
private SystemExceptionLogRpc systemExceptionLogRpc;
|
||||||
@Reference(version = "${dubbo.consumer.AdminRpc.version}", validation = "false")
|
@Reference(version = "${dubbo.consumer.AdminRpc.version}")
|
||||||
private AdminRpc adminRpc;
|
private AdminRpc adminRpc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,6 +24,7 @@ dubbo:
|
|||||||
# Dubbo 服务消费者的配置
|
# Dubbo 服务消费者的配置
|
||||||
consumer:
|
consumer:
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
|
validation: true # 开启 Consumer 参数校验
|
||||||
UserSmsCodeRpc:
|
UserSmsCodeRpc:
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
UserRpc:
|
UserRpc:
|
||||||
|
@ -20,6 +20,7 @@ dubbo:
|
|||||||
# Dubbo 服务消费者的配置
|
# Dubbo 服务消费者的配置
|
||||||
consumer:
|
consumer:
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
|
validation: true # 开启 Consumer 的参数校验
|
||||||
UserSmsCodeRpc:
|
UserSmsCodeRpc:
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
UserRpc:
|
UserRpc:
|
||||||
|
Loading…
Reference in New Issue
Block a user