diff --git a/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/core/interceptor/AdminSecurityInterceptor.java b/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/core/interceptor/AdminSecurityInterceptor.java index f9432bebf..baff3997b 100644 --- a/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/core/interceptor/AdminSecurityInterceptor.java +++ b/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/core/interceptor/AdminSecurityInterceptor.java @@ -27,9 +27,9 @@ import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeEnum.OAUTH_USER public class AdminSecurityInterceptor extends HandlerInterceptorAdapter { - @Reference(validation = "true", version = "${dubbo.consumer.OAuth2Rpc.version}") + @Reference(version = "${dubbo.consumer.OAuth2Rpc.version}") private OAuth2Rpc oauth2Rpc; - @Reference(validation = "true", version = "${dubbo.consumer.PermissionRpc.version}") + @Reference(version = "${dubbo.consumer.PermissionRpc.version}") private PermissionRpc permissionRpc; @Override diff --git a/common/mall-spring-boot-starter-security-user/src/main/java/cn/iocoder/mall/security/user/core/interceptor/UserSecurityInterceptor.java b/common/mall-spring-boot-starter-security-user/src/main/java/cn/iocoder/mall/security/user/core/interceptor/UserSecurityInterceptor.java index 190fc42a6..14033d8bb 100644 --- a/common/mall-spring-boot-starter-security-user/src/main/java/cn/iocoder/mall/security/user/core/interceptor/UserSecurityInterceptor.java +++ b/common/mall-spring-boot-starter-security-user/src/main/java/cn/iocoder/mall/security/user/core/interceptor/UserSecurityInterceptor.java @@ -23,7 +23,7 @@ import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeEnum.OAUTH_USER public class UserSecurityInterceptor extends HandlerInterceptorAdapter { - @Reference(validation = "true", version = "${dubbo.consumer.OAuth2Rpc.version}") + @Reference(version = "${dubbo.consumer.OAuth2Rpc.version}") private OAuth2Rpc oauth2Rpc; @Override diff --git a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/handler/GlobalExceptionHandler.java b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/handler/GlobalExceptionHandler.java index 3d5e4f4f4..46077edb7 100644 --- a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/handler/GlobalExceptionHandler.java +++ b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/handler/GlobalExceptionHandler.java @@ -51,7 +51,7 @@ public class GlobalExceptionHandler { private String applicationName; // TODO 目前存在一个问题,如果未引入 system-rpc-api 依赖,GlobalExceptionHandler 会报类不存在。未来封装出 Repository 解决该问题 - @Reference(validation = "true", version = "${dubbo.consumer.SystemExceptionLogRpc.version}") + @Reference(version = "${dubbo.consumer.SystemExceptionLogRpc.version}") private SystemExceptionLogRpc systemExceptionLogRpc; /** @@ -199,6 +199,7 @@ public class GlobalExceptionHandler { .setExceptionTime(new Date()); } + // TODO 优化点:后续可以增加事件 @Async public void addExceptionLog(SystemExceptionLogCreateDTO exceptionLog) { try { diff --git a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/interceptor/AccessLogInterceptor.java b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/interceptor/AccessLogInterceptor.java index d3ec9fb59..a8f54379c 100644 --- a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/interceptor/AccessLogInterceptor.java +++ b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/interceptor/AccessLogInterceptor.java @@ -26,7 +26,7 @@ public class AccessLogInterceptor extends HandlerInterceptorAdapter { private Logger logger = LoggerFactory.getLogger(getClass()); - @Reference(validation = "false", version = "${dubbo.consumer.SystemAccessLogRpc.version}") + @Reference(version = "${dubbo.consumer.SystemAccessLogRpc.version}") private SystemAccessLogRpc systemAccessLogRpc; @Value("${spring.application.name}") @@ -77,6 +77,7 @@ public class AccessLogInterceptor extends HandlerInterceptorAdapter { .setResponseTime((int) (System.currentTimeMillis() - accessLog.getStartTime().getTime())); // 默认响应时间设为 0 } + // TODO 优化点:后续可以增加事件 @Async // 异步入库 public void addAccessLog(SystemAccessLogCreateDTO accessLog) { try { diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/passport/PassportController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/passport/PassportController.http index 6fa47ca56..d5527e7e1 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/passport/PassportController.http +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/passport/PassportController.http @@ -10,6 +10,12 @@ Content-Type: application/x-www-form-urlencoded username=admin&password=1024 +### /passport/login 少传参数 +POST {{baseUrl}}/passport/login +Content-Type: application/x-www-form-urlencoded + +username=admin + ### /passport/info 成功 GET {{baseUrl}}/passport/info Authorization: Bearer {{accessToken}} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/admin/AdminManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/admin/AdminManager.java index a50fde68c..2d6d2bae5 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/admin/AdminManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/admin/AdminManager.java @@ -27,13 +27,13 @@ import java.util.*; @Validated public class AdminManager { - @Reference(version = "${dubbo.consumer.AdminRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.AdminRpc.version}") private AdminRpc adminRpc; - @Reference(version = "${dubbo.consumer.RoleRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.RoleRpc.version}") private RoleRpc roleRpc; - @Reference(version = "${dubbo.consumer.DepartmentRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.DepartmentRpc.version}") private DepartmentRpc departmentRpc; - @Reference(version = "${dubbo.consumer.PermissionRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.PermissionRpc.version}") private PermissionRpc permissionRpc; public PageResult pageAdmin(AdminPageDTO pageDTO) { diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/admin/DepartmentManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/admin/DepartmentManager.java index f278d87e3..1374e2f0c 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/admin/DepartmentManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/admin/DepartmentManager.java @@ -22,7 +22,7 @@ import java.util.stream.Collectors; @Slf4j public class DepartmentManager { - @Reference(version = "${dubbo.consumer.DepartmentRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.DepartmentRpc.version}") private DepartmentRpc departmentRpc; /** diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/datadict/DataDictManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/datadict/DataDictManager.java index aedde1fbc..627ea7de1 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/datadict/DataDictManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/datadict/DataDictManager.java @@ -19,15 +19,11 @@ import java.util.List; @Service public class DataDictManager { - private static final Comparator COMPARATOR_ENUM_VALUE_SORT = (o1, o2) -> { - int cmp = o1.getEnumValue().compareTo(o2.getEnumValue()); - if (cmp != 0) { - return cmp; - } - return o1.getSort().compareTo(o2.getSort()); - }; + private static final Comparator COMPARATOR_ENUM_VALUE_SORT = Comparator + .comparing(cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO::getEnumValue) + .thenComparingInt(cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO::getSort); - @Reference(version = "${dubbo.consumer.DataDictRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.DataDictRpc.version}") private DataDictRpc dataDictRpc; /** diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/passport/PassportManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/passport/PassportManager.java index c7d1b923a..c648533fd 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/passport/PassportManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/passport/PassportManager.java @@ -30,13 +30,13 @@ import java.util.Set; @Service public class PassportManager { - @Reference(version = "${dubbo.consumer.AdminRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.AdminRpc.version}") private AdminRpc adminRpc; - @Reference(version = "${dubbo.consumer.OAuth2Rpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.OAuth2Rpc.version}") private OAuth2Rpc oauth2Rpc; - @Reference(version = "${dubbo.consumer.RoleRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.RoleRpc.version}") private RoleRpc roleRpc; - @Reference(version = "${dubbo.consumer.ResourceRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.ResourceRpc.version}") private ResourceRpc resourceRpc; public PassportAccessTokenVO login(PassportLoginDTO loginDTO, String ip) { diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/PermissionManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/PermissionManager.java index 2463a6c50..d6850b4a6 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/PermissionManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/PermissionManager.java @@ -16,7 +16,7 @@ import java.util.Set; @Service public class PermissionManager { - @Reference(version = "${dubbo.consumer.PermissionRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.PermissionRpc.version}") private PermissionRpc permissionRpc; /** diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/ResourceManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/ResourceManager.java index 48812e2eb..8243951de 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/ResourceManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/ResourceManager.java @@ -23,9 +23,9 @@ import java.util.stream.Collectors; @Slf4j public class ResourceManager { - @Reference(version = "${dubbo.consumer.ResourceRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.ResourceRpc.version}") private ResourceRpc resourceRpc; - @Reference(version = "${dubbo.consumer.RoleRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.RoleRpc.version}") private RoleRpc roleRpc; /** diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/RoleManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/RoleManager.java index d5aa78170..1abe627f0 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/RoleManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/RoleManager.java @@ -19,7 +19,7 @@ import java.util.List; @Service public class RoleManager { - @Reference(version = "${dubbo.consumer.RoleRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.RoleRpc.version}") private RoleRpc roleRpc; /** diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/systemlog/SystemAccessLogManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/systemlog/SystemAccessLogManager.java index 0528c0fbc..8415b78ca 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/systemlog/SystemAccessLogManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/systemlog/SystemAccessLogManager.java @@ -15,7 +15,7 @@ import org.springframework.stereotype.Service; @Service public class SystemAccessLogManager { - @Reference(version = "${dubbo.consumer.SystemAccessLogRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.SystemAccessLogRpc.version}") private SystemAccessLogRpc systemAccessLogRpc; /** diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/systemlog/SystemExceptionLogManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/systemlog/SystemExceptionLogManager.java index e02d577f3..992f1398f 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/systemlog/SystemExceptionLogManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/systemlog/SystemExceptionLogManager.java @@ -19,9 +19,9 @@ import org.springframework.stereotype.Service; @Service public class SystemExceptionLogManager { - @Reference(version = "${dubbo.consumer.SystemExceptionLogRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.SystemExceptionLogRpc.version}") private SystemExceptionLogRpc systemExceptionLogRpc; - @Reference(version = "${dubbo.consumer.AdminRpc.version}", validation = "false") + @Reference(version = "${dubbo.consumer.AdminRpc.version}") private AdminRpc adminRpc; /** diff --git a/management-web-app/src/main/resources/application.yml b/management-web-app/src/main/resources/application.yml index dab91438b..c8c82df96 100644 --- a/management-web-app/src/main/resources/application.yml +++ b/management-web-app/src/main/resources/application.yml @@ -24,6 +24,7 @@ dubbo: # Dubbo 服务消费者的配置 consumer: timeout: 10000 + validation: true # 开启 Consumer 参数校验 UserSmsCodeRpc: version: 1.0.0 UserRpc: diff --git a/user-web-app/src/main/resources/application.yml b/user-web-app/src/main/resources/application.yml index 4dca395be..8d3df60bf 100644 --- a/user-web-app/src/main/resources/application.yml +++ b/user-web-app/src/main/resources/application.yml @@ -20,6 +20,7 @@ dubbo: # Dubbo 服务消费者的配置 consumer: timeout: 10000 + validation: true # 开启 Consumer 的参数校验 UserSmsCodeRpc: version: 1.0.0 UserRpc: