商品系统项目结构整理
This commit is contained in:
parent
eddec34e5d
commit
359d6766f3
@ -14,6 +14,7 @@
|
||||
<modules>
|
||||
<module>product-application</module>
|
||||
<module>product-service-api</module>
|
||||
<module>product-service-impl</module>
|
||||
</modules>
|
||||
|
||||
|
||||
|
@ -9,13 +9,18 @@
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>product-rest</artifactId>
|
||||
<artifactId>product-application</artifactId>
|
||||
|
||||
<properties>
|
||||
<org.mapstruct.version>1.3.0.Final</org.mapstruct.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>common-framework</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>product-service-api</artifactId>
|
||||
@ -23,7 +28,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>common-framework</artifactId>
|
||||
<artifactId>product-service-impl</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
@ -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();
|
||||
}
|
@ -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<ProductCategoryVO> list(@RequestParam("pid") Integer pid) {
|
||||
return ProductCategoryConvert.INSTANCE.convertToVO(
|
||||
productCategoryService.getListByPid(pid)
|
||||
);
|
||||
List<ProductCategoryBO> result = productCategoryService.getListByPid(pid);
|
||||
return ProductCategoryConvert.INSTANCE.convertToVO(result);
|
||||
}
|
||||
|
||||
}
|
@ -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 详情
|
@ -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<ProductCategoryVO> convertToVO(List<ProductCategoryBO> categoryList);
|
||||
|
||||
|
||||
}
|
@ -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;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.product.vo;
|
||||
package cn.iocoder.mall.product.application.vo;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -0,0 +1,4 @@
|
||||
package cn.iocoder.mall.product.application.vo;
|
||||
|
||||
public class ProductSpuVO {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package cn.iocoder.mall.product.vo;
|
||||
|
||||
public class ProductSpuVO {
|
||||
}
|
@ -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
|
||||
port: 18081
|
||||
servlet:
|
||||
context-path: /product-api/
|
@ -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<ProductCategoryBO> getListByPid(Integer pid);
|
||||
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.product.bo;
|
||||
package cn.iocoder.mall.product.api.bo;
|
||||
|
||||
/**
|
||||
* 商品分类 BO
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.product.bo;
|
||||
package cn.iocoder.mall.product.api.bo;
|
||||
|
||||
public class ProductSkuBO {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.product.bo;
|
||||
package cn.iocoder.mall.product.api.bo;
|
||||
|
||||
public class ProductSpuBO {
|
||||
|
@ -1,4 +0,0 @@
|
||||
package cn.iocoder.mall.product.service.api;
|
||||
|
||||
public interface ProductSpuService {
|
||||
}
|
82
product/product-service-impl/pom.xml
Normal file
82
product/product-service-impl/pom.xml
Normal file
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<parent>
|
||||
<artifactId>product</artifactId>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>product-service-impl</artifactId>
|
||||
|
||||
<properties>
|
||||
<org.mapstruct.version>1.3.0.Final</org.mapstruct.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>dubbo</artifactId>
|
||||
<version>2.6.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>product-service-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>${org.mapstruct.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>27.0.1-jre</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- 提供给 mapstruct 使用 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source> <!-- or higher, depending on your project -->
|
||||
<target>1.8</target> <!-- or higher, depending on your project -->
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>${org.mapstruct.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -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<ProductCategoryBO> convertToBO(List<ProductCategoryDO> categoryList);
|
||||
|
||||
@Mappings({})
|
||||
ProductCategoryVO convertToVO(ProductCategoryBO category);
|
||||
|
||||
List<ProductCategoryVO> convertToVO(List<ProductCategoryBO> categoryList);
|
||||
|
||||
}
|
@ -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;
|
@ -0,0 +1 @@
|
||||
package cn.iocoder.mall.product;
|
@ -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<ProductCategoryBO> getListByPid(Integer pid) {
|
||||
List<ProductCategoryDO> categoryList = productCategoryMapper.selectListByPidAndStatusOrderBySort(pid, ProductCategoryDO.STATUS_ENABLE);
|
||||
return ProductCategoryConvert.INSTANCE.convertToBO(categoryList);
|
@ -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
|
@ -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
|
Loading…
Reference in New Issue
Block a user