From e3f2e15c43bd750a60e5f8040202d9b11337ed92 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Fri, 17 Jul 2020 19:59:43 +0800 Subject: [PATCH] =?UTF-8?q?bom=20=E6=96=87=E4=BB=B6=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/common-framework/pom.xml | 36 ++- .../framework/dubbo/DubboExceptionFilter.java | 106 --------- .../framework/exception/ServiceException.java | 2 + .../common/framework/util/ExceptionUtil.java | 43 ---- .../common/framework/vo/CommonResult.java | 6 +- .../mall-spring-boot-starter-dubbo}/pom.xml | 33 ++- .../filter/DubboProviderExceptionFilter.java | 116 ++++++++++ .../iocoder/mall/dubbo/core/package-info.java | 4 + .../dubbo/com.alibaba.dubbo.rpc.Filter | 0 .../AdminSecurityAutoConfiguration.java | 18 +- .../admin/config/AdminSecurityProperties.java | 41 ++++ .../core/handler/GlobalExceptionHandler.java | 2 +- common/pom.xml | 11 +- demo/demo-application/pom.xml | 132 ----------- .../demo/application/DemoApplication.java | 27 --- .../controller/DemoOrderController.java | 28 --- .../controller/DemoProductController.java | 27 --- .../controller/DemoUserController.java | 28 --- .../application/convert/DemoOrderConvert.java | 17 -- .../convert/DemoProductConvert.java | 17 -- .../application/convert/DemoUserConvert.java | 17 -- .../demo/application/dto/DemoOrderAddDTO.java | 14 -- .../demo/application/vo/DemoProductVO.java | 22 -- .../mall/demo/application/vo/DemoUserVO.java | 23 -- .../src/main/resources/application-dev.yaml | 0 .../src/main/resources/application-local.yaml | 15 -- .../src/main/resources/application-pre.yaml | 0 .../src/main/resources/application-prod.yaml | 0 .../src/main/resources/application-uat.yaml | 0 .../src/main/resources/application.yaml | 12 - .../demo/business/api/DemoOrderService.java | 12 - .../demo/business/api/DemoProductService.java | 20 -- .../demo/business/api/DemoUserService.java | 9 - .../business/bo/order/DemoOrderAddBO.java | 21 -- .../business/bo/order/DemoOrderCancelBO.java | 4 - .../business/bo/product/DemoProductAddBO.java | 27 --- .../business/bo/product/DemoProductBO.java | 32 --- .../bo/product/DemoProductPageBO.java | 13 -- .../product/DemoProductQuantityReduceBO.java | 29 --- .../bo/product/DemoProductUpdateBO.java | 32 --- .../demo/business/bo/user/DemoUserBO.java | 26 --- .../business/constant/OrderStatusEnum.java | 38 ---- .../mall/demo/business/package-info.java | 1 - demo/demo-business/pom.xml | 78 ------- .../business/cacheobject/package-info.java | 1 - .../cacheobject/user/DemoUserCacheObject.java | 26 --- .../config/DatabaseConfiguration.java | 14 -- .../business/convert/DemoOrderConvert.java | 17 -- .../business/convert/DemoProductConvert.java | 17 -- .../business/convert/DemoUserConvert.java | 17 -- .../business/dao/mysql/DemoOrderMapper.java | 10 - .../business/dao/mysql/DemoProductMapper.java | 14 -- .../business/dao/redis/DemoUserCacheDao.java | 31 --- .../dataobject/order/DemoOrderDO.java | 42 ---- .../dataobject/product/DemoProductDO.java | 35 --- .../mall/demo/business/package-info.java | 1 - .../service/DemoOrderServiceImpl.java | 58 ----- .../service/DemoProductServiceImpl.java | 48 ---- .../business/service/DemoUserServiceImpl.java | 27 --- .../src/main/resources/business-local.yaml | 22 -- .../resources/mapper/DemoProductMapper.xml | 12 - demo/demo-job/pom.xml | 15 -- .../mall/demo/job/handler/DemoJobHandler.java | 4 - .../iocoder/mall/demo/job/package-info.java | 1 - demo/demo-mq/pom.xml | 15 -- .../cn/iocoder/mall/demo/mq/package-info.java | 1 - demo/demo-rpc-service-api/pom.xml | 45 ---- .../demo/rpc/api/DemoProductRpcService.java | 9 - .../mall/demo/rpc/api/DemoUserRpcService.java | 9 - .../mall/demo/rpc/dto/DemoProductDTO.java | 22 -- .../mall/demo/rpc/dto/DemoUserDTO.java | 23 -- .../iocoder/mall/demo/rpc/package-info.java | 1 - demo/demo-rpc-service/pom.xml | 65 ------ .../demo/rpc/convert/DemoProductConvert.java | 17 -- .../demo/rpc/convert/DemoUserConvert.java | 17 -- .../iocoder/mall/demo/rpc/package-info.java | 1 - .../service/DemoProductRpcServiceImpl.java | 23 -- .../rpc/service/DemoUserRpcServiceImpl.java | 23 -- .../src/main/resources/rpc-local.yaml | 20 -- demo/pom.xml | 36 --- mall-dependencies/pom.xml | 167 +++++++++++++- .../controller/admin/AdminController.java | 2 +- .../src/main/resources/application.yml | 2 +- pom.xml | 213 ------------------ .../system-service-api/pom.xml | 5 + .../system-service-app/pom.xml | 12 - .../service/admin/bo/AdminPageBO.java | 2 - 87 files changed, 383 insertions(+), 1898 deletions(-) delete mode 100644 common/common-framework/src/main/java/cn/iocoder/common/framework/dubbo/DubboExceptionFilter.java rename {demo/demo-business-api => common/mall-spring-boot-starter-dubbo}/pom.xml (53%) create mode 100644 common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/core/filter/DubboProviderExceptionFilter.java create mode 100644 common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/core/package-info.java rename common/{common-framework/src/main/resource => mall-spring-boot-starter-dubbo/src/main/resources}/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter (100%) create mode 100644 common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/config/AdminSecurityProperties.java delete mode 100644 demo/demo-application/pom.xml delete mode 100644 demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/DemoApplication.java delete mode 100644 demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoOrderController.java delete mode 100644 demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoProductController.java delete mode 100644 demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoUserController.java delete mode 100644 demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoOrderConvert.java delete mode 100644 demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoProductConvert.java delete mode 100644 demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoUserConvert.java delete mode 100644 demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/dto/DemoOrderAddDTO.java delete mode 100644 demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/vo/DemoProductVO.java delete mode 100644 demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/vo/DemoUserVO.java delete mode 100644 demo/demo-application/src/main/resources/application-dev.yaml delete mode 100644 demo/demo-application/src/main/resources/application-local.yaml delete mode 100644 demo/demo-application/src/main/resources/application-pre.yaml delete mode 100644 demo/demo-application/src/main/resources/application-prod.yaml delete mode 100644 demo/demo-application/src/main/resources/application-uat.yaml delete mode 100644 demo/demo-application/src/main/resources/application.yaml delete mode 100644 demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoOrderService.java delete mode 100644 demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoProductService.java delete mode 100644 demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoUserService.java delete mode 100644 demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/order/DemoOrderAddBO.java delete mode 100644 demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/order/DemoOrderCancelBO.java delete mode 100644 demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductAddBO.java delete mode 100644 demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductBO.java delete mode 100644 demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductPageBO.java delete mode 100644 demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductQuantityReduceBO.java delete mode 100644 demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductUpdateBO.java delete mode 100644 demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/user/DemoUserBO.java delete mode 100644 demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/constant/OrderStatusEnum.java delete mode 100644 demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/package-info.java delete mode 100644 demo/demo-business/pom.xml delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/cacheobject/package-info.java delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/cacheobject/user/DemoUserCacheObject.java delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/config/DatabaseConfiguration.java delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoOrderConvert.java delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoProductConvert.java delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoUserConvert.java delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/mysql/DemoOrderMapper.java delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/mysql/DemoProductMapper.java delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/redis/DemoUserCacheDao.java delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dataobject/order/DemoOrderDO.java delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dataobject/product/DemoProductDO.java delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/package-info.java delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoOrderServiceImpl.java delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoProductServiceImpl.java delete mode 100644 demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoUserServiceImpl.java delete mode 100644 demo/demo-business/src/main/resources/business-local.yaml delete mode 100644 demo/demo-business/src/main/resources/mapper/DemoProductMapper.xml delete mode 100644 demo/demo-job/pom.xml delete mode 100644 demo/demo-job/src/main/java/cn/iocoder/mall/demo/job/handler/DemoJobHandler.java delete mode 100644 demo/demo-job/src/main/java/cn/iocoder/mall/demo/job/package-info.java delete mode 100644 demo/demo-mq/pom.xml delete mode 100644 demo/demo-mq/src/main/java/cn/iocoder/mall/demo/mq/package-info.java delete mode 100644 demo/demo-rpc-service-api/pom.xml delete mode 100644 demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/api/DemoProductRpcService.java delete mode 100644 demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/api/DemoUserRpcService.java delete mode 100644 demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/dto/DemoProductDTO.java delete mode 100644 demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/dto/DemoUserDTO.java delete mode 100644 demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/package-info.java delete mode 100644 demo/demo-rpc-service/pom.xml delete mode 100644 demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/convert/DemoProductConvert.java delete mode 100644 demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/convert/DemoUserConvert.java delete mode 100644 demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/package-info.java delete mode 100644 demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/service/DemoProductRpcServiceImpl.java delete mode 100644 demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/service/DemoUserRpcServiceImpl.java delete mode 100644 demo/demo-rpc-service/src/main/resources/rpc-local.yaml delete mode 100644 demo/pom.xml diff --git a/common/common-framework/pom.xml b/common/common-framework/pom.xml index 1d7f7eefb..0281b812e 100644 --- a/common/common-framework/pom.xml +++ b/common/common-framework/pom.xml @@ -21,39 +21,47 @@ org.springframework spring-web + true org.springframework spring-webmvc + true io.swagger swagger-annotations - - - - - org.apache.dubbo - dubbo + true org.apache.skywalking apm-toolkit-trace + true org.slf4j slf4j-api + true + + + + + junit + junit + 4.8.1 + test org.hibernate hibernate-validator + true @@ -62,21 +70,11 @@ - com.fasterxml.jackson.core - jackson-annotations - - - com.fasterxml.jackson.core - jackson-databind - - - junit - junit - 4.8.1 - test + com.alibaba + fastjson + true - cn.hutool hutool-all diff --git a/common/common-framework/src/main/java/cn/iocoder/common/framework/dubbo/DubboExceptionFilter.java b/common/common-framework/src/main/java/cn/iocoder/common/framework/dubbo/DubboExceptionFilter.java deleted file mode 100644 index fb348ab1f..000000000 --- a/common/common-framework/src/main/java/cn/iocoder/common/framework/dubbo/DubboExceptionFilter.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.common.framework.dubbo; - -import cn.iocoder.common.framework.exception.ServiceException; -import org.apache.dubbo.common.constants.CommonConstants; -import org.apache.dubbo.common.extension.Activate; -import org.apache.dubbo.common.logger.Logger; -import org.apache.dubbo.common.logger.LoggerFactory; -import org.apache.dubbo.common.utils.ReflectUtils; -import org.apache.dubbo.common.utils.StringUtils; -import org.apache.dubbo.rpc.*; -import org.apache.dubbo.rpc.filter.ExceptionFilter; -import org.apache.dubbo.rpc.service.GenericService; - -import java.lang.reflect.Method; - -/** - * 基于 {@link org.apache.dubbo.rpc.filter.ExceptionFilter} 实现 - * - * 主要目的是,一些全局性的异常,能够返回。因为,Dubbo Consumer 能够保证,一定会引入全局性的异常。 - */ -@Activate(group = CommonConstants.PROVIDER) -public class DubboExceptionFilter implements Filter { - - private final Logger logger; - - public DubboExceptionFilter() { - this(LoggerFactory.getLogger(ExceptionFilter.class)); - } - - public DubboExceptionFilter(Logger logger) { - this.logger = logger; - } - - @Override - public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { - try { - return invoker.invoke(invocation); - } catch (RuntimeException e) { - logger.error("Got unchecked and undeclared exception which called by " + RpcContext.getContext().getRemoteHost() - + ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() - + ", exception: " + e.getClass().getName() + ": " + e.getMessage(), e); - throw e; - } - } - - @Override - public Result onResponse(Result result, Invoker invoker, Invocation invocation) { - if (result.hasException() && GenericService.class != invoker.getInterface()) { - try { - Throwable exception = result.getException(); - - // directly throw if it's checked exception - if (!(exception instanceof RuntimeException) && (exception instanceof Exception)) { - return result; - } else if (exception instanceof ServiceException) { // add by 芋艿。如果是业务异常,继续抛出 - return result; - } - // directly throw if the exception appears in the signature - try { - Method method = invoker.getInterface().getMethod(invocation.getMethodName(), invocation.getParameterTypes()); - Class[] exceptionClassses = method.getExceptionTypes(); - for (Class exceptionClass : exceptionClassses) { - if (exception.getClass().equals(exceptionClass)) { - return result; - } - } - } catch (NoSuchMethodException e) { - return result; - } - - // for the exception not found in method's signature, print ERROR message in server's log. - logger.error("Got unchecked and undeclared exception which called by " + RpcContext.getContext().getRemoteHost() - + ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() - + ", exception: " + exception.getClass().getName() + ": " + exception.getMessage(), exception); - - // directly throw if exception class and interface class are in the same jar file. - String serviceFile = ReflectUtils.getCodeBase(invoker.getInterface()); - String exceptionFile = ReflectUtils.getCodeBase(exception.getClass()); - if (serviceFile == null || exceptionFile == null || serviceFile.equals(exceptionFile)) { - return result; - } - // directly throw if it's JDK exception - String className = exception.getClass().getName(); - if (className.startsWith("java.") || className.startsWith("javax.")) { - return result; - } - // directly throw if it's dubbo exception - if (exception instanceof RpcException) { - return result; - } - - // otherwise, wrap with RuntimeException and throw back to the client - result.setException(new RuntimeException(StringUtils.toString(exception))); - return result; - } catch (Throwable e) { - logger.warn("Fail to ExceptionFilter when called by " + RpcContext.getContext().getRemoteHost() - + ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() - + ", exception: " + e.getClass().getName() + ": " + e.getMessage(), e); - return result; - } - } - return result; - } - -} - diff --git a/common/common-framework/src/main/java/cn/iocoder/common/framework/exception/ServiceException.java b/common/common-framework/src/main/java/cn/iocoder/common/framework/exception/ServiceException.java index 933255c26..15ce194b2 100644 --- a/common/common-framework/src/main/java/cn/iocoder/common/framework/exception/ServiceException.java +++ b/common/common-framework/src/main/java/cn/iocoder/common/framework/exception/ServiceException.java @@ -43,4 +43,6 @@ public final class ServiceException extends RuntimeException { return code; } + + } diff --git a/common/common-framework/src/main/java/cn/iocoder/common/framework/util/ExceptionUtil.java b/common/common-framework/src/main/java/cn/iocoder/common/framework/util/ExceptionUtil.java index a5dbbb1b9..7fe3b1a86 100644 --- a/common/common-framework/src/main/java/cn/iocoder/common/framework/util/ExceptionUtil.java +++ b/common/common-framework/src/main/java/cn/iocoder/common/framework/util/ExceptionUtil.java @@ -1,52 +1,9 @@ package cn.iocoder.common.framework.util; -import cn.iocoder.common.framework.exception.ServiceException; import org.apache.commons.lang3.exception.ExceptionUtils; -import javax.validation.ConstraintViolationException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.UndeclaredThrowableException; - public class ExceptionUtil { - public static ServiceException getServiceException(Exception e) { - if (e instanceof UndeclaredThrowableException) { - return getServiceException((UndeclaredThrowableException) e); - } - return null; - } - - // 处理 Spring 动态代理调用时,发生 UndeclaredThrowableException 的情况。 - // 不了解的胖友,可以先看看 https://segmentfault.com/a/1190000012262244 文章 - // 原因是: - // 1. Dubbo 动态代理 Wrapper 会将抛出的异常,包装成 InvocationTargetException 异常 - // 2. Spring AOP 发现是 InvocationTargetException 异常是非方法定义的异常,则会包装成 UndeclaredThrowableException 异常。 - @Deprecated // https://github.com/apache/incubator-dubbo/issues/3386 Dubbo 2.6.5 会触发该问题,在 2.7.1 版本已经解决。 - public static ServiceException getServiceException(UndeclaredThrowableException e) { - Throwable undeclaredThrowable = e.getUndeclaredThrowable(); - if (undeclaredThrowable instanceof InvocationTargetException) { - InvocationTargetException invocationTargetException = (InvocationTargetException) undeclaredThrowable; - Throwable targetException = invocationTargetException.getTargetException(); - if (targetException != null & targetException instanceof ServiceException) { - return (ServiceException) targetException; - } - } - return null; - } - - @Deprecated // https://github.com/apache/incubator-dubbo/issues/3386 Dubbo 2.6.5 会触发该问题,在 2.7.1 版本已经解决。 - public static ConstraintViolationException getConstraintViolationException(UndeclaredThrowableException e) { - Throwable undeclaredThrowable = e.getUndeclaredThrowable(); - if (undeclaredThrowable instanceof InvocationTargetException) { - InvocationTargetException invocationTargetException = (InvocationTargetException) undeclaredThrowable; - Throwable targetException = invocationTargetException.getTargetException(); - if (targetException instanceof ConstraintViolationException) { - return (ConstraintViolationException) targetException; - } - } - return null; - } - public static String getMessage(Throwable th) { return ExceptionUtils.getMessage(th); } diff --git a/common/common-framework/src/main/java/cn/iocoder/common/framework/vo/CommonResult.java b/common/common-framework/src/main/java/cn/iocoder/common/framework/vo/CommonResult.java index 2cf042db9..1fb1d0158 100644 --- a/common/common-framework/src/main/java/cn/iocoder/common/framework/vo/CommonResult.java +++ b/common/common-framework/src/main/java/cn/iocoder/common/framework/vo/CommonResult.java @@ -2,7 +2,7 @@ package cn.iocoder.common.framework.vo; import cn.iocoder.common.framework.enums.GlobalErrorCodeEnum; import cn.iocoder.common.framework.util.ServiceExceptionUtil; -import com.fasterxml.jackson.annotation.JsonIgnore; +import com.alibaba.fastjson.annotation.JSONField; import org.springframework.util.Assert; import java.io.Serializable; @@ -95,12 +95,12 @@ public final class CommonResult implements Serializable { return this; } - @JsonIgnore + @JSONField(serialize = false) // 避免序列化 public boolean isSuccess() { return CODE_SUCCESS.equals(code); } - @JsonIgnore + @JSONField(serialize = false) // 避免序列化 public boolean isError() { return !isSuccess(); } diff --git a/demo/demo-business-api/pom.xml b/common/mall-spring-boot-starter-dubbo/pom.xml similarity index 53% rename from demo/demo-business-api/pom.xml rename to common/mall-spring-boot-starter-dubbo/pom.xml index 9e3d3616a..35e5202c4 100644 --- a/demo/demo-business-api/pom.xml +++ b/common/mall-spring-boot-starter-dubbo/pom.xml @@ -3,42 +3,41 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - demo + common cn.iocoder.mall 1.0-SNAPSHOT 4.0.0 - jar - demo-business-api + mall-spring-boot-starter-dubbo - + cn.iocoder.mall common-framework - 1.0-SNAPSHOT - + - io.swagger - swagger-annotations + org.apache.dubbo + dubbo + + + org.apache.dubbo + dubbo-spring-boot-starter - + - org.mapstruct - mapstruct - - - org.mapstruct - mapstruct-jdk8 + org.slf4j + slf4j-api + - org.projectlombok - lombok + javax.validation + validation-api diff --git a/common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/core/filter/DubboProviderExceptionFilter.java b/common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/core/filter/DubboProviderExceptionFilter.java new file mode 100644 index 000000000..ef63ab4cd --- /dev/null +++ b/common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/core/filter/DubboProviderExceptionFilter.java @@ -0,0 +1,116 @@ +package cn.iocoder.mall.dubbo.core.filter; + +import cn.iocoder.common.framework.enums.GlobalErrorCodeEnum; +import cn.iocoder.common.framework.exception.ServiceException; +import cn.iocoder.common.framework.util.ExceptionUtil; +import cn.iocoder.common.framework.util.ServiceExceptionUtil; +import cn.iocoder.common.framework.vo.CommonResult; +import org.apache.dubbo.rpc.*; +import org.apache.dubbo.rpc.service.GenericService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; +import java.lang.reflect.Type; + +public class DubboProviderExceptionFilter implements Filter, Filter.Listener { + + private Logger logger = LoggerFactory.getLogger(DubboProviderExceptionFilter.class); + + @Override + public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { + return invoker.invoke(invocation); + } + + @Override + public void onResponse(Result appResponse, Invoker invoker, Invocation invocation) { + if (appResponse.hasException() && GenericService.class != invoker.getInterface()) { + try { + // 转换异常 + Throwable exception = appResponse.getException(); + if (exception instanceof ConstraintViolationException) { + exception = this.constraintViolationExceptionHandler((ConstraintViolationException) exception); + } + // 根据不同的方法 schema 返回结果 + // 第一种情况,则根据返回参数类型是否是 CommonResult 的情况,则将 ServiceException 转换成 CommonResult + if (isReturnCommonResult(invocation)) { + // 清空异常 + appResponse.setException(null); + // 设置结果 + CommonResult exceptionResult = new CommonResult(); + appResponse.setValue(exceptionResult); + // 处理非 ServiceException 业务异常,转换成 ServiceException 业务异常 + if (!(exception instanceof ServiceException)) { + logger.error("[onResponse][service({}) method({}) params({}) 执行异常]", + invocation.getServiceName(), invocation.getServiceName(), invocation.getArguments(), exception); + // + } + } + + // 1. 处理 ServiceException 异常的情况 + if (exception instanceof ServiceException) { + ServiceException serviceException = (ServiceException) exception; + // 则根据返回参数类型是否是 CommonResult 的情况,则将 ServiceException 转换成 CommonResult + if (isReturnCommonResult(invocation)) { + // 通用返回 + CommonResult exceptionResult = new CommonResult(); + exceptionResult.setCode(serviceException.getCode()); + exceptionResult.setMessage(serviceException.getMessage()); + appResponse.setValue(exceptionResult); + // 清空异常 + appResponse.setException(null); + // 如果不是 CommonResult 的情况,则将 ServiceException 转换成 DubboInvokeException 避免可能存在的反序列化问题 + } else { + RpcContext context = RpcContext.getContext(); + appResponse.setException(new DubboInvokeException(exception.getMessage(), context.getLocalHost(), context.getLocalHostName())); + } + // 2. 处理非 ServiceException 异常的情况 + } else { + RpcContext context = RpcContext.getContext(); + appResponse.setException(new DubboInvokeException(exception.getMessage(), context.getLocalHost(), context.getLocalHostName())); + + } + } catch (Throwable e) { + logger.warn("Fail to ExceptionFilter when called by " + RpcContext.getContext().getRemoteHost() + ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + ", exception: " + e.getClass().getName() + ": " + e.getMessage(), e); + } + } + } + + @Override + public void onError(Throwable e, Invoker invoker, Invocation invocation) { + logger.error("Got unchecked and undeclared exception which called by " + RpcContext.getContext().getRemoteHost() + ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + ", exception: " + e.getClass().getName() + ": " + e.getMessage(), e); + } + + private boolean isReturnCommonResult(Invocation invocation) { + if (!(invocation instanceof RpcInvocation)) { + return false; + } + RpcInvocation rpcInvocation = (RpcInvocation) invocation; + Type[] returnTypes = rpcInvocation.getReturnTypes(); + if (returnTypes.length == 0) { + return false; + } + Type returnType = returnTypes[0]; + if (!(returnType instanceof Class)) { + return false; + } + Class returnClass = (Class) returnType; + return returnClass == CommonResult.class; + } + + /** + * 处理 Validator 校验不通过产生的异常 + */ + private ServiceException constraintViolationExceptionHandler(ConstraintViolationException ex) { + logger.warn("[constraintViolationExceptionHandler]", ex); + ConstraintViolation constraintViolation = ex.getConstraintViolations().iterator().next(); + return ServiceExceptionUtil.exception0(GlobalErrorCodeEnum.BAD_REQUEST.getCode(), + String.format("请求参数不正确:%s", constraintViolation.getMessage())); + } + + private ServiceException defaultExceptionHandler() { + + } + +} diff --git a/common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/core/package-info.java b/common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/core/package-info.java new file mode 100644 index 000000000..7d9fe0e5c --- /dev/null +++ b/common/mall-spring-boot-starter-dubbo/src/main/java/cn/iocoder/mall/dubbo/core/package-info.java @@ -0,0 +1,4 @@ +/** + * 占坑 + */ +package cn.iocoder.mall.dubbo.core; diff --git a/common/common-framework/src/main/resource/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter b/common/mall-spring-boot-starter-dubbo/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter similarity index 100% rename from common/common-framework/src/main/resource/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter rename to common/mall-spring-boot-starter-dubbo/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter diff --git a/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/config/AdminSecurityAutoConfiguration.java b/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/config/AdminSecurityAutoConfiguration.java index 3575e9fb3..322016c37 100644 --- a/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/config/AdminSecurityAutoConfiguration.java +++ b/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/config/AdminSecurityAutoConfiguration.java @@ -6,7 +6,9 @@ import cn.iocoder.mall.web.config.CommonWebAutoConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; @@ -15,10 +17,17 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration @AutoConfigureAfter(CommonWebAutoConfiguration.class) // 在 CommonWebAutoConfiguration 之后自动配置,保证过滤器的顺序 @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET) +@EnableConfigurationProperties(AdminSecurityProperties.class) public class AdminSecurityAutoConfiguration implements WebMvcConfigurer { private Logger logger = LoggerFactory.getLogger(getClass()); + @Bean + @ConditionalOnMissingBean + public AdminSecurityProperties adminSecurityProperties() { + return new AdminSecurityProperties(); + } + // ========== 拦截器相关 ========== @Bean @@ -33,11 +42,16 @@ public class AdminSecurityAutoConfiguration implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { + AdminSecurityProperties properties = this.adminSecurityProperties(); // AdminSecurityInterceptor 拦截器 - registry.addInterceptor(this.adminSecurityInterceptor()); + registry.addInterceptor(this.adminSecurityInterceptor()) + .excludePathPatterns(properties.getIgnorePaths()) + .excludePathPatterns(properties.getDefaultIgnorePaths()); logger.info("[addInterceptors][加载 AdminSecurityInterceptor 拦截器完成]"); // AdminDemoInterceptor 拦截器 - registry.addInterceptor(this.adminDemoInterceptor()); + registry.addInterceptor(this.adminDemoInterceptor()) + .excludePathPatterns(properties.getIgnorePaths()) + .excludePathPatterns(properties.getDefaultIgnorePaths()); logger.info("[addInterceptors][加载 AdminDemoInterceptor 拦截器完成]"); } diff --git a/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/config/AdminSecurityProperties.java b/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/config/AdminSecurityProperties.java new file mode 100644 index 000000000..7195462d9 --- /dev/null +++ b/common/mall-spring-boot-starter-security-admin/src/main/java/cn/iocoder/mall/security/admin/config/AdminSecurityProperties.java @@ -0,0 +1,41 @@ +package cn.iocoder.mall.security.admin.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties("mall.security.admin") +public class AdminSecurityProperties { + + private static final String[] DEFAULT_IGNORE_PATHS = new String[]{ + // Swagger 相关 + "/doc.html", "/swagger-resources", "/swagger-resources/**", + // Actuator 相关 + }; + + /** + * 自定义忽略 Path + */ + private String[] ignorePaths = new String[0]; + /** + * 默认忽略 Path + */ + private String[] defaultIgnorePaths = DEFAULT_IGNORE_PATHS; + + public String[] getIgnorePaths() { + return ignorePaths; + } + + public AdminSecurityProperties setIgnorePaths(String[] ignorePaths) { + this.ignorePaths = ignorePaths; + return this; + } + + public String[] getDefaultIgnorePaths() { + return defaultIgnorePaths; + } + + public AdminSecurityProperties setDefaultIgnorePaths(String[] defaultIgnorePaths) { + this.defaultIgnorePaths = defaultIgnorePaths; + return this; + } + +} 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 46077edb7..364e9c118 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 @@ -154,7 +154,7 @@ public class GlobalExceptionHandler { * 处理系统异常,兜底处理所有的一切 */ @ExceptionHandler(value = Exception.class) - public CommonResult exceptionHandler(HttpServletRequest req, Throwable e) { + public CommonResult defaultExceptionHandler(HttpServletRequest req, Throwable e) { logger.error("[exceptionHandler]", e); // 插入异常日志 SystemExceptionLogCreateDTO exceptionLog = new SystemExceptionLogCreateDTO(); diff --git a/common/pom.xml b/common/pom.xml index 1599a6b3b..84cc6d5e6 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -20,17 +20,8 @@ mall-spring-boot-starter-security-admin mall-spring-boot-starter-security-user mall-spring-boot-starter-mybatis + mall-spring-boot-starter-dubbo - - - org.springframework - spring-context - - - redis.clients - jedis - - diff --git a/demo/demo-application/pom.xml b/demo/demo-application/pom.xml deleted file mode 100644 index e6e3d67fe..000000000 --- a/demo/demo-application/pom.xml +++ /dev/null @@ -1,132 +0,0 @@ - - - - demo - cn.iocoder.mall - 1.0-SNAPSHOT - - 4.0.0 - - demo-application - - - - - cn.iocoder.mall - common-framework - 1.0-SNAPSHOT - - - - - - - - - - - - - - - - - - - - - - - cn.iocoder.mall - demo-business-api - 1.0-SNAPSHOT - - - cn.iocoder.mall - demo-business - 1.0-SNAPSHOT - - - - cn.iocoder.mall - demo-rpc-service-api - 1.0-SNAPSHOT - - - cn.iocoder.mall - demo-rpc-service - 1.0-SNAPSHOT - - - - - org.springframework.boot - spring-boot-starter-web - - - - io.springfox - springfox-swagger2 - - - com.github.xiaoymin - swagger-bootstrap-ui - - - - - com.qiniu - qiniu-java-sdk - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-sentinel - - - - - de.codecentric - spring-boot-admin-starter-client - - - - org.springframework.boot - spring-boot-starter-actuator - - - - io.micrometer - micrometer-registry-prometheus - - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/DemoApplication.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/DemoApplication.java deleted file mode 100644 index 71b2cc9b5..000000000 --- a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/DemoApplication.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.mall.demo.application; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.config.ConfigFileApplicationListener; -import org.springframework.scheduling.annotation.EnableAsync; - -@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.demo"}) -@EnableAsync(proxyTargetClass = true) -//@PropertySource("classpath*:/application-dubbo.yaml") -public class DemoApplication { - - /** - * 设置需要读取的配置文件的名字。 - * 基于 {@link org.springframework.boot.context.config.ConfigFileApplicationListener#CONFIG_NAME_PROPERTY} 实现。 - */ - private static final String CONFIG_NAME_VALUE = "application,rpc,business"; - - public static void main(String[] args) { - // 设置环境变量 - System.setProperty(ConfigFileApplicationListener.CONFIG_NAME_PROPERTY, CONFIG_NAME_VALUE); - - // 启动 Spring Boot 应用 - SpringApplication.run(DemoApplication.class, args); - } - -} diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoOrderController.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoOrderController.java deleted file mode 100644 index da6dd58ea..000000000 --- a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoOrderController.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.mall.demo.application.controller; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.demo.application.convert.DemoOrderConvert; -import cn.iocoder.mall.demo.application.dto.DemoOrderAddDTO; -import cn.iocoder.mall.demo.business.api.DemoOrderService; -import cn.iocoder.mall.demo.business.bo.order.DemoOrderAddBO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/order") -public class DemoOrderController { - - @Autowired - private DemoOrderService demoOrderService; - - @PostMapping("/add") - public CommonResult add(DemoOrderAddDTO addDTO) { - DemoOrderAddBO addBO = DemoOrderConvert.INSTANCE.convert(addDTO); - addBO.setUserId(10); // TODO 10 用户编号。 - Integer orderId = demoOrderService.add(addBO); - return CommonResult.success(orderId); - } - -} diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoProductController.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoProductController.java deleted file mode 100644 index 3dc6ebcf7..000000000 --- a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoProductController.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.mall.demo.application.controller; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.demo.application.convert.DemoProductConvert; -import cn.iocoder.mall.demo.application.vo.DemoProductVO; -import cn.iocoder.mall.demo.business.api.DemoProductService; -import cn.iocoder.mall.demo.business.bo.product.DemoProductBO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/product") -public class DemoProductController { - - @Autowired - private DemoProductService productService; - - @GetMapping("/get") - public CommonResult get(@RequestParam("id") Integer id) { - DemoProductBO product = productService.get(id); - return CommonResult.success(DemoProductConvert.INSTANCE.convert(product)); - } - -} diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoUserController.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoUserController.java deleted file mode 100644 index 5feb28a2d..000000000 --- a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoUserController.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.mall.demo.application.controller; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.demo.application.convert.DemoUserConvert; -import cn.iocoder.mall.demo.application.vo.DemoUserVO; -import cn.iocoder.mall.demo.rpc.api.DemoUserRpcService; -import cn.iocoder.mall.demo.rpc.dto.DemoUserDTO; -import org.apache.dubbo.config.annotation.Reference; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/user") -public class DemoUserController { - - @Reference(validation = "true", version = "${dubbo.consumer.DemoUserRpcService.version}") - private DemoUserRpcService userRpcService; - - // TODO 芋艿,这里只是做一个 demo 。实际一般不会这么玩,更多是内嵌的,像 {@link #get(Integer id)} 的情况。 - @GetMapping("/get") - public CommonResult get(@RequestParam("id") Integer id) { - DemoUserDTO user = userRpcService.get(id); - return CommonResult.success(DemoUserConvert.INSTANCE.convert(user)); - } - -} diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoOrderConvert.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoOrderConvert.java deleted file mode 100644 index 3c3797868..000000000 --- a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoOrderConvert.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.mall.demo.application.convert; - -import cn.iocoder.mall.demo.application.dto.DemoOrderAddDTO; -import cn.iocoder.mall.demo.business.bo.order.DemoOrderAddBO; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface DemoOrderConvert { - - DemoOrderConvert INSTANCE = Mappers.getMapper(DemoOrderConvert.class); - - @Mappings({}) - DemoOrderAddBO convert(DemoOrderAddDTO addDTO); - -} diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoProductConvert.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoProductConvert.java deleted file mode 100644 index 62826e00b..000000000 --- a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoProductConvert.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.mall.demo.application.convert; - -import cn.iocoder.mall.demo.application.vo.DemoProductVO; -import cn.iocoder.mall.demo.business.bo.product.DemoProductBO; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface DemoProductConvert { - - DemoProductConvert INSTANCE = Mappers.getMapper(DemoProductConvert.class); - - @Mappings({}) - DemoProductVO convert(DemoProductBO object); - -} diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoUserConvert.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoUserConvert.java deleted file mode 100644 index 177d25707..000000000 --- a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoUserConvert.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.mall.demo.application.convert; - -import cn.iocoder.mall.demo.application.vo.DemoUserVO; -import cn.iocoder.mall.demo.rpc.dto.DemoUserDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface DemoUserConvert { - - DemoUserConvert INSTANCE = Mappers.getMapper(DemoUserConvert.class); - - @Mappings({}) - DemoUserVO convert(DemoUserDTO vo); - -} diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/dto/DemoOrderAddDTO.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/dto/DemoOrderAddDTO.java deleted file mode 100644 index 83d7d7c61..000000000 --- a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/dto/DemoOrderAddDTO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.mall.demo.application.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -@ApiModel("Demo 订单添加 DTO") -@Data -public class DemoOrderAddDTO { - - @ApiModelProperty(value = "商品编号", required = true, example = "1") - private Integer productId; - -} diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/vo/DemoProductVO.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/vo/DemoProductVO.java deleted file mode 100644 index 84021808f..000000000 --- a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/vo/DemoProductVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.mall.demo.application.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -@ApiModel("Demo 商品 BO") -@Data -public class DemoProductVO { - - @ApiModelProperty(value = "编号", required = true, example = "1") - private Integer id; - - @ApiModelProperty(value = "华为 Mate30 Pro", required = true, example = "小王") - private String name; - - @ApiModelProperty(value = "价格,单位:分", required = true, example = "10") - private Integer price; - @ApiModelProperty(value = "库存数量", required = true, example = "100") - private Integer quantity; - -} diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/vo/DemoUserVO.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/vo/DemoUserVO.java deleted file mode 100644 index 214f46c25..000000000 --- a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/vo/DemoUserVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.mall.demo.application.vo; - -import lombok.Data; -import lombok.experimental.Accessors; - -@Data -@Accessors(chain = true) -public class DemoUserVO { - - /** - * 用户编号 - */ - private Integer id; - /** - * 昵称 - */ - private String name; - /** - * 性别 - */ - private Integer gender; - -} diff --git a/demo/demo-application/src/main/resources/application-dev.yaml b/demo/demo-application/src/main/resources/application-dev.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/demo/demo-application/src/main/resources/application-local.yaml b/demo/demo-application/src/main/resources/application-local.yaml deleted file mode 100644 index 60380b557..000000000 --- a/demo/demo-application/src/main/resources/application-local.yaml +++ /dev/null @@ -1,15 +0,0 @@ -dubbo: - application: - name: demo-service - registry: - address: zookeeper://127.0.0.1:2181 - protocol: - port: -1 - name: dubbo - scan: - base-packages: cn.iocoder.mall.demo.rpc.service - consumer: - DemoProductRpcService: - version: 1.0.0 - DemoUserRpcService: - version: 1.0.0 diff --git a/demo/demo-application/src/main/resources/application-pre.yaml b/demo/demo-application/src/main/resources/application-pre.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/demo/demo-application/src/main/resources/application-prod.yaml b/demo/demo-application/src/main/resources/application-prod.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/demo/demo-application/src/main/resources/application-uat.yaml b/demo/demo-application/src/main/resources/application-uat.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/demo/demo-application/src/main/resources/application.yaml b/demo/demo-application/src/main/resources/application.yaml deleted file mode 100644 index 982596533..000000000 --- a/demo/demo-application/src/main/resources/application.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# spring -spring: - application: - name: demo-application - profiles: - active: local - -# server -server: - port: 8080 - servlet: - context-path: /demo-api/ diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoOrderService.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoOrderService.java deleted file mode 100644 index 77fdcce8c..000000000 --- a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoOrderService.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.mall.demo.business.api; - -import cn.iocoder.mall.demo.business.bo.order.DemoOrderAddBO; -import cn.iocoder.mall.demo.business.bo.order.DemoOrderCancelBO; - -public interface DemoOrderService { - - int add(DemoOrderAddBO addBO); - - int cancel(DemoOrderCancelBO cancelBO); - -} diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoProductService.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoProductService.java deleted file mode 100644 index 66e8f8d51..000000000 --- a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoProductService.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.mall.demo.business.api; - -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.demo.business.bo.product.*; - -public interface DemoProductService { - - DemoProductBO get(Integer id); - - PageResult page(DemoProductPageBO page); - - int add(DemoProductAddBO product); - - int update(DemoProductUpdateBO product); - -// void updateQuantityIncrease(); - - void updateQuantityReduce(DemoProductQuantityReduceBO reduceBO); - -} diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoUserService.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoUserService.java deleted file mode 100644 index 57b0f7c23..000000000 --- a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoUserService.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.iocoder.mall.demo.business.api; - -import cn.iocoder.mall.demo.business.bo.user.DemoUserBO; - -public interface DemoUserService { - - DemoUserBO get(Integer id); - -} diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/order/DemoOrderAddBO.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/order/DemoOrderAddBO.java deleted file mode 100644 index bf3fbf014..000000000 --- a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/order/DemoOrderAddBO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.mall.demo.business.bo.order; - -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotNull; - -/** - * Demo 订单添加 BO - */ -@Data -@Accessors(chain = true) -public class DemoOrderAddBO { - - @NotNull(message = "用户编号不能为空") - private Integer userId; - - @NotNull(message = "用户编号不能为空") - private Integer productId; - -} diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/order/DemoOrderCancelBO.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/order/DemoOrderCancelBO.java deleted file mode 100644 index c65e218a0..000000000 --- a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/order/DemoOrderCancelBO.java +++ /dev/null @@ -1,4 +0,0 @@ -package cn.iocoder.mall.demo.business.bo.order; - -public class DemoOrderCancelBO { -} diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductAddBO.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductAddBO.java deleted file mode 100644 index 354aae56d..000000000 --- a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductAddBO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.mall.demo.business.bo.product; - -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * Demo 商品添加 BO - */ -@Data -@Accessors(chain = true) -public class DemoProductAddBO { - - /** - * 名字 - */ - private String name; - - /** - * 价格 - */ - private Integer price; - /** - * 库存数量 - */ - private Integer quantity; - -} diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductBO.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductBO.java deleted file mode 100644 index 4e7bde065..000000000 --- a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductBO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.mall.demo.business.bo.product; - -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * Demo 商品 BO - */ -@Data -@Accessors(chain = true) -public class DemoProductBO { - - /** - * 编号 - */ - private Integer id; - - /** - * 名字 - */ - private String name; - - /** - * 价格 - */ - private Integer price; - /** - * 库存数量 - */ - private Integer quantity; - -} diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductPageBO.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductPageBO.java deleted file mode 100644 index 2c1bb17f2..000000000 --- a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductPageBO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.mall.demo.business.bo.product; - -import cn.iocoder.common.framework.vo.PageParam; - - -public class DemoProductPageBO extends PageParam { - - /** - * 名字,模糊搜索 - */ - private String name; - -} diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductQuantityReduceBO.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductQuantityReduceBO.java deleted file mode 100644 index 2fe96cfdd..000000000 --- a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductQuantityReduceBO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.mall.demo.business.bo.product; - -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -/** - * Demo 商品库存减少 BO - */ -@Data -@Accessors(chain = true) -public class DemoProductQuantityReduceBO { - - /** - * 商品编号 - */ - @NotNull(message = "商品编号不能为空") - private Integer id; - - /** - * 减少数量 - */ - @NotNull(message = "减少数量不能为空") - @Min(value = 1, message = "减少数量最小为 1") - private Integer quantity; - -} diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductUpdateBO.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductUpdateBO.java deleted file mode 100644 index 11d19366f..000000000 --- a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/product/DemoProductUpdateBO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.mall.demo.business.bo.product; - -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * Demo 商品更新 BO - */ -@Data -@Accessors(chain = true) -public class DemoProductUpdateBO { - - /** - * 编号 - */ - private Integer id; - - /** - * 名字 - */ - private String name; - - /** - * 价格 - */ - private Integer price; - /** - * 库存数量 - */ - private Integer quantity; - -} diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/user/DemoUserBO.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/user/DemoUserBO.java deleted file mode 100644 index b9a8db841..000000000 --- a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/user/DemoUserBO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.mall.demo.business.bo.user; - -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * Demo 用户 BO - */ -@Data -@Accessors(chain = true) -public class DemoUserBO { - - /** - * 用户编号 - */ - private Integer id; - /** - * 昵称 - */ - private String name; - /** - * 性别 - */ - private Integer gender; - -} diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/constant/OrderStatusEnum.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/constant/OrderStatusEnum.java deleted file mode 100644 index 28dee412c..000000000 --- a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/constant/OrderStatusEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.mall.demo.business.constant; - -/** - * 订单 - status - * - * @author Sin - * @time 2019-03-16 14:06 - */ -public enum OrderStatusEnum { - - WAITING_PAYMENT(1, "等待付款"), - WAIT_SHIPMENT(2, "等待发货"), - ALREADY_SHIPMENT(3, "已发货"), - COMPLETED(4, "已完成"), - CLOSED(5, "已关闭"); - - /** - * 状态值 - */ - private Integer value; - /** - * 状态名 - */ - private String name; - - OrderStatusEnum(int value, String name) { - this.value = value; - this.name = name; - } - - public int getValue() { - return value; - } - - public String getName() { - return name; - } -} diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/package-info.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/package-info.java deleted file mode 100644 index 4bf2d20bb..000000000 --- a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.mall.demo.business; diff --git a/demo/demo-business/pom.xml b/demo/demo-business/pom.xml deleted file mode 100644 index 4a4b1bc5d..000000000 --- a/demo/demo-business/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - demo - cn.iocoder.mall - 1.0-SNAPSHOT - - 4.0.0 - - demo-business - - - - - cn.iocoder.mall - demo-business-api - 1.0-SNAPSHOT - - - - - mysql - mysql-connector-java - - - - org.springframework - spring-tx - - - org.springframework - spring-jdbc - - - com.alibaba - druid-spring-boot-starter - - - - com.baomidou - mybatis-plus-boot-starter - - - - redis.clients - jedis - - - org.springframework.data - spring-data-redis - - - - - com.google.guava - guava - - - - - org.springframework.boot - spring-boot-starter-test - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - - diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/cacheobject/package-info.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/cacheobject/package-info.java deleted file mode 100644 index b3e4bc271..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/cacheobject/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.mall.demo.business.cacheobject; diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/cacheobject/user/DemoUserCacheObject.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/cacheobject/user/DemoUserCacheObject.java deleted file mode 100644 index 07248c575..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/cacheobject/user/DemoUserCacheObject.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.mall.demo.business.cacheobject.user; - -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 用户缓存对象 - */ -@Data -@Accessors(chain = true) -public class DemoUserCacheObject { - - /** - * 用户编号 - */ - private Integer id; - /** - * 昵称 - */ - private String name; - /** - * 性别 - */ - private Integer gender; - -} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/config/DatabaseConfiguration.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/config/DatabaseConfiguration.java deleted file mode 100644 index 9ffec2430..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/config/DatabaseConfiguration.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.mall.demo.business.config; - -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -@Configuration -@MapperScan("cn.iocoder.mall.demo.business.dao") // 扫描对应的 Mapper 接口 -@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理。为什么使用 proxyTargetClass 参数,参见 https://blog.csdn.net/huang_550/article/details/76492600 -public class DatabaseConfiguration { - - // 数据源,使用 Druid - -} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoOrderConvert.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoOrderConvert.java deleted file mode 100644 index 5cf696168..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoOrderConvert.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.mall.demo.business.convert; - -import cn.iocoder.mall.demo.business.bo.order.DemoOrderAddBO; -import cn.iocoder.mall.demo.business.dataobject.order.DemoOrderDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface DemoOrderConvert { - - DemoOrderConvert INSTANCE = Mappers.getMapper(DemoOrderConvert.class); - - @Mappings({}) - DemoOrderDO convert(DemoOrderAddBO object); - -} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoProductConvert.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoProductConvert.java deleted file mode 100644 index 3aebeef84..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoProductConvert.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.mall.demo.business.convert; - -import cn.iocoder.mall.demo.business.bo.product.DemoProductBO; -import cn.iocoder.mall.demo.business.dataobject.product.DemoProductDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface DemoProductConvert { - - DemoProductConvert INSTANCE = Mappers.getMapper(DemoProductConvert.class); - - @Mappings({}) - DemoProductBO convert(DemoProductDO object); - -} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoUserConvert.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoUserConvert.java deleted file mode 100644 index 2e043b1ea..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoUserConvert.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.mall.demo.business.convert; - -import cn.iocoder.mall.demo.business.bo.user.DemoUserBO; -import cn.iocoder.mall.demo.business.cacheobject.user.DemoUserCacheObject; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface DemoUserConvert { - - DemoUserConvert INSTANCE = Mappers.getMapper(DemoUserConvert.class); - - @Mappings({}) - DemoUserBO convert(DemoUserCacheObject object); - -} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/mysql/DemoOrderMapper.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/mysql/DemoOrderMapper.java deleted file mode 100644 index 0552f35bb..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/mysql/DemoOrderMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.mall.demo.business.dao.mysql; - -import cn.iocoder.mall.demo.business.dataobject.order.DemoOrderDO; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.springframework.stereotype.Repository; - -@Repository -public interface DemoOrderMapper extends BaseMapper { - -} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/mysql/DemoProductMapper.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/mysql/DemoProductMapper.java deleted file mode 100644 index 59e167a66..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/mysql/DemoProductMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.mall.demo.business.dao.mysql; - -import cn.iocoder.mall.demo.business.dataobject.product.DemoProductDO; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Param; -import org.springframework.stereotype.Repository; - -@Repository -public interface DemoProductMapper extends BaseMapper { - - int updateQuantityReduce(@Param("id") Integer id, - @Param("quantity") Integer quantity); - -} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/redis/DemoUserCacheDao.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/redis/DemoUserCacheDao.java deleted file mode 100644 index c3cb4b083..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/redis/DemoUserCacheDao.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.mall.demo.business.dao.redis; - -import cn.iocoder.mall.demo.business.cacheobject.user.DemoUserCacheObject; -import com.alibaba.fastjson.JSON; -import org.springframework.data.redis.core.ValueOperations; -import org.springframework.stereotype.Repository; - -import javax.annotation.Resource; - -@Repository -public class DemoUserCacheDao { - - private static final String KEY_PREFIX = "user_"; - - @Resource(name = "redisTemplate") - @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") - private ValueOperations operations; - - private static String buildKey(Integer id) { - return KEY_PREFIX + id; - } - - public DemoUserCacheObject get(Integer id) { - return JSON.parseObject(operations.get(buildKey(id)), DemoUserCacheObject.class); - } - - public void set(Integer id, DemoUserCacheObject value) { - operations.set(buildKey(id), JSON.toJSONString(value)); - } - -} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dataobject/order/DemoOrderDO.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dataobject/order/DemoOrderDO.java deleted file mode 100644 index 59f4c55f7..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dataobject/order/DemoOrderDO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.mall.demo.business.dataobject.order; - -import cn.iocoder.common.framework.dataobject.DeletableDO; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * Demo 订单 - */ -@Data -@Accessors(chain = true) -@TableName(value = "orders") -public class DemoOrderDO extends DeletableDO { - - /** - * id - */ - private Integer id; - - /** - * 用户编号 - */ - private Integer userId; - - /** - * 商品编号 - */ - private Integer productId; - - /** - * 状态 - * - * - 1、待付款 - * - 2、待发货 - * - 3、待收获 - * - 4、已完成 - * - 5、已关闭 - */ - private Integer status; - -} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dataobject/product/DemoProductDO.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dataobject/product/DemoProductDO.java deleted file mode 100644 index 9d46b7597..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dataobject/product/DemoProductDO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.mall.demo.business.dataobject.product; - -import cn.iocoder.common.framework.dataobject.DeletableDO; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * Demo 商品 - */ -@Data -@Accessors(chain = true) -@TableName(value = "product") -public class DemoProductDO extends DeletableDO { - - /** - * 编号 - */ - private Integer id; - - /** - * 名字 - */ - private String name; - - /** - * 价格 - */ - private Integer price; - /** - * 库存数量 - */ - private Integer quantity; - -} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/package-info.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/package-info.java deleted file mode 100644 index 4bf2d20bb..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.mall.demo.business; diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoOrderServiceImpl.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoOrderServiceImpl.java deleted file mode 100644 index 10282d5c5..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoOrderServiceImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.mall.demo.business.service; - -import cn.iocoder.common.framework.enums.DeletedStatusEnum; -import cn.iocoder.common.framework.util.ServiceExceptionUtil; -import cn.iocoder.mall.demo.business.api.DemoOrderService; -import cn.iocoder.mall.demo.business.api.DemoProductService; -import cn.iocoder.mall.demo.business.bo.order.DemoOrderAddBO; -import cn.iocoder.mall.demo.business.bo.order.DemoOrderCancelBO; -import cn.iocoder.mall.demo.business.bo.product.DemoProductBO; -import cn.iocoder.mall.demo.business.bo.product.DemoProductQuantityReduceBO; -import cn.iocoder.mall.demo.business.constant.OrderStatusEnum; -import cn.iocoder.mall.demo.business.convert.DemoOrderConvert; -import cn.iocoder.mall.demo.business.dao.mysql.DemoOrderMapper; -import cn.iocoder.mall.demo.business.dataobject.order.DemoOrderDO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class DemoOrderServiceImpl implements DemoOrderService { - - @Autowired - private DemoProductService demoProductService; - - @Autowired - private DemoOrderMapper demoOrderMapper; - - @Override - public int add(DemoOrderAddBO addBO) { - // 产品信息 - DemoProductBO productBO = demoProductService.get(addBO.getProductId()); - if (productBO == null) { // 商品不存在 - throw ServiceExceptionUtil.exception(100000); // TODO 芋艿,错误码 - } - int quantity = 1; - if (productBO.getQuantity() < quantity) { // 库存不够 - throw ServiceExceptionUtil.exception(100001); // TODO 芋艿,错误码 - } - - // 扣除库存 - demoProductService.updateQuantityReduce(new DemoProductQuantityReduceBO() - .setId(addBO.getProductId()).setQuantity(quantity)); - - // 创建订单 - DemoOrderDO orderDO = DemoOrderConvert.INSTANCE.convert(addBO); - orderDO.setStatus(OrderStatusEnum.WAITING_PAYMENT.getValue()) - .setDeleted(DeletedStatusEnum.DELETED_NO.getValue()); - demoOrderMapper.insert(orderDO); - - // 返回订单编号 - return orderDO.getId(); - } - - @Override - public int cancel(DemoOrderCancelBO cancelBO) { - return 0; - } - -} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoProductServiceImpl.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoProductServiceImpl.java deleted file mode 100644 index cfdddbce3..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoProductServiceImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.mall.demo.business.service; - -import cn.iocoder.common.framework.util.ServiceExceptionUtil; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.demo.business.api.DemoProductService; -import cn.iocoder.mall.demo.business.bo.product.*; -import cn.iocoder.mall.demo.business.convert.DemoProductConvert; -import cn.iocoder.mall.demo.business.dao.mysql.DemoProductMapper; -import cn.iocoder.mall.demo.business.dataobject.product.DemoProductDO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class DemoProductServiceImpl implements DemoProductService { - - @Autowired - private DemoProductMapper demoProductMapper; - - @Override - public DemoProductBO get(Integer id) { - DemoProductDO product = demoProductMapper.selectById(id); - return DemoProductConvert.INSTANCE.convert(product); - } - - @Override - public PageResult page(DemoProductPageBO page) { - return null; - } - - @Override - public int add(DemoProductAddBO product) { - return 0; - } - - @Override - public int update(DemoProductUpdateBO product) { - return 0; - } - - @Override - public void updateQuantityReduce(DemoProductQuantityReduceBO reduceBO) { - int updateCount = demoProductMapper.updateQuantityReduce(reduceBO.getId(), reduceBO.getQuantity()); - if (updateCount == 0) { - throw ServiceExceptionUtil.exception(20000); // TODO 芋艿,错误码 - } - } - -} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoUserServiceImpl.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoUserServiceImpl.java deleted file mode 100644 index 78680578e..000000000 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoUserServiceImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.mall.demo.business.service; - -import cn.iocoder.mall.demo.business.api.DemoUserService; -import cn.iocoder.mall.demo.business.bo.user.DemoUserBO; -import cn.iocoder.mall.demo.business.cacheobject.user.DemoUserCacheObject; -import cn.iocoder.mall.demo.business.convert.DemoUserConvert; -import cn.iocoder.mall.demo.business.dao.redis.DemoUserCacheDao; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class DemoUserServiceImpl implements DemoUserService { - - @Autowired - private DemoUserCacheDao userCacheDao; - - @Override - public DemoUserBO get(Integer id) { - DemoUserCacheObject userCacheObject = userCacheDao.get(id); - if (userCacheObject == null) { // TODO 芋艿,临时 - userCacheDao.set(id, new DemoUserCacheObject().setId(id) - .setName("芋艿").setGender(1)); - } - return DemoUserConvert.INSTANCE.convert(userCacheObject); - } - -} diff --git a/demo/demo-business/src/main/resources/business-local.yaml b/demo/demo-business/src/main/resources/business-local.yaml deleted file mode 100644 index 2ee552db3..000000000 --- a/demo/demo-business/src/main/resources/business-local.yaml +++ /dev/null @@ -1,22 +0,0 @@ -spring: - # datasource - datasource: - url: jdbc:mysql://47.112.193.81:3306/testb5f4?useSSL=false&useUnicode=true&characterEncoding=UTF-8 - driver-class-name: com.mysql.jdbc.Driver - username: testb5f4 - password: F4df4db0ed86@11 - # redis - redis: - -# mybatis-plus -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: auto - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - mapperLocations: classpath*:mapper/*.xml - typeAliasesPackage: cn.iocoder.mall.demo.business.dataobject - diff --git a/demo/demo-business/src/main/resources/mapper/DemoProductMapper.xml b/demo/demo-business/src/main/resources/mapper/DemoProductMapper.xml deleted file mode 100644 index 61ef03cd3..000000000 --- a/demo/demo-business/src/main/resources/mapper/DemoProductMapper.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - UPDATE product - SET quantity = quantity - #{quantity} - WHERE id = #{id} - AND quantity >= #{quantity} - - - diff --git a/demo/demo-job/pom.xml b/demo/demo-job/pom.xml deleted file mode 100644 index c1da9064f..000000000 --- a/demo/demo-job/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - demo - cn.iocoder.mall - 1.0-SNAPSHOT - - 4.0.0 - - demo-job - - - diff --git a/demo/demo-job/src/main/java/cn/iocoder/mall/demo/job/handler/DemoJobHandler.java b/demo/demo-job/src/main/java/cn/iocoder/mall/demo/job/handler/DemoJobHandler.java deleted file mode 100644 index 0f3156dea..000000000 --- a/demo/demo-job/src/main/java/cn/iocoder/mall/demo/job/handler/DemoJobHandler.java +++ /dev/null @@ -1,4 +0,0 @@ -package cn.iocoder.mall.demo.job.handler; - -public class DemoJobHandler { -} diff --git a/demo/demo-job/src/main/java/cn/iocoder/mall/demo/job/package-info.java b/demo/demo-job/src/main/java/cn/iocoder/mall/demo/job/package-info.java deleted file mode 100644 index 30d04308f..000000000 --- a/demo/demo-job/src/main/java/cn/iocoder/mall/demo/job/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.mall.demo.job; diff --git a/demo/demo-mq/pom.xml b/demo/demo-mq/pom.xml deleted file mode 100644 index 47a571331..000000000 --- a/demo/demo-mq/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - demo - cn.iocoder.mall - 1.0-SNAPSHOT - - 4.0.0 - - demo-mq - - - diff --git a/demo/demo-mq/src/main/java/cn/iocoder/mall/demo/mq/package-info.java b/demo/demo-mq/src/main/java/cn/iocoder/mall/demo/mq/package-info.java deleted file mode 100644 index 8172d958c..000000000 --- a/demo/demo-mq/src/main/java/cn/iocoder/mall/demo/mq/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.mall.demo.mq; diff --git a/demo/demo-rpc-service-api/pom.xml b/demo/demo-rpc-service-api/pom.xml deleted file mode 100644 index 7e81d8c9e..000000000 --- a/demo/demo-rpc-service-api/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - demo - cn.iocoder.mall - 1.0-SNAPSHOT - - 4.0.0 - jar - - demo-rpc-service-api - - - - - cn.iocoder.mall - common-framework - 1.0-SNAPSHOT - - - - - io.swagger - swagger-annotations - - - - - org.mapstruct - mapstruct - - - org.mapstruct - mapstruct-jdk8 - - - - org.projectlombok - lombok - - - - diff --git a/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/api/DemoProductRpcService.java b/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/api/DemoProductRpcService.java deleted file mode 100644 index cb3e132eb..000000000 --- a/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/api/DemoProductRpcService.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.iocoder.mall.demo.rpc.api; - -import cn.iocoder.mall.demo.rpc.dto.DemoProductDTO; - -public interface DemoProductRpcService { - - DemoProductDTO get(Integer id); - -} diff --git a/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/api/DemoUserRpcService.java b/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/api/DemoUserRpcService.java deleted file mode 100644 index 02bb34c45..000000000 --- a/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/api/DemoUserRpcService.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.iocoder.mall.demo.rpc.api; - -import cn.iocoder.mall.demo.rpc.dto.DemoUserDTO; - -public interface DemoUserRpcService { - - DemoUserDTO get(Integer id); - -} diff --git a/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/dto/DemoProductDTO.java b/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/dto/DemoProductDTO.java deleted file mode 100644 index 5c10af5de..000000000 --- a/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/dto/DemoProductDTO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.mall.demo.rpc.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -@ApiModel("Demo 商品 DTO") -@Data -public class DemoProductDTO { - - @ApiModelProperty(value = "编号", required = true, example = "1") - private Integer id; - - @ApiModelProperty(value = "华为 Mate30 Pro", required = true, example = "小王") - private String name; - - @ApiModelProperty(value = "价格,单位:分", required = true, example = "10") - private Integer price; - @ApiModelProperty(value = "库存数量", required = true, example = "100") - private Integer quantity; - -} diff --git a/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/dto/DemoUserDTO.java b/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/dto/DemoUserDTO.java deleted file mode 100644 index ea8e2fcdb..000000000 --- a/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/dto/DemoUserDTO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.mall.demo.rpc.dto; - -import lombok.Data; -import lombok.experimental.Accessors; - -@Data -@Accessors(chain = true) -public class DemoUserDTO { - - /** - * 用户编号 - */ - private Integer id; - /** - * 昵称 - */ - private String name; - /** - * 性别 - */ - private Integer gender; - -} diff --git a/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/package-info.java b/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/package-info.java deleted file mode 100644 index 6fdbe595a..000000000 --- a/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.mall.demo.rpc; diff --git a/demo/demo-rpc-service/pom.xml b/demo/demo-rpc-service/pom.xml deleted file mode 100644 index db628e433..000000000 --- a/demo/demo-rpc-service/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - demo - cn.iocoder.mall - 1.0-SNAPSHOT - - 4.0.0 - - demo-rpc-service - - - - - cn.iocoder.mall - demo-rpc-service-api - 1.0-SNAPSHOT - - - - cn.iocoder.mall - demo-business-api - 1.0-SNAPSHOT - - - cn.iocoder.mall - demo-business - 1.0-SNAPSHOT - - - - - org.apache.dubbo - dubbo - - - org.apache.dubbo - dubbo-spring-boot-starter - - - - - org.apache.curator - curator-framework - - - org.apache.curator - curator-recipes - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - - diff --git a/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/convert/DemoProductConvert.java b/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/convert/DemoProductConvert.java deleted file mode 100644 index fd5733ef6..000000000 --- a/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/convert/DemoProductConvert.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.mall.demo.rpc.convert; - -import cn.iocoder.mall.demo.business.bo.product.DemoProductBO; -import cn.iocoder.mall.demo.rpc.dto.DemoProductDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface DemoProductConvert { - - DemoProductConvert INSTANCE = Mappers.getMapper(DemoProductConvert.class); - - @Mappings({}) - DemoProductDTO convert(DemoProductBO object); - -} diff --git a/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/convert/DemoUserConvert.java b/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/convert/DemoUserConvert.java deleted file mode 100644 index e36b9571b..000000000 --- a/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/convert/DemoUserConvert.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.mall.demo.rpc.convert; - -import cn.iocoder.mall.demo.business.bo.user.DemoUserBO; -import cn.iocoder.mall.demo.rpc.dto.DemoUserDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface DemoUserConvert { - - DemoUserConvert INSTANCE = Mappers.getMapper(DemoUserConvert.class); - - @Mappings({}) - DemoUserDTO convert(DemoUserBO object); - -} diff --git a/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/package-info.java b/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/package-info.java deleted file mode 100644 index 6fdbe595a..000000000 --- a/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.mall.demo.rpc; diff --git a/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/service/DemoProductRpcServiceImpl.java b/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/service/DemoProductRpcServiceImpl.java deleted file mode 100644 index 2425573b1..000000000 --- a/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/service/DemoProductRpcServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.mall.demo.rpc.service; - -import cn.iocoder.mall.demo.business.api.DemoProductService; -import cn.iocoder.mall.demo.business.bo.product.DemoProductBO; -import cn.iocoder.mall.demo.rpc.api.DemoProductRpcService; -import cn.iocoder.mall.demo.rpc.convert.DemoProductConvert; -import cn.iocoder.mall.demo.rpc.dto.DemoProductDTO; -import org.apache.dubbo.config.annotation.Service; -import org.springframework.beans.factory.annotation.Autowired; - -@Service(validation = "true", version = "${dubbo.provider.DemoProductRpcService.version}") -public class DemoProductRpcServiceImpl implements DemoProductRpcService { - - @Autowired - private DemoProductService productService; - - @Override - public DemoProductDTO get(Integer id) { - DemoProductBO product = productService.get(id); - return DemoProductConvert.INSTANCE.convert(product); - } - -} diff --git a/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/service/DemoUserRpcServiceImpl.java b/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/service/DemoUserRpcServiceImpl.java deleted file mode 100644 index 94267e185..000000000 --- a/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/service/DemoUserRpcServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.mall.demo.rpc.service; - -import cn.iocoder.mall.demo.business.api.DemoUserService; -import cn.iocoder.mall.demo.business.bo.user.DemoUserBO; -import cn.iocoder.mall.demo.rpc.api.DemoUserRpcService; -import cn.iocoder.mall.demo.rpc.convert.DemoUserConvert; -import cn.iocoder.mall.demo.rpc.dto.DemoUserDTO; -import org.apache.dubbo.config.annotation.Service; -import org.springframework.beans.factory.annotation.Autowired; - -@Service(validation = "true", version = "${dubbo.provider.DemoUserRpcService.version}") -public class DemoUserRpcServiceImpl implements DemoUserRpcService { - - @Autowired - private DemoUserService demoUserService; - - @Override - public DemoUserDTO get(Integer id) { - DemoUserBO userBO = demoUserService.get(id); - return DemoUserConvert.INSTANCE.convert(userBO); - } - -} diff --git a/demo/demo-rpc-service/src/main/resources/rpc-local.yaml b/demo/demo-rpc-service/src/main/resources/rpc-local.yaml deleted file mode 100644 index 91477b775..000000000 --- a/demo/demo-rpc-service/src/main/resources/rpc-local.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# dubbo -dubbo: - application: - name: demo-service - registry: - address: zookeeper://127.0.0.1:2181 - protocol: - port: -1 - name: dubbo - scan: - base-packages: cn.iocoder.mall.demo.rpc.service -# consumer: -# ProductSpuService: -# version: 1.0.0 - provider: -# filter: -exception - DemoProductRpcService: - version: 1.0.0 - DemoUserRpcService: - version: 1.0.0 diff --git a/demo/pom.xml b/demo/pom.xml deleted file mode 100644 index 094822a0c..000000000 --- a/demo/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - onemall - cn.iocoder.mall - 1.0-SNAPSHOT - - 4.0.0 - - demo - pom - - demo-application - demo-rpc-service-api - demo-rpc-service - demo-business-api - demo-business - demo-job - demo-mq - - - - - - cn.iocoder.mall - mall-dependencies - 1.0-SNAPSHOT - pom - import - - - - - diff --git a/mall-dependencies/pom.xml b/mall-dependencies/pom.xml index a25483e49..288eb7f11 100644 --- a/mall-dependencies/pom.xml +++ b/mall-dependencies/pom.xml @@ -12,39 +12,60 @@ mall-dependencies pom - Onemall Dependencies + ${project.artifactId} Maven Bom,定义 Onemall 项目的所有依赖的版本 - 2.2.4.RELEASE + UTF-8 + UTF-8 + @ + 1.8 + ${java.version} + ${java.version} + 3.8.0 + + 2.2.5.RELEASE Hoxton.SR1 2.2.1.RELEASE + 2.5 2.0.2 + 1.5.21 + 2.9.2 5.1.46 1.1.16 2.0.0 3.5.1 3.1.1 + 3.2.5.RELEASE - 2.7.1 + 2.7.6 + + 2.0.1 1.1.0 + + 7.2.18 + 1.2.7 + 4.1.0 7.0.0 + 2.2.2 1.2.56 6.0.16.Final 5.2.5 - 3.2.5.RELEASE + 27.0.1-jre + 1.16.14 + 1.3.0.Final - + org.springframework.boot spring-boot-starter-parent @@ -129,9 +150,11 @@ - com.github.xiaoymin - knife4j-spring-boot-starter - ${knife4j.version} + javax.servlet + servlet-api + provided + ${servlet.version} + true @@ -140,6 +163,22 @@ 1.0-SNAPSHOT + + io.swagger + swagger-annotations + ${swagger.version} + + + io.springfox + springfox-swagger2 + ${springfox-swagger.version} + + + com.github.xiaoymin + knife4j-spring-boot-starter + ${knife4j.version} + + cn.iocoder.mall mall-security-annotations @@ -168,6 +207,18 @@ dubbo ${dubbo.version} + + org.apache.dubbo + dubbo-spring-boot-starter + ${dubbo.version} + + + + + com.xuxueli + xxl-job-core + ${xxl-job.version} + @@ -183,13 +234,75 @@ ${skywalking.version} + + de.codecentric + spring-boot-admin-starter-client + ${spring-boot-admin-starter-client.version} + + + + + + + + + com.qiniu + qiniu-java-sdk + ${qiniu.version} + + + + com.yunpian.sdk + yunpian-java-sdk + ${yunpian-java-sdk.version} + + + com.aliyun + aliyun-java-sdk-core + ${aliyun-java-sdk-core.version} + + + + org.mapstruct + mapstruct + ${org.mapstruct.version} + + + org.mapstruct + mapstruct-jdk8 + ${org.mapstruct.version} + + + + org.projectlombok + lombok + ${org.projectlombok.version} + + + + com.google.guava + guava + ${guava.version} + + com.alibaba fastjson ${fastjson.version} + + + + + + + + + + + cn.hutool @@ -205,4 +318,42 @@ + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${java.version} + ${java.version} + + + org.mapstruct + mapstruct-processor + ${org.mapstruct.version} + + + org.projectlombok + lombok + ${org.projectlombok.version} + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + + diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/AdminController.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/AdminController.java index fa7f295d7..6b530fee4 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/AdminController.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/admin/AdminController.java @@ -25,7 +25,7 @@ import javax.validation.Valid; import static cn.iocoder.common.framework.vo.CommonResult.success; -@Api("管理员 API") +@Api(tags = "管理员 API") @RestController @RequestMapping("/admin") @Validated diff --git a/management-web-app/src/main/resources/application.yml b/management-web-app/src/main/resources/application.yml index c8c82df96..a45906dae 100644 --- a/management-web-app/src/main/resources/application.yml +++ b/management-web-app/src/main/resources/application.yml @@ -14,7 +14,7 @@ spring: # SpringMVC 配置项 mvc: throw-exception-if-no-handler-found: true # 匹配不到路径时,抛出 NoHandlerFoundException 异常 - static-path-pattern: /statics/** # 静态资源的路径 + static-path-pattern: /doc.html # 静态资源的路径 # Dubbo 配置项 dubbo: diff --git a/pom.xml b/pom.xml index b33dd81b1..657fa5bbb 100644 --- a/pom.xml +++ b/pom.xml @@ -34,217 +34,4 @@ pom - - 2.2.5.RELEASE - 2.2.2 - - 2.7.4.1 - - - 1.3.0.Final - 2.13.0 - - - 1.5.21 - 2.9.2 - 1.9.3 - - 2.0.1 - 27.0.1-jre - - 3.8.0 - 1.16.14 - - 7.2.18 - - 2.5 - - - 1.2.7 - 4.1.0 - - 1.8 - - - - - - - org.springframework.boot - spring-boot-starter - ${springboot.version} - - - - - javax.servlet - servlet-api - provided - ${servlet.version} - true - - - - org.springframework.boot - spring-boot-starter-web - ${springboot.version} - - - - io.swagger - swagger-annotations - ${swagger.version} - - - io.springfox - springfox-swagger2 - ${springfox-swagger.version} - - - io.springfox - springfox-swagger-ui - ${springfox-swagger.version} - - - com.github.xiaoymin - swagger-bootstrap-ui - ${swagger-bootstrap-ui.version} - - - - - org.apache.dubbo - dubbo - ${dubbo.version} - - - org.apache.dubbo - dubbo-spring-boot-starter - ${dubbo.version} - - - - - - - - com.xuxueli - xxl-job-core - ${xxl-job.version} - - - - - com.yunpian.sdk - yunpian-java-sdk - ${yunpian-java-sdk.version} - - - com.aliyun - aliyun-java-sdk-core - ${aliyun-java-sdk-core.version} - - - - - com.qiniu - qiniu-java-sdk - ${qiniu.version} - - - - - - de.codecentric - spring-boot-admin-starter-client - ${spring-boot-admin-starter-client.version} - - - - - - - - - org.mapstruct - mapstruct - ${org.mapstruct.version} - - - org.mapstruct - mapstruct-jdk8 - ${org.mapstruct.version} - - - - org.projectlombok - lombok - ${org.projectlombok.version} - - - - com.google.guava - guava - ${guava.version} - - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - - - - - - - - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${java.version} - ${java.version} - - - org.mapstruct - mapstruct-processor - ${org.mapstruct.version} - - - org.projectlombok - lombok - ${org.projectlombok.version} - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - true - - - - - - diff --git a/system-service-project/system-service-api/pom.xml b/system-service-project/system-service-api/pom.xml index 9d0ae27b5..7b8572d9e 100644 --- a/system-service-project/system-service-api/pom.xml +++ b/system-service-project/system-service-api/pom.xml @@ -22,6 +22,11 @@ javax.validation validation-api + + org.hibernate + hibernate-validator + + org.projectlombok lombok diff --git a/system-service-project/system-service-app/pom.xml b/system-service-project/system-service-app/pom.xml index 2cb932c0c..923ef2670 100644 --- a/system-service-project/system-service-app/pom.xml +++ b/system-service-project/system-service-app/pom.xml @@ -73,18 +73,6 @@ mapstruct-jdk8 - - - - - - - - - - - - diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/bo/AdminPageBO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/bo/AdminPageBO.java index f3face9cb..812efb8ae 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/bo/AdminPageBO.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/bo/AdminPageBO.java @@ -1,12 +1,10 @@ package cn.iocoder.mall.systemservice.service.admin.bo; import cn.iocoder.common.framework.vo.PageParam; -import io.swagger.annotations.ApiModel; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; -@ApiModel("管理员分页查询 BO") @Data @EqualsAndHashCode(callSuper = true) @Accessors(chain = true)