From 359d6766f36a784016800cf3c88e082769788b06 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sun, 3 Mar 2019 18:04:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E7=B3=BB=E7=BB=9F=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=BB=93=E6=9E=84=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- product/pom.xml | 1 + product/product-application/pom.xml | 9 +- .../mall/product/ProductApplication.java | 2 +- .../config/MVCConfiguration.java | 2 +- .../config/SwaggerConfiguration.java | 4 +- .../users}/ProductCategoryController.java | 18 ++-- .../users}/ProductSpuController.java | 12 +-- .../convert/ProductCategoryConvert.java | 22 +++++ .../vo/ProductCategoryVO.java | 2 +- .../vo/ProductSpuListVO.java | 2 +- .../product/application/vo/ProductSpuVO.java | 4 + .../iocoder/mall/product/vo/ProductSpuVO.java | 4 - .../src/main/resources/application.yaml | 29 +------ .../product/api/ProductCategoryService.java | 11 +++ .../mall/product/api/ProductSpuService.java | 9 ++ .../product/api}/bo/ProductCategoryBO.java | 2 +- .../mall/product/api}/bo/ProductSkuBO.java | 2 +- .../mall/product/api}/bo/ProductSpuBO.java | 2 +- .../service/api/ProductSpuService.java | 4 - product/product-service-impl/pom.xml | 82 +++++++++++++++++++ .../product/config/DatabaseConfiguration.java | 0 .../convert/ProductCategoryConvert.java | 8 +- .../product/convert/ProductSpuConvert.java | 2 +- .../product/dao/ProductCategoryMapper.java | 0 .../mall/product/dao/ProductSpuMapper.java | 0 .../product/dataobject/ProductAttrDO.java | 0 .../dataobject/ProductAttrValueDO.java | 0 .../product/dataobject/ProductCategoryDO.java | 0 .../mall/product/dataobject/ProductSkuDO.java | 0 .../mall/product/dataobject/ProductSpuDO.java | 0 .../product/dataobject/ProductStockDO.java | 0 .../cn/iocoder/mall/product/package-info.java | 1 + .../service/ProductCategoryServiceImpl.java} | 8 +- .../service/ProductSpuServiceImpl.java} | 6 +- .../main/resources/config/application.yaml | 25 ++++++ .../mapper/ProductCategoryMapper.xml | 0 .../resources/mapper/ProductSkuMapper.xml | 0 .../src/main/resources/mybatis-config.xml | 0 38 files changed, 200 insertions(+), 73 deletions(-) rename product/product-application/src/main/java/cn/iocoder/mall/product/{ => application}/config/MVCConfiguration.java (96%) rename product/product-application/src/main/java/cn/iocoder/mall/product/{ => application}/config/SwaggerConfiguration.java (92%) rename product/product-application/src/main/java/cn/iocoder/mall/product/{controller/user => application/controller/users}/ProductCategoryController.java (60%) rename product/product-application/src/main/java/cn/iocoder/mall/product/{controller/user => application/controller/users}/ProductSpuController.java (67%) create mode 100644 product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductCategoryConvert.java rename product/product-application/src/main/java/cn/iocoder/mall/product/{ => application}/vo/ProductCategoryVO.java (95%) rename product/product-application/src/main/java/cn/iocoder/mall/product/{ => application}/vo/ProductSpuListVO.java (81%) create mode 100644 product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductSpuVO.java delete mode 100644 product/product-application/src/main/java/cn/iocoder/mall/product/vo/ProductSpuVO.java create mode 100644 product/product-service-api/src/main/java/cn/iocoder/mall/product/api/ProductCategoryService.java create mode 100644 product/product-service-api/src/main/java/cn/iocoder/mall/product/api/ProductSpuService.java rename product/{product-application/src/main/java/cn/iocoder/mall/product => product-service-api/src/main/java/cn/iocoder/mall/product/api}/bo/ProductCategoryBO.java (96%) rename product/{product-application/src/main/java/cn/iocoder/mall/product => product-service-api/src/main/java/cn/iocoder/mall/product/api}/bo/ProductSkuBO.java (81%) rename product/{product-application/src/main/java/cn/iocoder/mall/product => product-service-api/src/main/java/cn/iocoder/mall/product/api}/bo/ProductSpuBO.java (81%) delete mode 100644 product/product-service-api/src/main/java/cn/iocoder/mall/product/service/api/ProductSpuService.java create mode 100644 product/product-service-impl/pom.xml rename product/{product-application => product-service-impl}/src/main/java/cn/iocoder/mall/product/config/DatabaseConfiguration.java (100%) rename product/{product-application => product-service-impl}/src/main/java/cn/iocoder/mall/product/convert/ProductCategoryConvert.java (66%) rename product/{product-application => product-service-impl}/src/main/java/cn/iocoder/mall/product/convert/ProductSpuConvert.java (88%) rename product/{product-application => product-service-impl}/src/main/java/cn/iocoder/mall/product/dao/ProductCategoryMapper.java (100%) rename product/{product-application => product-service-impl}/src/main/java/cn/iocoder/mall/product/dao/ProductSpuMapper.java (100%) rename product/{product-application => product-service-impl}/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrDO.java (100%) rename product/{product-application => product-service-impl}/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrValueDO.java (100%) rename product/{product-application => product-service-impl}/src/main/java/cn/iocoder/mall/product/dataobject/ProductCategoryDO.java (100%) rename product/{product-application => product-service-impl}/src/main/java/cn/iocoder/mall/product/dataobject/ProductSkuDO.java (100%) rename product/{product-application => product-service-impl}/src/main/java/cn/iocoder/mall/product/dataobject/ProductSpuDO.java (100%) rename product/{product-application => product-service-impl}/src/main/java/cn/iocoder/mall/product/dataobject/ProductStockDO.java (100%) create mode 100644 product/product-service-impl/src/main/java/cn/iocoder/mall/product/package-info.java rename product/{product-application/src/main/java/cn/iocoder/mall/product/service/ProductCategoryService.java => product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductCategoryServiceImpl.java} (74%) rename product/{product-application/src/main/java/cn/iocoder/mall/product/service/ProductSpuService.java => product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductSpuServiceImpl.java} (79%) create mode 100644 product/product-service-impl/src/main/resources/config/application.yaml rename product/{product-application => product-service-impl}/src/main/resources/mapper/ProductCategoryMapper.xml (100%) rename product/{product-application => product-service-impl}/src/main/resources/mapper/ProductSkuMapper.xml (100%) rename product/{product-application => product-service-impl}/src/main/resources/mybatis-config.xml (100%) diff --git a/product/pom.xml b/product/pom.xml index 58be06e12..52389badc 100644 --- a/product/pom.xml +++ b/product/pom.xml @@ -14,6 +14,7 @@ product-application product-service-api + product-service-impl diff --git a/product/product-application/pom.xml b/product/product-application/pom.xml index 07bdef822..685d042d2 100644 --- a/product/product-application/pom.xml +++ b/product/product-application/pom.xml @@ -9,13 +9,18 @@ 4.0.0 - product-rest + product-application 1.3.0.Final + + cn.iocoder.mall + common-framework + 1.0-SNAPSHOT + cn.iocoder.mall product-service-api @@ -23,7 +28,7 @@ cn.iocoder.mall - common-framework + product-service-impl 1.0-SNAPSHOT diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/ProductApplication.java b/product/product-application/src/main/java/cn/iocoder/mall/product/ProductApplication.java index fba29b9a4..8332826a2 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/ProductApplication.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/ProductApplication.java @@ -3,7 +3,7 @@ package cn.iocoder.mall.product; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication +@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.product"}) public class ProductApplication { public static void main(String[] args) { diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/config/MVCConfiguration.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/config/MVCConfiguration.java similarity index 96% rename from product/product-application/src/main/java/cn/iocoder/mall/product/config/MVCConfiguration.java rename to product/product-application/src/main/java/cn/iocoder/mall/product/application/config/MVCConfiguration.java index b27d40f4c..20dc73906 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/config/MVCConfiguration.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/config/MVCConfiguration.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.product.config; +package cn.iocoder.mall.product.application.config; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.EnableWebMvc; diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/config/SwaggerConfiguration.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/config/SwaggerConfiguration.java similarity index 92% rename from product/product-application/src/main/java/cn/iocoder/mall/product/config/SwaggerConfiguration.java rename to product/product-application/src/main/java/cn/iocoder/mall/product/application/config/SwaggerConfiguration.java index 1a518f1ac..e5acbd02e 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/config/SwaggerConfiguration.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/config/SwaggerConfiguration.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.product.config; +package cn.iocoder.mall.product.application.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -19,7 +19,7 @@ public class SwaggerConfiguration { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() - .apis(RequestHandlerSelectors.basePackage("cn.iocoder.mall.product.controller")) + .apis(RequestHandlerSelectors.basePackage("cn.iocoder.mall.product.application.controller")) .paths(PathSelectors.any()) .build(); } diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/controller/user/ProductCategoryController.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/ProductCategoryController.java similarity index 60% rename from product/product-application/src/main/java/cn/iocoder/mall/product/controller/user/ProductCategoryController.java rename to product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/ProductCategoryController.java index d35ac88da..f439f7433 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/controller/user/ProductCategoryController.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/ProductCategoryController.java @@ -1,12 +1,13 @@ -package cn.iocoder.mall.product.controller.user; +package cn.iocoder.mall.product.application.controller.users; -import cn.iocoder.mall.product.convert.ProductCategoryConvert; -import cn.iocoder.mall.product.service.ProductCategoryService; -import cn.iocoder.mall.product.vo.ProductCategoryVO; +import cn.iocoder.mall.product.api.ProductCategoryService; +import cn.iocoder.mall.product.api.bo.ProductCategoryBO; +import cn.iocoder.mall.product.application.convert.ProductCategoryConvert; +import cn.iocoder.mall.product.application.vo.ProductCategoryVO; +import com.alibaba.dubbo.config.annotation.Reference; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; -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; @@ -19,16 +20,15 @@ import java.util.List; @Api("商品分类") public class ProductCategoryController { - @Autowired + @Reference(validation = "true") private ProductCategoryService productCategoryService; @GetMapping @ApiOperation("获得指定编号下的子分类的数组") @ApiImplicitParam(name = "pid", value = "指定分类编号", required = true, example = "0") public List list(@RequestParam("pid") Integer pid) { - return ProductCategoryConvert.INSTANCE.convertToVO( - productCategoryService.getListByPid(pid) - ); + List result = productCategoryService.getListByPid(pid); + return ProductCategoryConvert.INSTANCE.convertToVO(result); } } \ No newline at end of file diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/controller/user/ProductSpuController.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/ProductSpuController.java similarity index 67% rename from product/product-application/src/main/java/cn/iocoder/mall/product/controller/user/ProductSpuController.java rename to product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/ProductSpuController.java index 6c9fd73c7..ac88a885a 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/controller/user/ProductSpuController.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/ProductSpuController.java @@ -1,9 +1,9 @@ -package cn.iocoder.mall.product.controller.user; +package cn.iocoder.mall.product.application.controller.users; -import cn.iocoder.mall.product.bo.ProductSpuBO; -import cn.iocoder.mall.product.service.ProductSpuService; -import cn.iocoder.mall.product.vo.ProductSpuListVO; -import org.springframework.beans.factory.annotation.Autowired; +import cn.iocoder.mall.product.api.ProductSpuService; +import cn.iocoder.mall.product.api.bo.ProductSpuBO; +import cn.iocoder.mall.product.application.vo.ProductSpuListVO; +import com.alibaba.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; @@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("user/product/spu") public class ProductSpuController { - @Autowired + @Reference(validation = "true") private ProductSpuService productSpuService; // TODO 详情 diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductCategoryConvert.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductCategoryConvert.java new file mode 100644 index 000000000..72a73663d --- /dev/null +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductCategoryConvert.java @@ -0,0 +1,22 @@ +package cn.iocoder.mall.product.application.convert; + +import cn.iocoder.mall.product.api.bo.ProductCategoryBO; +import cn.iocoder.mall.product.application.vo.ProductCategoryVO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface ProductCategoryConvert { + + ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class); + + @Mappings({}) + ProductCategoryVO convertToVO(ProductCategoryBO category); + + List convertToVO(List categoryList); + + +} diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/vo/ProductCategoryVO.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductCategoryVO.java similarity index 95% rename from product/product-application/src/main/java/cn/iocoder/mall/product/vo/ProductCategoryVO.java rename to product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductCategoryVO.java index 457517a34..910f1bef0 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/vo/ProductCategoryVO.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductCategoryVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.product.vo; +package cn.iocoder.mall.product.application.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/vo/ProductSpuListVO.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductSpuListVO.java similarity index 81% rename from product/product-application/src/main/java/cn/iocoder/mall/product/vo/ProductSpuListVO.java rename to product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductSpuListVO.java index 3b70bbf35..944fd53b3 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/vo/ProductSpuListVO.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductSpuListVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.product.vo; +package cn.iocoder.mall.product.application.vo; import java.util.List; diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductSpuVO.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductSpuVO.java new file mode 100644 index 000000000..8f141d860 --- /dev/null +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductSpuVO.java @@ -0,0 +1,4 @@ +package cn.iocoder.mall.product.application.vo; + +public class ProductSpuVO { +} diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/vo/ProductSpuVO.java b/product/product-application/src/main/java/cn/iocoder/mall/product/vo/ProductSpuVO.java deleted file mode 100644 index 8e2e1b892..000000000 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/vo/ProductSpuVO.java +++ /dev/null @@ -1,4 +0,0 @@ -package cn.iocoder.mall.product.vo; - -public class ProductSpuVO { -} diff --git a/product/product-application/src/main/resources/application.yaml b/product/product-application/src/main/resources/application.yaml index a200bc9fe..d86f295cd 100644 --- a/product/product-application/src/main/resources/application.yaml +++ b/product/product-application/src/main/resources/application.yaml @@ -1,32 +1,9 @@ spring: application: name: product-application - # datasource - datasource: - url: jdbc:mysql://127.0.0.1:33061/mall_product?useSSL=false - driver-class-name: com.mysql.jdbc.Driver - username: root - password: 123456 # server server: - port: 8081 - -# mybatis -mybatis: - config-location: classpath:mybatis-config.xml - mapper-locations: classpath:mapper/*.xml - type-aliases-package: cn.iocoder.mall.product.dataobject - -# dubbo -dubbo: - registry: - address: zookeeper://127.0.0.1:2181 - protocol: - port: -1 - name: dubbo - scan: - base-packages: cn.iocoder.mall.product.service -demo: - service: - version: 1.0.0 \ No newline at end of file + port: 18081 + servlet: + context-path: /product-api/ \ No newline at end of file diff --git a/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/ProductCategoryService.java b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/ProductCategoryService.java new file mode 100644 index 000000000..90f8e4397 --- /dev/null +++ b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/ProductCategoryService.java @@ -0,0 +1,11 @@ +package cn.iocoder.mall.product.api; + +import cn.iocoder.mall.product.api.bo.ProductCategoryBO; + +import java.util.List; + +public interface ProductCategoryService { + + List getListByPid(Integer pid); + +} \ No newline at end of file diff --git a/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/ProductSpuService.java b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/ProductSpuService.java new file mode 100644 index 000000000..b2fc9aa43 --- /dev/null +++ b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/ProductSpuService.java @@ -0,0 +1,9 @@ +package cn.iocoder.mall.product.api; + +import cn.iocoder.mall.product.api.bo.ProductSpuBO; + +public interface ProductSpuService { + + ProductSpuBO getProductSpu(Integer id); + +} diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/bo/ProductCategoryBO.java b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductCategoryBO.java similarity index 96% rename from product/product-application/src/main/java/cn/iocoder/mall/product/bo/ProductCategoryBO.java rename to product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductCategoryBO.java index 29fa1d023..af90b1afe 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/bo/ProductCategoryBO.java +++ b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductCategoryBO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.product.bo; +package cn.iocoder.mall.product.api.bo; /** * 商品分类 BO diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/bo/ProductSkuBO.java b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductSkuBO.java similarity index 81% rename from product/product-application/src/main/java/cn/iocoder/mall/product/bo/ProductSkuBO.java rename to product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductSkuBO.java index 858ab2272..7bc35b788 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/bo/ProductSkuBO.java +++ b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductSkuBO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.product.bo; +package cn.iocoder.mall.product.api.bo; public class ProductSkuBO { diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/bo/ProductSpuBO.java b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductSpuBO.java similarity index 81% rename from product/product-application/src/main/java/cn/iocoder/mall/product/bo/ProductSpuBO.java rename to product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductSpuBO.java index 06b881899..7ae0a87bf 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/bo/ProductSpuBO.java +++ b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductSpuBO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.product.bo; +package cn.iocoder.mall.product.api.bo; public class ProductSpuBO { diff --git a/product/product-service-api/src/main/java/cn/iocoder/mall/product/service/api/ProductSpuService.java b/product/product-service-api/src/main/java/cn/iocoder/mall/product/service/api/ProductSpuService.java deleted file mode 100644 index 5529bfeaa..000000000 --- a/product/product-service-api/src/main/java/cn/iocoder/mall/product/service/api/ProductSpuService.java +++ /dev/null @@ -1,4 +0,0 @@ -package cn.iocoder.mall.product.service.api; - -public interface ProductSpuService { -} diff --git a/product/product-service-impl/pom.xml b/product/product-service-impl/pom.xml new file mode 100644 index 000000000..7195150a9 --- /dev/null +++ b/product/product-service-impl/pom.xml @@ -0,0 +1,82 @@ + + + + product + cn.iocoder.mall + 1.0-SNAPSHOT + + 4.0.0 + + product-service-impl + + + 1.3.0.Final + + + + + com.alibaba + dubbo + 2.6.5 + compile + + + cn.iocoder.mall + product-service-api + 1.0-SNAPSHOT + compile + + + + mysql + mysql-connector-java + + + org.springframework.boot + spring-boot-starter-jdbc + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.0.0 + + + org.mapstruct + mapstruct + ${org.mapstruct.version} + + + + com.google.guava + guava + 27.0.1-jre + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + org.mapstruct + mapstruct-processor + ${org.mapstruct.version} + + + + + + + + \ No newline at end of file diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/config/DatabaseConfiguration.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/config/DatabaseConfiguration.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/config/DatabaseConfiguration.java rename to product/product-service-impl/src/main/java/cn/iocoder/mall/product/config/DatabaseConfiguration.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/convert/ProductCategoryConvert.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/convert/ProductCategoryConvert.java similarity index 66% rename from product/product-application/src/main/java/cn/iocoder/mall/product/convert/ProductCategoryConvert.java rename to product/product-service-impl/src/main/java/cn/iocoder/mall/product/convert/ProductCategoryConvert.java index 0e4abb009..969aa6ab1 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/convert/ProductCategoryConvert.java +++ b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/convert/ProductCategoryConvert.java @@ -1,8 +1,7 @@ package cn.iocoder.mall.product.convert; -import cn.iocoder.mall.product.bo.ProductCategoryBO; +import cn.iocoder.mall.product.api.bo.ProductCategoryBO; import cn.iocoder.mall.product.dataobject.ProductCategoryDO; -import cn.iocoder.mall.product.vo.ProductCategoryVO; import org.mapstruct.Mapper; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; @@ -19,9 +18,4 @@ public interface ProductCategoryConvert { List convertToBO(List categoryList); - @Mappings({}) - ProductCategoryVO convertToVO(ProductCategoryBO category); - - List convertToVO(List categoryList); - } \ No newline at end of file diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/convert/ProductSpuConvert.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/convert/ProductSpuConvert.java similarity index 88% rename from product/product-application/src/main/java/cn/iocoder/mall/product/convert/ProductSpuConvert.java rename to product/product-service-impl/src/main/java/cn/iocoder/mall/product/convert/ProductSpuConvert.java index b0599c2f7..4390597b2 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/convert/ProductSpuConvert.java +++ b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/convert/ProductSpuConvert.java @@ -1,6 +1,6 @@ package cn.iocoder.mall.product.convert; -import cn.iocoder.mall.product.bo.ProductSpuBO; +import cn.iocoder.mall.product.api.bo.ProductSpuBO; import cn.iocoder.mall.product.dataobject.ProductSpuDO; import org.mapstruct.Mapper; import org.mapstruct.Mappings; diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/dao/ProductCategoryMapper.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dao/ProductCategoryMapper.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/dao/ProductCategoryMapper.java rename to product/product-service-impl/src/main/java/cn/iocoder/mall/product/dao/ProductCategoryMapper.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/dao/ProductSpuMapper.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dao/ProductSpuMapper.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/dao/ProductSpuMapper.java rename to product/product-service-impl/src/main/java/cn/iocoder/mall/product/dao/ProductSpuMapper.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrDO.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrDO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrDO.java rename to product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrDO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrValueDO.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrValueDO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrValueDO.java rename to product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrValueDO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/dataobject/ProductCategoryDO.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductCategoryDO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/dataobject/ProductCategoryDO.java rename to product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductCategoryDO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/dataobject/ProductSkuDO.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSkuDO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/dataobject/ProductSkuDO.java rename to product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSkuDO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/dataobject/ProductSpuDO.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSpuDO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/dataobject/ProductSpuDO.java rename to product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSpuDO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/dataobject/ProductStockDO.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductStockDO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/dataobject/ProductStockDO.java rename to product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductStockDO.java diff --git a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/package-info.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/package-info.java new file mode 100644 index 000000000..ce84a3085 --- /dev/null +++ b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.mall.product; \ No newline at end of file diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/service/ProductCategoryService.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductCategoryServiceImpl.java similarity index 74% rename from product/product-application/src/main/java/cn/iocoder/mall/product/service/ProductCategoryService.java rename to product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductCategoryServiceImpl.java index 110c76ad1..8d6367d7a 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/service/ProductCategoryService.java +++ b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductCategoryServiceImpl.java @@ -1,6 +1,7 @@ package cn.iocoder.mall.product.service; -import cn.iocoder.mall.product.bo.ProductCategoryBO; +import cn.iocoder.mall.product.api.ProductCategoryService; +import cn.iocoder.mall.product.api.bo.ProductCategoryBO; import cn.iocoder.mall.product.convert.ProductCategoryConvert; import cn.iocoder.mall.product.dao.ProductCategoryMapper; import cn.iocoder.mall.product.dataobject.ProductCategoryDO; @@ -10,12 +11,13 @@ import org.springframework.stereotype.Service; import java.util.List; @Service // 实际上不用添加。添加的原因是,必须 Spring 报错提示 -//@com.alibaba.dubbo.config.annotation.Service -public class ProductCategoryService { +@com.alibaba.dubbo.config.annotation.Service(validation = "true") +public class ProductCategoryServiceImpl implements ProductCategoryService { @Autowired private ProductCategoryMapper productCategoryMapper; + @Override public List getListByPid(Integer pid) { List categoryList = productCategoryMapper.selectListByPidAndStatusOrderBySort(pid, ProductCategoryDO.STATUS_ENABLE); return ProductCategoryConvert.INSTANCE.convertToBO(categoryList); diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/service/ProductSpuService.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductSpuServiceImpl.java similarity index 79% rename from product/product-application/src/main/java/cn/iocoder/mall/product/service/ProductSpuService.java rename to product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductSpuServiceImpl.java index e08b5e068..3cc508617 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/service/ProductSpuService.java +++ b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductSpuServiceImpl.java @@ -1,6 +1,7 @@ package cn.iocoder.mall.product.service; -import cn.iocoder.mall.product.bo.ProductSpuBO; +import cn.iocoder.mall.product.api.ProductSpuService; +import cn.iocoder.mall.product.api.bo.ProductSpuBO; import cn.iocoder.mall.product.convert.ProductSpuConvert; import cn.iocoder.mall.product.dao.ProductSpuMapper; import cn.iocoder.mall.product.dataobject.ProductSpuDO; @@ -9,11 +10,12 @@ import org.springframework.stereotype.Service; @Service // 实际上不用添加。添加的原因是,必须 Spring 报错提示 @com.alibaba.dubbo.config.annotation.Service -public class ProductSpuService implements cn.iocoder.mall.product.service.api.ProductSpuService { +public class ProductSpuServiceImpl implements ProductSpuService { @Autowired private ProductSpuMapper productSpuDAO; + @Override public ProductSpuBO getProductSpu(Integer id) { ProductSpuDO productSpuDO = productSpuDAO.selectById(id); // 转换成 BO diff --git a/product/product-service-impl/src/main/resources/config/application.yaml b/product/product-service-impl/src/main/resources/config/application.yaml new file mode 100644 index 000000000..80f856a19 --- /dev/null +++ b/product/product-service-impl/src/main/resources/config/application.yaml @@ -0,0 +1,25 @@ +spring: + # datasource + datasource: + url: jdbc:mysql://127.0.0.1:33061/mall_product?useSSL=false + driver-class-name: com.mysql.jdbc.Driver + username: root + password: 123456 + +# mybatis +mybatis: + config-location: classpath:mybatis-config.xml + mapper-locations: classpath:mapper/*.xml + type-aliases-package: cn.iocoder.mall.product.dataobject + +# dubbo +dubbo: + application: + name: product-service + registry: + address: zookeeper://127.0.0.1:2181 + protocol: + port: -1 + name: dubbo + scan: + base-packages: cn.iocoder.mall.product.service \ No newline at end of file diff --git a/product/product-application/src/main/resources/mapper/ProductCategoryMapper.xml b/product/product-service-impl/src/main/resources/mapper/ProductCategoryMapper.xml similarity index 100% rename from product/product-application/src/main/resources/mapper/ProductCategoryMapper.xml rename to product/product-service-impl/src/main/resources/mapper/ProductCategoryMapper.xml diff --git a/product/product-application/src/main/resources/mapper/ProductSkuMapper.xml b/product/product-service-impl/src/main/resources/mapper/ProductSkuMapper.xml similarity index 100% rename from product/product-application/src/main/resources/mapper/ProductSkuMapper.xml rename to product/product-service-impl/src/main/resources/mapper/ProductSkuMapper.xml diff --git a/product/product-application/src/main/resources/mybatis-config.xml b/product/product-service-impl/src/main/resources/mybatis-config.xml similarity index 100% rename from product/product-application/src/main/resources/mybatis-config.xml rename to product/product-service-impl/src/main/resources/mybatis-config.xml