diff --git a/demo/demo-application/pom.xml b/demo/demo-application/pom.xml new file mode 100644 index 000000000..c3b9596fe --- /dev/null +++ b/demo/demo-application/pom.xml @@ -0,0 +1,119 @@ + + + + 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 + + + + + org.springframework.boot + spring-boot-starter-web + + + + io.springfox + springfox-swagger2 + + + com.github.xiaoymin + swagger-bootstrap-ui + + + + + com.qiniu + qiniu-java-sdk + + + + + de.codecentric + spring-boot-admin-starter-client + + + org.springframework.cloud + spring-cloud-starter-alibaba-sentinel + + + + 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 new file mode 100644 index 000000000..b8d86eb43 --- /dev/null +++ b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/DemoApplication.java @@ -0,0 +1,15 @@ +package cn.iocoder.mall.demo.application; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableAsync; + +@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.demo"}) +@EnableAsync(proxyTargetClass = true) +public class DemoApplication { + + public static void main(String[] args) { + SpringApplication.run(DemoApplication.class, args); + } + +} 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 new file mode 100644 index 000000000..a952b2517 --- /dev/null +++ b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoProductController.java @@ -0,0 +1,27 @@ +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.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/convert/DemoProductConvert.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoProductConvert.java new file mode 100644 index 000000000..7e3fefda0 --- /dev/null +++ b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoProductConvert.java @@ -0,0 +1,17 @@ +package cn.iocoder.mall.demo.application.convert; + +import cn.iocoder.mall.demo.application.vo.DemoProductVO; +import cn.iocoder.mall.demo.business.bo.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/vo/DemoProductVO.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/vo/DemoProductVO.java new file mode 100644 index 000000000..8ee8b7cf0 --- /dev/null +++ b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/vo/DemoProductVO.java @@ -0,0 +1,4 @@ +package cn.iocoder.mall.demo.application.vo; + +public class DemoProductVO { +} diff --git a/demo/demo-application/src/main/resources/application.yaml b/demo/demo-application/src/main/resources/application.yaml new file mode 100644 index 000000000..73ee32099 --- /dev/null +++ b/demo/demo-application/src/main/resources/application.yaml @@ -0,0 +1,5 @@ +# server +server: + port: 8080 + servlet: + context-path: /demo-api/ diff --git a/demo/demo-business-api/pom.xml b/demo/demo-business-api/pom.xml new file mode 100644 index 000000000..9e3d3616a --- /dev/null +++ b/demo/demo-business-api/pom.xml @@ -0,0 +1,45 @@ + + + + demo + cn.iocoder.mall + 1.0-SNAPSHOT + + 4.0.0 + jar + + demo-business-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-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 new file mode 100644 index 000000000..5f0466abc --- /dev/null +++ b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoOrderService.java @@ -0,0 +1,7 @@ +package cn.iocoder.mall.demo.business.api; + +public interface DemoOrderService { + + + +} 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 new file mode 100644 index 000000000..3bdb3e6cf --- /dev/null +++ b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoProductService.java @@ -0,0 +1,9 @@ +package cn.iocoder.mall.demo.business.api; + +import cn.iocoder.mall.demo.business.bo.DemoProductBO; + +public interface DemoProductService { + + DemoProductBO get(Integer id); + +} diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/DemoProductBO.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/DemoProductBO.java new file mode 100644 index 000000000..2750bc90d --- /dev/null +++ b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/DemoProductBO.java @@ -0,0 +1,4 @@ +package cn.iocoder.mall.demo.business.bo; + +public class DemoProductBO { +} 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 new file mode 100644 index 000000000..4bf2d20bb --- /dev/null +++ b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.mall.demo.business; diff --git a/demo/demo-business/pom.xml b/demo/demo-business/pom.xml new file mode 100644 index 000000000..bb1fb8d83 --- /dev/null +++ b/demo/demo-business/pom.xml @@ -0,0 +1,69 @@ + + + + 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 + + + + + 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/config/DatabaseConfiguration.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/config/DatabaseConfiguration.java new file mode 100644 index 000000000..9ffec2430 --- /dev/null +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/config/DatabaseConfiguration.java @@ -0,0 +1,14 @@ +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/DemoProductConvert.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoProductConvert.java new file mode 100644 index 000000000..d6aa736af --- /dev/null +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoProductConvert.java @@ -0,0 +1,17 @@ +package cn.iocoder.mall.demo.business.convert; + +import cn.iocoder.mall.demo.business.bo.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/dao/DemoProductMapper.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/DemoProductMapper.java new file mode 100644 index 000000000..43ef4ba90 --- /dev/null +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/DemoProductMapper.java @@ -0,0 +1,10 @@ +package cn.iocoder.mall.demo.business.dao; + +import cn.iocoder.mall.demo.business.dataobject.product.DemoProductDO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +@Repository +public interface DemoProductMapper extends BaseMapper { + +} 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 new file mode 100644 index 000000000..a5a13df4a --- /dev/null +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dataobject/order/DemoOrderDO.java @@ -0,0 +1,37 @@ +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 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 new file mode 100644 index 000000000..a0c6d5104 --- /dev/null +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dataobject/product/DemoProductDO.java @@ -0,0 +1,33 @@ +package cn.iocoder.mall.demo.business.dataobject.product; + +import cn.iocoder.common.framework.dataobject.DeletableDO; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * Demo 商品 + */ +@Data +@Accessors(chain = true) +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 new file mode 100644 index 000000000..4bf2d20bb --- /dev/null +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/package-info.java @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..bb5ecc3ac --- /dev/null +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoOrderServiceImpl.java @@ -0,0 +1,6 @@ +package cn.iocoder.mall.demo.business.service; + +import cn.iocoder.mall.demo.business.api.DemoOrderService; + +public class DemoOrderServiceImpl implements DemoOrderService { +} 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 new file mode 100644 index 000000000..570472acf --- /dev/null +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoProductServiceImpl.java @@ -0,0 +1,23 @@ +package cn.iocoder.mall.demo.business.service; + +import cn.iocoder.mall.demo.business.api.DemoProductService; +import cn.iocoder.mall.demo.business.bo.DemoProductBO; +import cn.iocoder.mall.demo.business.convert.DemoProductConvert; +import cn.iocoder.mall.demo.business.dao.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); + } + +} diff --git a/demo/demo-business/src/main/resources/config/application.yaml b/demo/demo-business/src/main/resources/config/application.yaml new file mode 100644 index 000000000..0daca8bcb --- /dev/null +++ b/demo/demo-business/src/main/resources/config/application.yaml @@ -0,0 +1,19 @@ +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 + +# 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-job/pom.xml b/demo/demo-job/pom.xml new file mode 100644 index 000000000..c1da9064f --- /dev/null +++ b/demo/demo-job/pom.xml @@ -0,0 +1,15 @@ + + + + demo + cn.iocoder.mall + 1.0-SNAPSHOT + + 4.0.0 + + demo-job + + + diff --git a/demo/demo-rpc-service-api/pom.xml b/demo/demo-rpc-service-api/pom.xml new file mode 100644 index 000000000..7e81d8c9e --- /dev/null +++ b/demo/demo-rpc-service-api/pom.xml @@ -0,0 +1,45 @@ + + + + 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/pom.xml b/demo/demo-rpc-service/pom.xml new file mode 100644 index 000000000..669b313f1 --- /dev/null +++ b/demo/demo-rpc-service/pom.xml @@ -0,0 +1,15 @@ + + + + demo + cn.iocoder.mall + 1.0-SNAPSHOT + + 4.0.0 + + demo-rpc-service + + + diff --git a/demo/pom.xml b/demo/pom.xml new file mode 100644 index 000000000..1a9ae0bc3 --- /dev/null +++ b/demo/pom.xml @@ -0,0 +1,24 @@ + + + + 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 + + + + diff --git a/pom.xml b/pom.xml index fe35bf9a6..08713cf55 100644 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,7 @@ pay promotion search + demo pom