diff --git a/product/pom.xml b/product/pom.xml index 7e103f173..f4e48fe32 100644 --- a/product/pom.xml +++ b/product/pom.xml @@ -10,11 +10,15 @@ 4.0.0 product + product pom product-application - product-service-api - product-service-impl + product-rpc-api + product-rpc + product-rest + product-biz + product-biz-api diff --git a/product/product-application/pom.xml b/product/product-application/pom.xml index 8aba527cc..3dec4c1e0 100644 --- a/product/product-application/pom.xml +++ b/product/product-application/pom.xml @@ -15,90 +15,15 @@ cn.iocoder.mall - common-framework + product-rest 1.0-SNAPSHOT cn.iocoder.mall - mall-spring-boot + product-rpc 1.0-SNAPSHOT - - cn.iocoder.mall - product-service-api - 1.0-SNAPSHOT - - - cn.iocoder.mall - product-service-impl - 1.0-SNAPSHOT - - - cn.iocoder.mall - user-sdk - 1.0-SNAPSHOT - - - cn.iocoder.mall - system-sdk - 1.0-SNAPSHOT - - - - - org.springframework.boot - spring-boot-starter-web - - - - io.springfox - springfox-swagger2 - - - com.github.xiaoymin - swagger-bootstrap-ui - - - - - com.alibaba.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/product/product-application/src/main/java/cn/iocoder/mall/product/application/ProductApplication.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/ProductApplication.java index c3a9758c3..81aed8b6a 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/ProductApplication.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/ProductApplication.java @@ -2,14 +2,25 @@ package cn.iocoder.mall.product.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.product"}) @EnableAsync(proxyTargetClass = true) public class ProductApplication { - public static void main(String[] args) { - SpringApplication.run(ProductApplication.class, args); - } + /** + * 设置需要读取的配置文件的名字。 + * 基于 {@link org.springframework.boot.context.config.ConfigFileApplicationListener#CONFIG_NAME_PROPERTY} 实现。 + */ + private static final String CONFIG_NAME_VALUE = "biz,rest,rpc,application"; + + public static void main(String[] args) { + // 设置环境变量 + System.setProperty(ConfigFileApplicationListener.CONFIG_NAME_PROPERTY, CONFIG_NAME_VALUE); + + // 启动 Spring Boot 应用 + SpringApplication.run(ProductApplication.class, args); + } } diff --git a/product/product-application/src/main/resources/application.yaml b/product/product-application/src/main/resources/application.yaml index a5f4207ce..003331d9f 100644 --- a/product/product-application/src/main/resources/application.yaml +++ b/product/product-application/src/main/resources/application.yaml @@ -1,34 +1,9 @@ spring: + # Application 的配置项 application: name: product-application - - # Spring Cloud 配置项 - cloud: - # Spring Cloud Sentinel 配置项 - sentinel: - transport: - dashboard: s1.iocoder.cn:12088 # Sentinel Dashboard 服务地址 - eager: true # 项目启动时,直接连接到 Sentinel - -# server -server: - port: 18081 - servlet: - context-path: /product-api/ + # Profile 的配置项 + profiles: + active: local - -management: - endpoints: - web: - exposure: - include: health,info,env,metrics,prometheus - metrics: - enabled: true - -swagger: - enable: true - title: 商品子系统 - description: 商品子系统 - version: 1.0.0 - base-package: cn.iocoder.mall.product.application.controller diff --git a/product/product-biz-api/pom.xml b/product/product-biz-api/pom.xml new file mode 100644 index 000000000..7c302c683 --- /dev/null +++ b/product/product-biz-api/pom.xml @@ -0,0 +1,23 @@ + + + + system + cn.iocoder.mall + 1.0-SNAPSHOT + + 4.0.0 + + product-biz-api + + + + + cn.iocoder.mall + common-framework + 1.0-SNAPSHOT + + + + diff --git a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/ProductErrorCodeEnum.java b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/ProductErrorCodeEnum.java new file mode 100644 index 000000000..d4a9697a4 --- /dev/null +++ b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/ProductErrorCodeEnum.java @@ -0,0 +1,54 @@ +package cn.iocoder.mall.product.biz.enums; + +/** + * 错误码枚举类 + * + * 商品系统,使用 1-003-000-000 段 + */ +public enum ProductErrorCodeEnum { + + // ========== PRODUCT CATEGORY 模块 ========== + PRODUCT_CATEGORY_PARENT_NOT_EXISTS(1003001000, "父分类不存在"), + PRODUCT_CATEGORY_NOT_EXISTS(1003001001, "商品分类不存在"), + PRODUCT_CATEGORY_PARENT_NOT_SELF(1003001002, "不能设置自己为父分类"), + PRODUCT_CATEGORY_STATUS_EQUALS(1002001003, "商品分类已经是该状态"), + PRODUCT_CATEGORY_DELETE_ONLY_DISABLE(1002001004, "只有关闭的商品分类才可以删除"), + PRODUCT_CATEGORY_MUST_ENABLE(1002001005, "只有开启的商品分类,才可以使用"), + PRODUCT_CATEGORY_PARENT_CAN_NOT_BE_LEVEL2(1002001005, "父分类必须是一级分类"), + + // ========== PRODUCT SPU + SKU 模块 ========== + PRODUCT_SKU_ATTR_CANT_NOT_DUPLICATE(1003002000, "一个 Sku 下,不能有重复的规格"), + PRODUCT_SPU_ATTR_NUMBERS_MUST_BE_EQUALS(1003002001, "一个 Spu 下的每个 Sku ,其规格数必须一致"), + PRODUCT_SPU_SKU__NOT_DUPLICATE(1003002002, "一个 Spu 下的每个 Sku ,必须不重复"), + PRODUCT_SPU_NOT_EXISTS(1003002003, "Spu 不存在"), + PRODUCT_SPU_CATEGORY_MUST_BE_LEVEL2(1003002003, "Spu 只能添加在二级分类下"), + + // ========== PRODUCT ATTR + ATTR_VALUE 模块 ========== + PRODUCT_ATTR_VALUE_NOT_EXIST(1003003000, "商品属性值不存在"), + PRODUCT_ATTR_NOT_EXIST(1003003001, "商品属性值不存在"), + PRODUCT_ATTR_EXISTS(1003003002, "商品规格已经存在"), + PRODUCT_ATTR_STATUS_EQUALS(1003003003, "商品规格已经是该状态"), + PRODUCT_ATTR_VALUE_EXISTS(1003003004, "商品规格值已经存在"), + PRODUCT_ATTR_VALUE_STATUS_EQUALS(1003003005, "商品规格值已经是该状态"), + + // ========== PRODUCT BRAND模块 ========== + PRODUCT_BRAND_EXIST(1003004000, "品牌值已经存在"), + ; + + private final int code; + private final String message; + + ProductErrorCodeEnum(int code, String message) { + this.code = code; + this.message = message; + } + + public int getCode() { + return code; + } + + public String getMessage() { + return message; + } + +} diff --git a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/product/ProductAttrConstants.java b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/product/ProductAttrConstants.java new file mode 100644 index 000000000..ea3f9a802 --- /dev/null +++ b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/product/ProductAttrConstants.java @@ -0,0 +1,23 @@ +package cn.iocoder.mall.product.biz.enums.product; + +public class ProductAttrConstants { + + /** + * ATTR 状态 - 开启 + */ + public static final Integer ATTR_STATUS_ENABLE = 1; + /** + * ATTR 状态 - 关闭 + */ + public static final Integer ATTR_STATUS_DISABLE = 2; + + /** + * ATTR_VALUE 状态 - 开启 + */ + public static final Integer ATTR_VALUE_STATUS_ENABLE = 1; + /** + * ATTR_VALUE 状态 - 关闭 + */ + public static final Integer ATTR_VALUE_STATUS_DISABLE = 2; + +} diff --git a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/product/ProductCategoryConstants.java b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/product/ProductCategoryConstants.java new file mode 100644 index 000000000..e533545ea --- /dev/null +++ b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/product/ProductCategoryConstants.java @@ -0,0 +1,19 @@ +package cn.iocoder.mall.product.biz.enums.product; + +public class ProductCategoryConstants { + + /** + * 状态 - 开启 + */ + public static final Integer STATUS_ENABLE = 1; + /** + * 状态 - 关闭 + */ + public static final Integer STATUS_DISABLE = 2; + + /** + * 父分类编号 - 根节点 + */ + public static final Integer PID_ROOT = 0; + +} \ No newline at end of file diff --git a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/product/ProductSpuConstants.java b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/product/ProductSpuConstants.java new file mode 100644 index 000000000..6e04c4509 --- /dev/null +++ b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/product/ProductSpuConstants.java @@ -0,0 +1,14 @@ +package cn.iocoder.mall.product.biz.enums.product; + +public class ProductSpuConstants { + + /** + * 状态 - 开启 + */ + public static final Integer SKU_STATUS_ENABLE = 1; + /** + * 状态 - 关闭 + */ + public static final Integer SKU_STATUS_DISABLE = 2; + +} diff --git a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/package-info.java b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/package-info.java new file mode 100644 index 000000000..d68b31026 --- /dev/null +++ b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/package-info.java @@ -0,0 +1,6 @@ +/** + * 该项目,主要用于暴露一些共享的枚举类等。 + * + * 例如说,RPC 接口提供错误码给调用方 + */ +package cn.iocoder.mall.product.biz; diff --git a/product/product-biz/pom.xml b/product/product-biz/pom.xml new file mode 100644 index 000000000..5fceb0b3b --- /dev/null +++ b/product/product-biz/pom.xml @@ -0,0 +1,94 @@ + + + + system + cn.iocoder.mall + 1.0-SNAPSHOT + + 4.0.0 + + product-biz + + + + + cn.iocoder.mall + product-biz-api + 1.0-SNAPSHOT + + + + + org.springframework.boot + spring-boot-starter + + + + + mysql + mysql-connector-java + + + + org.springframework + spring-tx + + + org.springframework + spring-jdbc + + + com.alibaba + druid-spring-boot-starter + + + + cn.iocoder.mall + mall-spring-boot-starter-mybatis + 1.0-SNAPSHOT + + + + + com.yunpian.sdk + yunpian-java-sdk + + + com.aliyun + aliyun-java-sdk-core + + + + + org.mapstruct + mapstruct + + + org.mapstruct + mapstruct-jdk8 + + + org.projectlombok + lombok + + + + com.alibaba + fastjson + + + + com.google.guava + guava + + + + + com.alibaba.cloud + spring-cloud-starter-stream-rocketmq + + + + diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrBO.java new file mode 100644 index 000000000..855638bd7 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrBO.java @@ -0,0 +1,33 @@ +package cn.iocoder.mall.product.biz.bo.attr; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; +import java.util.List; + +@Data +@Accessors(chain = true) +public class ProductAttrBO { + + /** + * 规格编号 + */ + private Integer id; + /** + * 规格名 + */ + private String name; + /** + * 状态 + */ + private Integer status; + /** + * 创建时间 + */ + private Date createTime; + /** + * 规格值数组 + */ + private List values; +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrValueBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrValueBO.java new file mode 100644 index 000000000..1539b5030 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrValueBO.java @@ -0,0 +1,33 @@ +package cn.iocoder.mall.product.biz.bo.attr; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * 商品规格值 VO + */ +@Data +@Accessors(chain = true) +public class ProductAttrValueBO implements Serializable { + + /** + * 规格值编号 + */ + private Integer id; + /** + * 规格值名 + */ + private String name; + /** + * 状态 + */ + private Integer status; + /** + * 创建时间 + */ + private Date createTime; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/package-info.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/package-info.java new file mode 100644 index 000000000..943d9070b --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/package-info.java @@ -0,0 +1,5 @@ +/** + * author: sin + * time: 2020/5/3 8:31 下午 + */ +package cn.iocoder.mall.product.biz.bo; \ No newline at end of file diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrAndValuePairBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrAndValuePairBO.java new file mode 100644 index 000000000..2d0ec610b --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrAndValuePairBO.java @@ -0,0 +1,32 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 商品规格明细 BO + */ +@Data +@Accessors(chain = true) +public class ProductAttrAndValuePairBO implements Serializable { + + /** + * 规格编号 + */ + private Integer attrId; + /** + * 规格名 + */ + private String attrName; + /** + * 规格值 + */ + private Integer attrValueId; + /** + * 规格值名 + */ + private String attrValueName; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrBO2.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrBO2.java new file mode 100644 index 000000000..e1ae3dc67 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrBO2.java @@ -0,0 +1,33 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * 商品规格 VO + */ +@Data +@Accessors(chain = true) +public class ProductAttrBO2 implements Serializable { + + /** + * 规格编号 + */ + private Integer id; + /** + * 规格名 + */ + private String name; + /** + * 状态 + */ + private Integer status; + /** + * 创建时间 + */ + private Date createTime; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrDetailBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrDetailBO.java new file mode 100644 index 000000000..d6c8737b7 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrDetailBO.java @@ -0,0 +1,38 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 商品规格明细 VO + */ +@Data +@Accessors(chain = true) +public class ProductAttrDetailBO implements Serializable { + + /** + * 规格编号 + */ + private Integer id; + /** + * 规格名 + */ + private String name; + /** + * 状态 + */ + private Integer status; + /** + * 创建时间 + */ + private Date createTime; + /** + * 规格值数组 + */ + private List values; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrPageBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrPageBO.java new file mode 100644 index 000000000..12786462f --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrPageBO.java @@ -0,0 +1,25 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 商品规格明细分页 BO + */ +@Data +@Accessors(chain = true) +public class ProductAttrPageBO implements Serializable { + + /** + * 规格数组 + */ + private List attrs; + /** + * 总数 + */ + private Integer count; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrSimpleBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrSimpleBO.java new file mode 100644 index 000000000..0a0ab22e1 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrSimpleBO.java @@ -0,0 +1,29 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 商品规格精简 VO + */ +@Data +@Accessors(chain = true) +public class ProductAttrSimpleBO implements Serializable { + + /** + * 规格编号 + */ + private Integer id; + /** + * 规格名 + */ + private String name; + /** + * 规格值数组 + */ + private List values; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrValueBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrValueBO.java new file mode 100644 index 000000000..3b771074f --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrValueBO.java @@ -0,0 +1,37 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * 商品规格值 VO + */ +@Data +@Accessors(chain = true) +public class ProductAttrValueBO implements Serializable { + + /** + * 规格值编号 + */ + private Integer id; + /** + * 规格编号 + */ + private Integer attrId; + /** + * 规格值名 + */ + private String name; + /** + * 状态 + */ + private Integer status; + /** + * 创建时间 + */ + private Date createTime; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrValueDetailBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrValueDetailBO.java new file mode 100644 index 000000000..a7ac0a4be --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrValueDetailBO.java @@ -0,0 +1,33 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * 商品规格值 VO + */ +@Data +@Accessors(chain = true) +public class ProductAttrValueDetailBO implements Serializable { + + /** + * 规格值编号 + */ + private Integer id; + /** + * 规格值名 + */ + private String name; + /** + * 状态 + */ + private Integer status; + /** + * 创建时间 + */ + private Date createTime; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrValueSimpleBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrValueSimpleBO.java new file mode 100644 index 000000000..246de84a9 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductAttrValueSimpleBO.java @@ -0,0 +1,24 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 商品规格值 VO + */ +@Data +@Accessors(chain = true) +public class ProductAttrValueSimpleBO implements Serializable { + + /** + * 规格值编号 + */ + private Integer id; + /** + * 规格值名 + */ + private String name; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductBrandBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductBrandBO.java new file mode 100644 index 000000000..4bf95a294 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductBrandBO.java @@ -0,0 +1,42 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 商品品牌 VO + */ +@Data +@Accessors(chain = true) +public class ProductBrandBO implements Serializable { + + /** + * 规格编号 + */ + private Integer id; + /** + * 名称 + */ + private String name; + + /** + * 描述 + */ + private String description; + + /** + * 图片地址 + */ + private String picUrl; + + /** + * 状态 + * + * 1-开启 + * 2-禁用 + */ + private Integer status; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductBrangPageBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductBrangPageBO.java new file mode 100644 index 000000000..c80d6b0d4 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductBrangPageBO.java @@ -0,0 +1,25 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 商品品牌分页 BO + */ +@Data +@Accessors(chain = true) +public class ProductBrangPageBO implements Serializable { + + /** + * 品牌数组 + */ + private List brands; + /** + * 总数 + */ + private Integer count; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductCategoryBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductCategoryBO.java new file mode 100644 index 000000000..6d4feb567 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductCategoryBO.java @@ -0,0 +1,54 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * 商品分类 BO + */ +@Data +@Accessors(chain = true) +public class ProductCategoryBO implements Serializable { + + /** + * 分类编号 + */ + private Integer id; + /** + * 父分类编号 + * + * 如果不存在父级,则 pid = 0 。 + */ + private Integer pid; + /** + * 名称 + */ + private String name; + /** + * 描述 + */ + private String description; + /** + * 分类图片 + */ + private String picUrl; + /** + * 排序值 + */ + private Integer sort; + /** + * 状态 + * + * 1-开启 + * 2-关闭 + */ + private Integer status; + /** + * 创建时间 + */ + private Date createTime; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSkuBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSkuBO.java new file mode 100644 index 000000000..f11155be3 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSkuBO.java @@ -0,0 +1,45 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 商品 SKU BO + */ +@Data +@Accessors(chain = true) +public class ProductSkuBO implements Serializable { + + /** + * sku 编号 + */ + private Integer id; + /** + * 商品编号 + */ + private Integer spuId; + /** + * 状态 + */ + private Integer status; + /** + * 图片地址 + */ + private String picURL; +// /** +// * 规格值数组 +// */ +// // TODO 芋艿,这个属性目前未进行设置 +// private List attrs; + /** + * 价格,单位:分 + */ + private Integer price; + /** + * 库存数量 + */ + private Integer quantity; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSkuDetailBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSkuDetailBO.java new file mode 100644 index 000000000..634383941 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSkuDetailBO.java @@ -0,0 +1,91 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 商品 Sku 明细 BO(包括 Spu 明细) + */ +@Data +@Accessors(chain = true) +public class ProductSkuDetailBO implements Serializable { + + /** + * sku 编号 + */ + private Integer id; + /** + * SPU 信息 + */ + private Spu spu; + /** + * 图片地址 + */ + private String picURL; + /** + * 规格值数组 + */ + private List attrs; + /** + * 价格,单位:分 + */ + private Integer price; + /** + * 库存数量 + */ + private Integer quantity; + + @Data + @Accessors(chain = true) + public static class Spu implements Serializable { + + /** + * SPU 编号 + */ + private Integer id; + + // ========== 基本信息 ========= + /** + * SPU 名字 + */ + private String name; + /** + * 卖点 + */ + private String sellPoint; + /** + * 描述 + */ + private String description; + /** + * 分类编号 + */ + private Integer cid; + /** + * 商品主图地址 + * + * 数组,以逗号分隔 + * + * 建议尺寸:800*800像素,你可以拖拽图片调整顺序,最多上传15张 + */ + private List picUrls; + + // ========== 其他信息 ========= + /** + * 是否上架商品(是否可见)。 + * + * true 为已上架 + * false 为已下架 + */ + private Boolean visible; + /** + * 排序字段 + */ + private Integer sort; + + } + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSpuBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSpuBO.java new file mode 100644 index 000000000..6823ac14b --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSpuBO.java @@ -0,0 +1,74 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 商品 SPU BO + */ +@Data +@Accessors(chain = true) +public class ProductSpuBO implements Serializable { + + /** + * SPU 编号 + */ + private Integer id; + + // ========== 基本信息 ========= + /** + * SPU 名字 + */ + private String name; + /** + * 卖点 + */ + private String sellPoint; + /** + * 描述 + */ + private String description; + /** + * 分类编号 + */ + private Integer cid; + /** + * 商品主图地址 + * + * 数组,以逗号分隔 + * + * 建议尺寸:800*800像素,你可以拖拽图片调整顺序,最多上传15张 + */ + private List picUrls; + + // ========== 其他信息 ========= + /** + * 是否上架商品(是否可见)。 + * + * true 为已上架 + * false 为已下架 + */ + private Boolean visible; + /** + * 排序字段 + */ + private Integer sort; + + // ========== Sku 相关字段 ========= + /** + * 价格 + * + * 目前的计算方式是,以 Sku 最小价格为准 + */ + private Integer price; + /** + * 库存数量 + * + * 目前的计算方式是,以 Sku 库存累加为准 + */ + private Integer quantity; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSpuDetailBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSpuDetailBO.java new file mode 100644 index 000000000..f289d8354 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSpuDetailBO.java @@ -0,0 +1,105 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 商品 Spu 明细 BO(包括 Sku 明细) + */ +@Data +@Accessors(chain = true) +public class ProductSpuDetailBO implements Serializable { + + /** + * SPU 编号 + */ + private Integer id; + + // ========== 基本信息 ========= + /** + * SPU 名字 + */ + private String name; + /** + * 卖点 + */ + private String sellPoint; + /** + * 描述 + */ + private String description; + /** + * 分类编号 + */ + private Integer cid; + /** + * 分类名 + */ + private String categoryName; + /** + * 商品主图地址 + * + * 数组,以逗号分隔 + * + * 建议尺寸:800*800像素,你可以拖拽图片调整顺序,最多上传15张 + */ + private List picUrls; + + // ========== 其他信息 ========= + /** + * 是否上架商品(是否可见)。 + * + * true 为已上架 + * false 为已下架 + */ + private Boolean visible; + /** + * 排序字段 + */ + private Integer sort; + + // ========== SKU ========= + + /** + * SKU 数组 + */ + private List skus; + + /** + * 商品 Sku 明细 BO + */ + @Data + @Accessors(chain = true) + public static class Sku implements Serializable { + + /** + * sku 编号 + */ + private Integer id; + /** + * 商品编号 + */ + private Integer spuId; + /** + * 图片地址 + */ + private String picURL; + /** + * 规格值数组 + */ + private List attrs; + /** + * 价格,单位:分 + */ + private Integer price; + /** + * 库存数量 + */ + private Integer quantity; + + } + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSpuPageBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSpuPageBO.java new file mode 100644 index 000000000..a1655cc46 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/ProductSpuPageBO.java @@ -0,0 +1,25 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 商品 SPU 分页 BO + */ +@Data +@Accessors(chain = true) +public class ProductSpuPageBO implements Serializable { + + /** + * Spu 数组 + */ + private List list; + /** + * 总量 + */ + private Integer total; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/UserProductSpuCollectionsBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/UserProductSpuCollectionsBO.java new file mode 100644 index 000000000..7cb10a1b3 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/UserProductSpuCollectionsBO.java @@ -0,0 +1,74 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * 用户_商品_收藏记录表 + * @author xiaofeng + * @date 2019-07-01 20:23:30 + */ +@Data +@Accessors(chain = true) +public class UserProductSpuCollectionsBO implements Serializable { + + /** + * id自增长 + */ + private Integer id; + + /** + * 用户id + */ + private Integer userId; + + /** + * 用户名称 + */ + private String nickname; + + /** + * 商品id + */ + private Integer spuId; + + /** + * 商品名字 + */ + private String spuName; + + /** + * 图片名字 + */ + private String spuImage; + + /** + * 卖点 + */ + private String sellPoint; + + /** + * 价格,单位:分 + */ + private Integer price; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 删除状态 + */ + private Integer deleted; + + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/UserProductSpuCollectionsPageBO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/UserProductSpuCollectionsPageBO.java new file mode 100644 index 000000000..ea5233c91 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/product/UserProductSpuCollectionsPageBO.java @@ -0,0 +1,30 @@ +package cn.iocoder.mall.product.biz.bo.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 商品收藏分页 + * @author xiaofeng + * @date 2019/07/06 18:37 + * @version 1.0 + */ +@Data +@Accessors(chain = true) +public class UserProductSpuCollectionsPageBO implements Serializable { + + /** + * 返回的数据列表 + */ + private List list; + + /** + * 总量 + */ + private Integer total; + + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/config/DatabaseConfiguration.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/config/DatabaseConfiguration.java new file mode 100644 index 000000000..d2e6ca7ad --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/config/DatabaseConfiguration.java @@ -0,0 +1,26 @@ +package cn.iocoder.mall.product.biz.config; + +import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector; +import com.baomidou.mybatisplus.core.injector.ISqlInjector; +import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Configuration +@MapperScan("cn.iocoder.mall.product.biz.dao") // 扫描对应的 Mapper 接口 +@EnableTransactionManagement(proxyTargetClass = true) +// 启动事务管理。为什么使用 proxyTargetClass 参数,参见 https://blog.csdn.net/huang_550/article/details/76492600 +public class DatabaseConfiguration { + @Bean + public ISqlInjector sqlInjector() { + return new DefaultSqlInjector(); // MyBatis Plus 逻辑删除 + } + + @Bean + public PaginationInterceptor paginationInterceptor() { + return new PaginationInterceptor(); // MyBatis Plus 分页插件 + } + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/config/MQStreamConfiguration.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/config/MQStreamConfiguration.java new file mode 100644 index 000000000..a80ffadd5 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/config/MQStreamConfiguration.java @@ -0,0 +1,10 @@ +package cn.iocoder.mall.product.biz.config; + +import cn.iocoder.mall.product.biz.message.MQStreamProducer; +import org.springframework.cloud.stream.annotation.EnableBinding; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableBinding(MQStreamProducer.class) +public class MQStreamConfiguration { +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/attr/ProductAttrConvert.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/attr/ProductAttrConvert.java new file mode 100644 index 000000000..a32265009 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/attr/ProductAttrConvert.java @@ -0,0 +1,26 @@ +package cn.iocoder.mall.product.biz.convert.attr; + +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.product.biz.bo.attr.ProductAttrBO; +import cn.iocoder.mall.product.biz.bo.attr.ProductAttrValueBO; +import cn.iocoder.mall.product.biz.dataobject.product.ProductAttrDO; +import cn.iocoder.mall.product.biz.dataobject.product.ProductAttrValueDO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface ProductAttrConvert { + + ProductAttrConvert INSTANCE = Mappers.getMapper(ProductAttrConvert.class); + + @Mapping(source = "records", target = "list") + PageResult convertPage(IPage bean); + + @Mappings({}) + List convertAttrValue(List values); +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/package-info.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/package-info.java new file mode 100644 index 000000000..7f8ec0164 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/package-info.java @@ -0,0 +1,5 @@ +/** + * author: sin + * time: 2020/5/3 8:31 下午 + */ +package cn.iocoder.mall.product.biz.convert; \ No newline at end of file diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/ProductAttrConvert2.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/ProductAttrConvert2.java new file mode 100644 index 000000000..df87e42ce --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/ProductAttrConvert2.java @@ -0,0 +1,58 @@ +package cn.iocoder.mall.product.biz.convert.product; + +import cn.iocoder.mall.product.biz.bo.product.*; +import cn.iocoder.mall.product.biz.dataobject.product.ProductAttrDO; +import cn.iocoder.mall.product.biz.dataobject.product.ProductAttrValueDO; +import cn.iocoder.mall.product.biz.dto.product.ProductAttrAddDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductAttrUpdateDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductAttrValueAddDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductAttrValueUpdateDTO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface ProductAttrConvert2 { + + ProductAttrConvert2 INSTANCE = Mappers.getMapper(ProductAttrConvert2.class); + + @Mappings({}) + List convert(List attrs); + + @Mappings({}) + ProductAttrValueDetailBO convert(ProductAttrValueDO value); + + @Mappings({}) + List convert2(List values); + + @Mappings({}) + List convert3(List attrs); + + @Mappings({}) + ProductAttrValueSimpleBO convert3(ProductAttrValueDO value); // 保证 convert4 能够映射到这个方法 + + @Mappings({}) + List convert4(List values); + + @Mappings({}) + ProductAttrDO convert(ProductAttrAddDTO productAttrAddDTO); + + @Mappings({}) + ProductAttrDO convert(ProductAttrUpdateDTO productAttrUpdateDTO); + + @Mappings({}) + ProductAttrValueDO convert(ProductAttrValueAddDTO productAttrValueAddDTO); + + @Mappings({}) + ProductAttrValueDO convert(ProductAttrValueUpdateDTO productAttrValueUpdateDTO); + + @Mappings({}) + ProductAttrBO2 convert(ProductAttrDO productAttrDO); + + @Mappings({}) + ProductAttrValueBO convert2(ProductAttrValueDO productAttrValueDO); + + +} \ No newline at end of file diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/ProductBrandConvert.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/ProductBrandConvert.java new file mode 100644 index 000000000..6e18c8412 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/ProductBrandConvert.java @@ -0,0 +1,30 @@ +package cn.iocoder.mall.product.biz.convert.product; + +import cn.iocoder.mall.product.biz.bo.product.ProductBrandBO; +import cn.iocoder.mall.product.biz.dataobject.product.ProductBrandDO; +import cn.iocoder.mall.product.biz.dto.product.ProductBrandAddDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductBrandUpdateDTO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface ProductBrandConvert { + + ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class); + + @Mappings({}) + List convert(List brands); + + @Mappings({}) + ProductBrandBO convert(ProductBrandDO brand); + + @Mappings({}) + ProductBrandDO convert(ProductBrandUpdateDTO brand); + + @Mappings({}) + ProductBrandDO convert(ProductBrandAddDTO brand); + +} \ No newline at end of file diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/ProductCategoryConvert.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/ProductCategoryConvert.java new file mode 100644 index 000000000..45d074f41 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/ProductCategoryConvert.java @@ -0,0 +1,30 @@ +package cn.iocoder.mall.product.biz.convert.product; + +import cn.iocoder.mall.product.biz.bo.product.ProductCategoryBO; +import cn.iocoder.mall.product.biz.dataobject.product.ProductCategoryDO; +import cn.iocoder.mall.product.biz.dto.product.ProductCategoryAddDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductCategoryUpdateDTO; +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({}) + ProductCategoryBO convertToBO(ProductCategoryDO category); + + @Mappings({}) + List convertToBO(List categoryList); + + @Mappings({}) + ProductCategoryDO convert(ProductCategoryAddDTO productCategoryAddDTO); + + @Mappings({}) + ProductCategoryDO convert(ProductCategoryUpdateDTO productCategoryUpdateDTO); + +} \ No newline at end of file diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/ProductSpuConvert.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/ProductSpuConvert.java new file mode 100644 index 000000000..e6b4ec24a --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/ProductSpuConvert.java @@ -0,0 +1,135 @@ +package cn.iocoder.mall.product.biz.convert.product; + +import cn.iocoder.common.framework.util.StringUtil; +import cn.iocoder.mall.product.biz.bo.product.*; +import cn.iocoder.mall.product.biz.dataobject.product.ProductCategoryDO; +import cn.iocoder.mall.product.biz.dataobject.product.ProductSkuDO; +import cn.iocoder.mall.product.biz.dataobject.product.ProductSpuDO; +import cn.iocoder.mall.product.biz.dto.product.ProductSkuAddOrUpdateDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductSpuAddDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductSpuUpdateDTO; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Mappings; +import org.mapstruct.Named; +import org.mapstruct.factory.Mappers; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Mapper +public interface ProductSpuConvert { + + ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class); + + @Mappings({ + @Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "translatePicUrlsFromString") + }) + ProductSpuBO convert(ProductSpuDO spu); + + @Named("translatePicUrlsFromString") + default List translatePicUrlsFromString(String picUrls) { + return StringUtil.split(picUrls, ","); + } + + @Mappings({}) + List convert(List spus); + + @Mappings({ + @Mapping(source = "picUrls", target = "picUrls", ignore = true) + }) + ProductSpuDO convert(ProductSpuAddDTO productSpuAddDTO); + + @Mappings({ + @Mapping(source = "attrs", target = "attrs", ignore = true) + }) + ProductSkuDO convert(ProductSkuAddOrUpdateDTO productSkuAddDTO); + + + @Mappings({ + @Mapping(source = "picUrls", target = "picUrls", ignore = true) + }) + ProductSpuDO convert(ProductSpuUpdateDTO productSpuUpdateDTO); + + @Mappings({}) + ProductSpuDetailBO convert(ProductSpuBO spu); + + @Mappings({ + @Mapping(source = "picUrls", target = "picUrls", ignore = true) + }) + ProductSpuDetailBO convert2(ProductSpuDO spu); + + @Mappings({ + @Mapping(source = "picUrls", target = "picUrls", ignore = true) + }) + ProductSkuDetailBO.Spu convert3(ProductSpuDO spu); + + @Mappings({ + @Mapping(source = "attrs", target = "attrs", ignore = true) + }) + ProductSpuDetailBO.Sku convert2(ProductSkuDO sku); + + @Mappings({ + @Mapping(source = "attrs", target = "attrs", ignore = true) + }) + ProductSkuDetailBO convert3(ProductSkuDO sku); + + @Mappings({ +// @Mapping(source = "attrs", target = "attrs", ignore = true) // TODO 芋艿 后续补充 + }) + ProductSkuBO convert4(ProductSkuDO sku); + + @Mappings({}) // TODO 芋艿,后续细看下 mapstruct 的 API ,优化这块 + default ProductSpuDetailBO convert2(ProductSpuDO spu, List skus, List productAttrDetailBOs, + ProductCategoryDO category) { + // 创建并转换 ProductSpuDetailBO 对象 + ProductSpuDetailBO spuDetail = this.convert2(spu).setPicUrls(StringUtil.split(spu.getPicUrls(), ",")); + // 创建 ProductAttrDetailBO 的映射。其中,KEY 为 ProductAttrDetailBO.attrValueId ,即规格值的编号 + Map productAttrDetailBOMap = productAttrDetailBOs.stream().collect( + Collectors.toMap(ProductAttrAndValuePairBO::getAttrValueId, productAttrDetailBO -> productAttrDetailBO)); + // 创建并转换 ProductSpuDetailBO 数组 + spuDetail.setSkus(new ArrayList<>()); + skus.forEach(sku -> { + // 创建 ProductSpuDetailBO 对象 + ProductSpuDetailBO.Sku skuDetail = ProductSpuConvert.this.convert2(sku) + .setAttrs(new ArrayList<>()); + spuDetail.getSkus().add(skuDetail); + // 设置 ProductSpuDetailBO 的 attrs 规格属性 + List attrs = StringUtil.split(sku.getAttrs(), ","); + attrs.forEach(attr -> skuDetail.getAttrs().add(productAttrDetailBOMap.get(Integer.valueOf(attr)))); + }); + // 设置分类名 + spuDetail.setCategoryName(category.getName()); + // 返回 + return spuDetail; + } + + @Mappings({}) // TODO 芋艿,后续细看下 mapstruct 的 API ,优化这块 + default List convert3(List skus, List spus, List productAttrDetailBOs) { + // 创建 ProductAttrDetailBO 的映射。其中,KEY 为 ProductAttrDetailBO.attrValueId ,即规格值的编号 + Map productAttrDetailBOMap = productAttrDetailBOs.stream().collect( + Collectors.toMap(ProductAttrAndValuePairBO::getAttrValueId, productAttrDetailBO -> productAttrDetailBO)); + // 创建 ProductSpuDO 的映射 + Map spuMap = spus.stream().collect( + Collectors.toMap(ProductSpuDO::getId, spu -> ProductSpuConvert.this.convert3(spu).setPicUrls(StringUtil.split(spu.getPicUrls(), ",")))); + // 拼装结果 + List spuDetailList = new ArrayList<>(skus.size()); + for (ProductSkuDO sku : skus) { + // 创建 ProductSkuDetailBO 对象 + ProductSkuDetailBO skuDetail = ProductSpuConvert.this.convert3(sku) + .setAttrs(new ArrayList<>()) + .setSpu(spuMap.get(sku.getSpuId())); + spuDetailList.add(skuDetail); + // 设置 ProductSpuDetailBO 的 attrs 规格属性 + List attrs = StringUtil.split(sku.getAttrs(), ","); + attrs.forEach(attr -> skuDetail.getAttrs().add(productAttrDetailBOMap.get(Integer.valueOf(attr)))); + } + // 返回 + return spuDetailList; + } + + + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/UserProductSpuCollectionsConvert.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/UserProductSpuCollectionsConvert.java new file mode 100644 index 000000000..9007cd0ab --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/convert/product/UserProductSpuCollectionsConvert.java @@ -0,0 +1,65 @@ +package cn.iocoder.mall.product.biz.convert.product; + +import cn.iocoder.mall.product.biz.bo.product.UserProductSpuCollectionsBO; +import cn.iocoder.mall.product.biz.dataobject.product.UserProductSpuCollectionsDO; +import cn.iocoder.mall.product.biz.dto.product.UserProductSpuCollectionsAddDTO; +import cn.iocoder.mall.product.biz.dto.product.UserProductSpuCollectionsUpdateDTO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 用户_商品_收藏记录表 + * + * @author xiaofeng + * @date 2019-07-01 20:23:30 + */ +@Mapper +public interface UserProductSpuCollectionsConvert { + + UserProductSpuCollectionsConvert INSTANCE = Mappers.getMapper(UserProductSpuCollectionsConvert.class); + + /** + * DTO convert DO + * @param userSkuCollectionsAddDTO + * @return + */ + @Mappings({}) + UserProductSpuCollectionsDO convert(UserProductSpuCollectionsAddDTO userSkuCollectionsAddDTO); + + /** + * update DTO convert DO + * @param userProductSpuCollectionsUpdateDTO + * @return + */ + @Mappings({}) + UserProductSpuCollectionsDO convert(UserProductSpuCollectionsUpdateDTO userProductSpuCollectionsUpdateDTO); + + /** + * DO Convert BO + * @param userSkuCollectionsDO + * @return + */ + @Mappings({}) + UserProductSpuCollectionsBO convert(UserProductSpuCollectionsDO userSkuCollectionsDO); + + /** + * DO List convert BO LIST + * @param userSkuCollectionsDOS + * @return + */ + @Mappings({}) + List convert(List userSkuCollectionsDOS); + +// /** +// * 消处数据转换 +// * @param productSpuCollectionMessage +// * @return +// */ +// @Mappings({}) +// UserProductSpuCollectionsAddDTO convert(ProductSpuCollectionMessage productSpuCollectionMessage); + + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/package-info.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/package-info.java new file mode 100644 index 000000000..d6ee2fb59 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/package-info.java @@ -0,0 +1,5 @@ +/** + * author: sin + * time: 2020/5/3 8:28 下午 + */ +package cn.iocoder.mall.product.biz.dao; \ No newline at end of file diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductAttrMapper.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductAttrMapper.java new file mode 100644 index 000000000..4421c0185 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductAttrMapper.java @@ -0,0 +1,10 @@ +package cn.iocoder.mall.product.biz.dao.product; + +import cn.iocoder.mall.product.biz.dataobject.product.ProductAttrDO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +@Repository +public interface ProductAttrMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductAttrValueMapper.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductAttrValueMapper.java new file mode 100644 index 000000000..a8b42a22c --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductAttrValueMapper.java @@ -0,0 +1,11 @@ +package cn.iocoder.mall.product.biz.dao.product; + +import cn.iocoder.mall.product.biz.dataobject.product.ProductAttrValueDO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +@Repository +public interface ProductAttrValueMapper extends BaseMapper { + + +} \ No newline at end of file diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductBrandMapper.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductBrandMapper.java new file mode 100644 index 000000000..5d79a4a1b --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductBrandMapper.java @@ -0,0 +1,11 @@ +package cn.iocoder.mall.product.biz.dao.product; + +import cn.iocoder.mall.product.biz.dataobject.product.ProductBrandDO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +@Repository +public interface ProductBrandMapper extends BaseMapper { + + +} \ No newline at end of file diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductCategoryMapper.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductCategoryMapper.java new file mode 100644 index 000000000..8ede5d1e6 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductCategoryMapper.java @@ -0,0 +1,10 @@ +package cn.iocoder.mall.product.biz.dao.product; + +import cn.iocoder.mall.product.biz.dataobject.product.ProductBrandDO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +@Repository +public interface ProductCategoryMapper extends BaseMapper { + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductSkuMapper.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductSkuMapper.java new file mode 100644 index 000000000..acd271ed4 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductSkuMapper.java @@ -0,0 +1,10 @@ +package cn.iocoder.mall.product.biz.dao.product; + +import cn.iocoder.mall.product.biz.dataobject.product.ProductBrandDO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +@Repository +public interface ProductSkuMapper extends BaseMapper { + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductSpuMapper.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductSpuMapper.java new file mode 100644 index 000000000..21a7fd8f7 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/ProductSpuMapper.java @@ -0,0 +1,11 @@ +package cn.iocoder.mall.product.biz.dao.product; + +import cn.iocoder.mall.product.biz.dataobject.product.ProductBrandDO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +@Repository +public interface ProductSpuMapper extends BaseMapper { + + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/UserProductSpuCollectionsMapper.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/UserProductSpuCollectionsMapper.java new file mode 100644 index 000000000..bfde4fc9f --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dao/product/UserProductSpuCollectionsMapper.java @@ -0,0 +1,54 @@ +package cn.iocoder.mall.product.biz.dao.product; + +import cn.iocoder.mall.product.biz.dataobject.product.UserProductSpuCollectionsDO; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 用户_商品_收藏记录表 + * + * @author xiaofeng + * @date 2019-07-01 20:23:30 + */ +@Repository +public interface UserProductSpuCollectionsMapper extends BaseMapper { + + /** + * 根据用户id 和 spuId 查找用户商品收藏 + * + * @param userId + * @param spuId + * @return + */ + default UserProductSpuCollectionsDO getUserSpuCollectionsByUserIdAndSpuId(final Integer userId, + final Integer spuId) { + QueryWrapper query = new QueryWrapper() + .eq("user_id", userId).eq("spu_id", spuId); + return selectOne(query); + } + + + /** + * 查询用户收藏列表 + * + * @param userId + * @param offset + * @param limit + * @return + */ + List selectListByUser(@Param("userId") Integer userId, @Param("offset") Integer offset, + @Param("limit") Integer limit); + + /** + * 根据用户ID 查找总数 + * + * @param userId + * @return + */ + Integer selectCountByUser(Integer userId); + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/package-info.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/package-info.java new file mode 100644 index 000000000..a182cf975 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/package-info.java @@ -0,0 +1,5 @@ +/** + * author: sin + * time: 2020/5/3 8:27 下午 + */ +package cn.iocoder.mall.product.biz.dataobject; \ No newline at end of file diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductAttrDO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductAttrDO.java new file mode 100644 index 000000000..f4fb446eb --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductAttrDO.java @@ -0,0 +1,30 @@ +package cn.iocoder.mall.product.biz.dataobject.product; + +import cn.iocoder.mall.mybatis.dataobject.DeletableDO; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * Product 规格 + */ +@Data +@Accessors(chain = true) +public class ProductAttrDO extends DeletableDO { + + /** + * 规格编号 + */ + private Integer id; + /** + * 名称 + */ + private String name; + /** + * 状态 + * + * 1-开启 + * 2-禁用 + */ + private Integer status; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductAttrValueDO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductAttrValueDO.java new file mode 100644 index 000000000..b4cef1862 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductAttrValueDO.java @@ -0,0 +1,34 @@ +package cn.iocoder.mall.product.biz.dataobject.product; + +import cn.iocoder.mall.mybatis.dataobject.DeletableDO; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * Product 规格值 + */ +@Data +@Accessors(chain = true) +public class ProductAttrValueDO extends DeletableDO { + + /** + * 规格值编号 + */ + private Integer id; + /** + * 规格编号 + */ + private Integer attrId; + /** + * 规格值 + */ + private String name; + /** + * 状态 + * + * 1-正常 + * 2-禁用 + */ + private Integer status; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductBrandDO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductBrandDO.java new file mode 100644 index 000000000..18b3c62aa --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductBrandDO.java @@ -0,0 +1,41 @@ +package cn.iocoder.mall.product.biz.dataobject.product; + +import cn.iocoder.mall.mybatis.dataobject.DeletableDO; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * Product 品牌 + */ +@Data +@Accessors(chain = true) +public class ProductBrandDO extends DeletableDO { + + /** + * 规格编号 + */ + private Integer id; + /** + * 名称 + */ + private String name; + + /** + * 描述 + */ + private String description; + + /** + * 图片地址 + */ + private String picUrl; + + /** + * 状态 + * + * 1-开启 + * 2-禁用 + */ + private Integer status; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductCategoryDO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductCategoryDO.java new file mode 100644 index 000000000..94cab4e03 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductCategoryDO.java @@ -0,0 +1,48 @@ +package cn.iocoder.mall.product.biz.dataobject.product; + +import cn.iocoder.mall.mybatis.dataobject.DeletableDO; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 商品分类 + */ +@Data +@Accessors(chain = true) +public class ProductCategoryDO extends DeletableDO { + + /** + * 分类编号 + */ + private Integer id; + /** + * 父分类编号 + * + * 如果不存在父级,则 pid = 0 。 + */ + private Integer pid; + /** + * 名称 + */ + private String name; + /** + * 描述 + */ + private String description; + /** + * 分类图片 + */ + private String picUrl; + /** + * 排序值 + */ + private Integer sort; + /** + * 状态 + * + * 1-开启 + * 2-关闭 + */ + private Integer status; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductSkuDO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductSkuDO.java new file mode 100644 index 000000000..41a3b2fbd --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductSkuDO.java @@ -0,0 +1,61 @@ +package cn.iocoder.mall.product.biz.dataobject.product; + +import cn.iocoder.mall.mybatis.dataobject.DeletableDO; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 商品 SKU + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +public class ProductSkuDO extends DeletableDO { + + /** + * sku 编号 + */ + private Integer id; + /** + * 商品编号 + */ + private Integer spuId; + + // TODO 店铺编号 + + /** + * 状态 + * + * 1-正常 + * 2-禁用 + */ + private Integer status; + /** + * 图片地址 + */ + private String picUrl; + /** + * 规格值({@link ProductAttrDO})数组 + * + * 数组,以逗号分隔 + */ + private String attrs; + /** + * 价格,单位:分 + */ + private Integer price; + /** + * 库存数量 + */ + private Integer quantity; +// /** +// * 商品在付款减库存的状态下,该Sku上未付款的订单数量 +// */ +// private Integer withHoldQuantity; +// /** +// * 销量 +// */ +// private Integer soldNum; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductSpuDO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductSpuDO.java new file mode 100644 index 000000000..fb0d1363d --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductSpuDO.java @@ -0,0 +1,78 @@ +package cn.iocoder.mall.product.biz.dataobject.product; + +import cn.iocoder.mall.mybatis.dataobject.DeletableDO; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 商品 SPU + * + * TODO 芋艿,后面增加商品普通参数。例如说,正面材料,背面材料,屏幕尺寸。 + */ +@Data +@Accessors(chain = true) +public class ProductSpuDO extends DeletableDO { + + /** + * SPU 编号 + */ + private Integer id; + + // TODO 店铺编号 先不考虑,因为第一个版本,不做 B2B2C + + // ========== 基本信息 ========= + /** + * SPU 名字 + */ + private String name; + /** + * 卖点 + */ + private String sellPoint; + /** + * 描述 + */ + private String description; + /** + * 分类编号 + */ + private Integer cid; + /** + * 商品主图地址 + * + * 数组,以逗号分隔 + * + * 建议尺寸:800*800像素,你可以拖拽图片调整顺序,最多上传15张 + */ + private String picUrls; + + // TODO 运费信息 + + // ========== 其他信息 ========= + /** + * 是否上架商品(是否可见)。 + * + * true 为已上架 + * false 为已下架 + */ + private Boolean visible; + /** + * 排序字段 + */ + private Integer sort; + + // ========== Sku 相关字段 ========= + /** + * 价格 + * + * 目前的计算方式是,以 Sku 最小价格为准 + */ + private Integer price; + /** + * 库存数量 + * + * 目前的计算方式是,以 Sku 库存累加为准 + */ + private Integer quantity; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductStockDO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductStockDO.java new file mode 100644 index 000000000..b1da3fd51 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/ProductStockDO.java @@ -0,0 +1,44 @@ +package cn.iocoder.mall.product.biz.dataobject.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * Product 库存 + */ +@Deprecated // TODO 芋艿,咱暂时不加库存表和库存服务 +@Data +@Accessors(chain = true) +public class ProductStockDO { + + /** + * 编号,自增 + */ + private Integer id; + /** + * SKU 编号 + */ + private Integer skuId; + /** + * 库存数 + */ + private Integer quantity; + /** + * 创建时间 + */ + private Date createTime; + /** + * 最后更新时间 + */ + private Date updateTime; + /** + * 状态 + * + * 1-正常 + * 2-删除 + */ + private Integer status; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/UserProductSpuCollectionsDO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/UserProductSpuCollectionsDO.java new file mode 100644 index 000000000..eb1c3fd2d --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/product/UserProductSpuCollectionsDO.java @@ -0,0 +1,78 @@ +package cn.iocoder.mall.product.biz.dataobject.product; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * 用户_商品_收藏记录表 + * + * @author xiaofeng + * @date 2019-07-01 20:23:30 + */ +@TableName("user_spu_collections") +@Data +@Accessors(chain = true) +public class UserProductSpuCollectionsDO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id自增长 + */ + private Integer id; + + /** + * 用户id + */ + private Integer userId; + + /** + * 用户名称 + */ + private String nickname; + + /** + * 商品id + */ + private Integer spuId; + + /** + * 商品名字 + */ + private String spuName; + + /** + * 图片名字 + */ + private String spuImage; + + /** + * 卖点 + */ + private String sellPoint; + + /** + * 价格,单位:分 + */ + private Integer price; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 删除状态 + */ + private Integer deleted; + + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/attr/AdminProductAttrPageDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/attr/AdminProductAttrPageDTO.java new file mode 100644 index 000000000..9b0aa0a84 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/attr/AdminProductAttrPageDTO.java @@ -0,0 +1,19 @@ +package cn.iocoder.mall.product.biz.dto.attr; + +import cn.iocoder.common.framework.vo.PageParam; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 商品规格模块 - 商品规格分页 DTO + */ +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class AdminProductAttrPageDTO extends PageParam { + /** + * 商品规格名字 + */ + private String name; +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/package-info.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/package-info.java new file mode 100644 index 000000000..0b03eaaf8 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/package-info.java @@ -0,0 +1,5 @@ +/** + * author: sin + * time: 2020/5/3 8:29 下午 + */ +package cn.iocoder.mall.product.biz.dto; \ No newline at end of file diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrAddDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrAddDTO.java new file mode 100644 index 000000000..870153fc4 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrAddDTO.java @@ -0,0 +1,21 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; + +/** + * Product 规格添加 DTO + */ +@Data +@Accessors(chain = true) +public class ProductAttrAddDTO { + + /** + * 名称 + */ + @NotEmpty(message = "规格名不能为空") + private String name; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrPageDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrPageDTO.java new file mode 100644 index 000000000..49d4aaf68 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrPageDTO.java @@ -0,0 +1,22 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + * 商品规格分页 DTO + */ +@Data +@Accessors(chain = true) +public class ProductAttrPageDTO { + + private String name; + + @NotNull(message = "页码不能为空") + private Integer pageNo; + @NotNull(message = "每页条数不能为空") + private Integer pageSize; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrUpdateDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrUpdateDTO.java new file mode 100644 index 000000000..503e699ae --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrUpdateDTO.java @@ -0,0 +1,28 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +/** + * Product 规格修改 DTO + */ +@Data +@Accessors(chain = true) +public class ProductAttrUpdateDTO { + + /** + * 规格编号 + */ + @NotNull(message = "规格编号不能为空") + private Integer id; + /** + * 名称 + */ + @NotEmpty(message = "规格名不能为空") + private String name; + + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrValueAddDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrValueAddDTO.java new file mode 100644 index 000000000..b7f4d8a73 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrValueAddDTO.java @@ -0,0 +1,27 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +/** + * Product 规格值添加 DTO + */ +@Data +@Accessors(chain = true) +public class ProductAttrValueAddDTO { + + /** + * 规格编号 + */ + @NotNull(message = "规格编号不能为空") + private Integer attrId; + /** + * 名称 + */ + @NotEmpty(message = "规格值名不能为空") + private String name; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrValueUpdateDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrValueUpdateDTO.java new file mode 100644 index 000000000..a7ae3491d --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductAttrValueUpdateDTO.java @@ -0,0 +1,29 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +/** + * Product 规格值修改 DTO + * + * 注意,不允许修改所属规格 + */ +@Data +@Accessors(chain = true) +public class ProductAttrValueUpdateDTO { + + /** + * 规格值编号 + */ + @NotNull(message = "规格编号不能为空") + private Integer id; + /** + * 名称 + */ + @NotEmpty(message = "规格名不能为空") + private String name; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductBrandAddDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductBrandAddDTO.java new file mode 100644 index 000000000..bda1d92ae --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductBrandAddDTO.java @@ -0,0 +1,43 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +/** + * Product 品牌添加 DTO + */ +@Data +@Accessors(chain = true) +public class ProductBrandAddDTO { + + /** + * 名称 + */ + @NotEmpty(message = "品牌名不能为空") + private String name; + + /** + * 描述 + */ + @NotEmpty(message = "品牌描述不能为空") + private String description; + + /** + * 图片地址 + */ + @NotEmpty(message = "品牌图片地址不能为空") + private String picUrl; + + /** + * 状态 + * + * 1-开启 + * 2-禁用 + */ + @NotNull(message = "品牌状态不能为空") + private Integer status; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductBrandPageDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductBrandPageDTO.java new file mode 100644 index 000000000..cbd50fe8e --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductBrandPageDTO.java @@ -0,0 +1,36 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + * 商品品牌分页 DTO + */ +@Data +@Accessors(chain = true) +public class ProductBrandPageDTO { + + /** + * 名称 + */ + private String name; + + /** + * 描述 + */ + private String description; + + /** + * 状态 1-开启 2-禁用 + */ + private Integer status; + + @NotNull(message = "页码不能为空") + private Integer pageNo; + + @NotNull(message = "每页条数不能为空") + private Integer pageSize; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductBrandUpdateDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductBrandUpdateDTO.java new file mode 100644 index 000000000..b64d0bd6c --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductBrandUpdateDTO.java @@ -0,0 +1,49 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +/** + * Product 品牌添加 DTO + */ +@Data +@Accessors(chain = true) +public class ProductBrandUpdateDTO { + + /** + * 主键 + */ + @NotNull(message = "品牌主键不能为空") + private Integer id; + + /** + * 名称 + */ + @NotEmpty(message = "品牌名不能为空") + private String name; + + /** + * 描述 + */ + @NotEmpty(message = "品牌描述不能为空") + private String description; + + /** + * 图片地址 + */ + @NotEmpty(message = "品牌图片地址不能为空") + private String picUrl; + + /** + * 状态 + * + * 1-开启 + * 2-禁用 + */ + @NotNull(message = "品牌状态不能为空") + private Integer status; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductCategoryAddDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductCategoryAddDTO.java new file mode 100644 index 000000000..a05dd5653 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductCategoryAddDTO.java @@ -0,0 +1,41 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + * 商品分类添加 DTO + */ +@Data +@Accessors(chain = true) +public class ProductCategoryAddDTO { + + /** + * 父分类编号 + */ + @NotNull(message = "父分类编号不能为空") + private Integer pid; + /** + * 名称 + */ + @NotNull(message = "名称不能为空") + private String name; + /** + * 描述 + */ + @NotNull(message = "描述不能为空") + private String description; + /** + * 分类图片 + */ +// @NotNull(message = "分类图片不能为空") + private String picUrl; + /** + * 排序值 + */ + @NotNull(message = "排序值不能为空") + private Integer sort; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductCategoryUpdateDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductCategoryUpdateDTO.java new file mode 100644 index 000000000..726c6e89f --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductCategoryUpdateDTO.java @@ -0,0 +1,46 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + * 商品分类更新 DTO + */ +@Data +@Accessors(chain = true) +public class ProductCategoryUpdateDTO { + + /** + * 编号 + */ + @NotNull(message = "编号不能为空") + private Integer id; + /** + * 父分类编号 + */ + @NotNull(message = "父分类编号不能为空") + private Integer pid; + /** + * 名称 + */ + @NotNull(message = "名称不能为空") + private String name; + /** + * 描述 + */ + @NotNull(message = "描述不能为空") + private String description; + /** + * 分类图片 + */ +// @NotNull(message = "分类图片不能为空") + private String picUrl; + /** + * 排序值 + */ + @NotNull(message = "排序值不能为空") + private Integer sort; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSkuAddOrUpdateDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSkuAddOrUpdateDTO.java new file mode 100644 index 000000000..b497b3c58 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSkuAddOrUpdateDTO.java @@ -0,0 +1,35 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * 商品 Sku 添加 DTO + */ +@Data +@Accessors(chain = true) +public class ProductSkuAddOrUpdateDTO { + + /** + * 规格值数组 + */ + @NotNull(message = "规格值数组不能为空") + private List attrs; + /** + * 价格,单位:分 + */ + @NotNull(message = "价格不能为空") + @Min(value = 1L, message = "最小价格为 1") + private Integer price; + /** + * 库存数量 + */ + @NotNull(message = "库存数量不能为空") + @Min(value = 1L, message = "最小库存为 1") + private Integer quantity; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSpuAddDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSpuAddDTO.java new file mode 100644 index 000000000..f03aa9c8c --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSpuAddDTO.java @@ -0,0 +1,62 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * 商品 SPU + SKU 添加 DTO + */ +@Data +@Accessors(chain = true) +public class ProductSpuAddDTO { + + // ========== 基本信息 ========= + /** + * SPU 名字 + */ + @NotEmpty(message = "SPU 名字不能为空") + private String name; + /** + * 卖点 + */ + @NotEmpty(message = "卖点不能为空") + private String sellPoint; + /** + * 描述 + */ + @NotEmpty(message = "描述不能为空") + private String description; + /** + * 分类编号 + */ + @NotNull(message = "分类不能为空") + private Integer cid; + /** + * 商品主图地址 + */ + @NotNull(message = "商品主图不能为空") + private List picUrls; + + // ========== 其他信息 ========= + /** + * 是否上架商品(是否可见)。 + * + * true 为已上架 + * false 为已下架 + */ + @NotNull(message = "是否上架不能为空") + private Boolean visible; + + // ========== SKU ========= + + /** + * SKU 数组 + */ + @NotNull(message = "SKU 不能为空") + private List skus; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSpuPageDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSpuPageDTO.java new file mode 100644 index 000000000..9f6dfe5a9 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSpuPageDTO.java @@ -0,0 +1,41 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + * 商品 Spu 分页 DTO + */ +@Data +@Accessors(chain = true) +public class ProductSpuPageDTO { + + /** + * 商品名 + * + * 模糊匹配 + */ + private String name; + /** + * 分类编号 + */ + private Integer cid; + /** + * 是否可见 + */ + private Boolean visible; + /** + * 是否有库存 + * + * 允许为空。空时,不进行筛选 + */ + private Boolean hasQuantity; + + @NotNull(message = "页码不能为空") + private Integer pageNo; + @NotNull(message = "每页条数不能为空") + private Integer pageSize; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSpuSearchListDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSpuSearchListDTO.java new file mode 100644 index 000000000..cc278bb9e --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSpuSearchListDTO.java @@ -0,0 +1,20 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 商品 Spu 搜索列表 DTO + */ +@Data +@Accessors(chain = true) +public class ProductSpuSearchListDTO { + + /** + * 商品名 + * + * 模糊匹配 + */ + private String name; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSpuUpdateDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSpuUpdateDTO.java new file mode 100644 index 000000000..58372f0d7 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/ProductSpuUpdateDTO.java @@ -0,0 +1,68 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * 商品 SPU + SKU 更新 DTO + */ +@Data +@Accessors(chain = true) +public class ProductSpuUpdateDTO { + + /** + * Spu 编号 + */ + @NotNull(message = "SPU 编号不能为空") + private Integer id; + + // ========== 基本信息 ========= + /** + * SPU 名字 + */ + @NotEmpty(message = "SPU 名字不能为空") + private String name; + /** + * 卖点 + */ + @NotEmpty(message = "卖点不能为空") + private String sellPoint; + /** + * 描述 + */ + @NotEmpty(message = "描述不能为空") + private String description; + /** + * 分类编号 + */ + @NotNull(message = "分类不能为空") + private Integer cid; + /** + * 商品主图地址 + */ + @NotNull(message = "商品主图不能为空") + private List picUrls; + + // ========== 其他信息 ========= + /** + * 是否上架商品(是否可见)。 + * + * true 为已上架 + * false 为已下架 + */ + @NotNull(message = "是否上架不能为空") + private Boolean visible; + + // ========== SKU ========= + + /** + * SKU 数组 + */ + @NotNull(message = "SKU 不能为空") + private List skus; + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/UserProductSpuCollectionsAddDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/UserProductSpuCollectionsAddDTO.java new file mode 100644 index 000000000..a043027b9 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/UserProductSpuCollectionsAddDTO.java @@ -0,0 +1,75 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * 添加商品收藏参数 + * @author xiaofeng + * @date 2019/07/01 20:38 + * @version 1.0 + */ +@Data +@Accessors(chain = true) +public class UserProductSpuCollectionsAddDTO implements Serializable { + + /** + * id自增长 + */ + private Integer id; + + /** + * 用户id + */ + private Integer userId; + + /** + * 用户名称 + */ + private String nickname; + + /** + * 商品id + */ + private Integer spuId; + + /** + * 商品名字 + */ + private String spuName; + + /** + * 图片名字 + */ + private String spuImage; + + /** + * 卖点 + */ + private String sellPoint; + + /** + * 价格,单位:分 + */ + private Integer price; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 删除状态 + */ + private Integer deleted; + + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/UserProductSpuCollectionsPageDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/UserProductSpuCollectionsPageDTO.java new file mode 100644 index 000000000..22befd128 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/UserProductSpuCollectionsPageDTO.java @@ -0,0 +1,35 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * 商品收藏分页参数 + * @author xiaofeng + * @date 2019/07/06 18:40 + * @version 1.0 + */ +@Data +@Accessors(chain = true) +public class UserProductSpuCollectionsPageDTO implements Serializable { + + /** + * 用户ID + */ + private Integer userId; + + /** + * 当前页 + */ + @NotNull(message = "页码不能为空") + private Integer pageNo; + + /** + * 每页显示的条数 + */ + @NotNull(message = "每页条数不能为空") + private Integer pageSize; +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/UserProductSpuCollectionsUpdateDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/UserProductSpuCollectionsUpdateDTO.java new file mode 100644 index 000000000..e47596ee7 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/product/UserProductSpuCollectionsUpdateDTO.java @@ -0,0 +1,35 @@ +package cn.iocoder.mall.product.biz.dto.product; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * 更新商品收藏参数 + * @author xiaofeng + * @date 2019/07/01 20:38 + * @version 1.0 + */ +@Data +@Accessors(chain = true) +public class UserProductSpuCollectionsUpdateDTO implements Serializable { + + /** + * id自增长 + */ + private Integer id; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 删除状态 + */ + private Integer deleted; + + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/message/MQStreamProducer.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/message/MQStreamProducer.java new file mode 100644 index 000000000..f6175be9c --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/message/MQStreamProducer.java @@ -0,0 +1,27 @@ +package cn.iocoder.mall.product.biz.message; + +import org.springframework.cloud.stream.annotation.Output; +import org.springframework.messaging.MessageChannel; + +/** + * Spring Cloud Stream Source 接口 + */ +public interface MQStreamProducer { + + /** + * 商品更新 Output + */ + String PRODUCT_UPDATE_OUTPUT = "product-update-output"; + + @Output(PRODUCT_UPDATE_OUTPUT) + MessageChannel productUpdateOutput(); + +// default boolean sendProductUpdateMessage(ProductUpdateMessage message) { +// // 创建 Spring Message 对象 +// Message springMessage = MessageBuilder.withPayload(message) +// .build(); +// // 发送消息 +// return productUpdateOutput().send(springMessage); +// } + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/message/UserProductSpuCollectionsConsumer.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/message/UserProductSpuCollectionsConsumer.java new file mode 100644 index 000000000..e1f915643 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/message/UserProductSpuCollectionsConsumer.java @@ -0,0 +1,109 @@ +package cn.iocoder.mall.product.biz.message; + +import org.springframework.stereotype.Service; + +/** + * 商品收藏 消费者 + * @author xiaofeng + * @date 2019/07/02 19:57 + * @version 1.0 + */ +@Service +//@RocketMQMessageListener(topic = ProductSpuCollectionMessage.TOPIC, consumerGroup = "product-spu-consumer-group-" +// + ProductSpuCollectionMessage.TOPIC) +public class UserProductSpuCollectionsConsumer +// implements RocketMQListener +{ + +// @Autowired +// private UserProductSpuCollectionsService userProductSpuCollectionsService; +// +// @Reference(validation = "true", version = "${dubbo.consumer.UserService.version}") +// private UserService userService; +// +// @Override +// public void onMessage(ProductSpuCollectionMessage productSpuCollectionMessage) { +// UserBO userBO = userService.getUser(productSpuCollectionMessage.getUserId()); +// if (userBO == null) { +// throw ServiceExceptionUtil.exception(UserErrorCodeEnum.USER_NOT_EXISTS.getCode()); +// } +// // 收藏 +// if (productSpuCollectionMessage.getHasCollectionType().equals(1)) { +// this.saveUserProductSpuCollections(productSpuCollectionMessage, userBO.getNickname()); +// } else if (productSpuCollectionMessage.getHasCollectionType().equals(2)) { +// // 取消收藏 +// this.deleteUserProductSpuCollections(productSpuCollectionMessage.getUserId(), +// productSpuCollectionMessage.getSpuId()); +// } +// +// } +// +// /** +// * 保存商品收藏 +// * @param productSpuCollectionMessage +// * @param nickname +// * @return +// */ +// private int saveUserProductSpuCollections(final ProductSpuCollectionMessage productSpuCollectionMessage, +// final String nickname) { +// int result = 0; +// UserProductSpuCollectionsBO userProductSpuCollectionsBO = this.userProductSpuCollectionsService +// .getUserSpuCollectionsByUserIdAndSpuId(productSpuCollectionMessage.getUserId(), +// productSpuCollectionMessage.getSpuId()); +// if (userProductSpuCollectionsBO == null) { +// UserProductSpuCollectionsAddDTO userProductSpuCollectionsAddDTO = UserProductSpuCollectionsConvert.INSTANCE +// .convert(productSpuCollectionMessage); +// userProductSpuCollectionsAddDTO.setNickname(StringUtils.isEmpty(nickname) ? "" : nickname); +// userProductSpuCollectionsAddDTO.setCreateTime(new Date()); +// userProductSpuCollectionsAddDTO.setDeleted(DeletedStatusEnum.DELETED_NO.getValue()); +// result = userProductSpuCollectionsService.addUserSkuCollections(userProductSpuCollectionsAddDTO); +// } else { +// // 存在重新收藏 +// if (userProductSpuCollectionsBO.getDeleted().equals(DeletedStatusEnum.DELETED_YES.getValue())) { +// UserProductSpuCollectionsUpdateDTO userProductSpuCollectionsUpdateDTO = this +// .setUserProductSpuCollectionsUpdateDTO(userProductSpuCollectionsBO.getId(), +// DeletedStatusEnum.DELETED_NO); +// result = this.userProductSpuCollectionsService +// .updateUserProductSpuCollections(userProductSpuCollectionsUpdateDTO); +// } +// } +// return result; +// } +// +// /** +// * 取消收藏 +// * @param userId +// * @param spuId +// * @return +// */ +// private int deleteUserProductSpuCollections(final Integer userId, final Integer spuId) { +// UserProductSpuCollectionsBO userProductSpuCollectionsBO = this.userProductSpuCollectionsService +// .getUserSpuCollectionsByUserIdAndSpuId(userId, spuId); +// int result = 0; +// if (userProductSpuCollectionsBO != null) { +// // 未取消收藏的数据 +// if (userProductSpuCollectionsBO.getDeleted().equals(DeletedStatusEnum.DELETED_NO.getValue())) { +// UserProductSpuCollectionsUpdateDTO userProductSpuCollectionsUpdateDTO = this +// .setUserProductSpuCollectionsUpdateDTO(userProductSpuCollectionsBO.getId(), +// DeletedStatusEnum.DELETED_YES); +// result = this.userProductSpuCollectionsService +// .updateUserProductSpuCollections(userProductSpuCollectionsUpdateDTO); +// } +// } +// return result; +// } +// +// /** +// * 设置更新值 +// * @param id +// * @param deletedStatusEnum +// * @return +// */ +// private UserProductSpuCollectionsUpdateDTO setUserProductSpuCollectionsUpdateDTO(final Integer id, +// final DeletedStatusEnum deletedStatusEnum) { +// return new UserProductSpuCollectionsUpdateDTO().setId(id).setUpdateTime(new Date()) +// .setDeleted(deletedStatusEnum.getValue()); +// } + + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/package-info.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/package-info.java new file mode 100644 index 000000000..4a008b3e1 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/package-info.java @@ -0,0 +1,5 @@ +/** + * author: sin + * time: 2020/5/3 8:31 下午 + */ +package cn.iocoder.mall.product.biz.service; \ No newline at end of file diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/ProductAttrService.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/ProductAttrService.java new file mode 100644 index 000000000..36a34f4b7 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/ProductAttrService.java @@ -0,0 +1,50 @@ +package cn.iocoder.mall.product.biz.service.product; + +import cn.iocoder.common.framework.constant.CommonStatusEnum; +import cn.iocoder.common.framework.validator.InEnum; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.product.biz.bo.attr.ProductAttrBO; +import cn.iocoder.mall.product.biz.bo.product.ProductAttrBO2; +import cn.iocoder.mall.product.biz.bo.product.ProductAttrSimpleBO; +import cn.iocoder.mall.product.biz.bo.product.ProductAttrValueBO; +import cn.iocoder.mall.product.biz.dto.attr.AdminProductAttrPageDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductAttrAddDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductAttrUpdateDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductAttrValueAddDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductAttrValueUpdateDTO; + +import java.util.List; + +public interface ProductAttrService { + /** + * 获取规格分页数据 + * + * @param productAttrPageDTO 查询参数 + * @return 规格分页信息 + */ + PageResult getProductAttrPage(AdminProductAttrPageDTO productAttrPageDTO); + + /** + * 获得规格属性数组 + *

+ * 注意,该方法过滤了禁用的规格 + * + * @return 规格属性数组 + */ + List getProductAttrList(); + + ProductAttrBO2 addProductAttr(Integer adminId, ProductAttrAddDTO productAttrAddDTO); + + Boolean updateProductAttr(Integer adminId, ProductAttrUpdateDTO productAttrUpdateDTO); + + Boolean updateProductAttrStatus(Integer adminId, Integer productAttrId, + @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") Integer status); + + ProductAttrValueBO addProductAttrValue(Integer adminId, ProductAttrValueAddDTO productAttrValueAddDTO); + + Boolean updateProductAttrValue(Integer adminId, ProductAttrValueUpdateDTO productAttrValueUpdateDTO); + + Boolean updateProductAttrValueStatus(Integer adminId, Integer productAttrValueId, + @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") Integer status); + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/impl/ProductAttrServiceImpl.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/impl/ProductAttrServiceImpl.java new file mode 100644 index 000000000..3c40f8098 --- /dev/null +++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/product/impl/ProductAttrServiceImpl.java @@ -0,0 +1,255 @@ +package cn.iocoder.mall.product.biz.service.product.impl; + +import cn.iocoder.common.framework.util.CollectionUtil; +import cn.iocoder.common.framework.util.ServiceExceptionUtil; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.mybatis.enums.DeletedStatusEnum; +import cn.iocoder.mall.product.biz.bo.attr.ProductAttrBO; +import cn.iocoder.mall.product.biz.bo.product.ProductAttrAndValuePairBO; +import cn.iocoder.mall.product.biz.bo.product.ProductAttrBO2; +import cn.iocoder.mall.product.biz.bo.product.ProductAttrSimpleBO; +import cn.iocoder.mall.product.biz.bo.product.ProductAttrValueBO; +import cn.iocoder.mall.product.biz.convert.attr.ProductAttrConvert; +import cn.iocoder.mall.product.biz.convert.product.ProductAttrConvert2; +import cn.iocoder.mall.product.biz.dao.product.ProductAttrMapper; +import cn.iocoder.mall.product.biz.dao.product.ProductAttrValueMapper; +import cn.iocoder.mall.product.biz.dataobject.product.ProductAttrDO; +import cn.iocoder.mall.product.biz.dataobject.product.ProductAttrValueDO; +import cn.iocoder.mall.product.biz.dto.attr.AdminProductAttrPageDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductAttrAddDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductAttrUpdateDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductAttrValueAddDTO; +import cn.iocoder.mall.product.biz.dto.product.ProductAttrValueUpdateDTO; +import cn.iocoder.mall.product.biz.enums.ProductErrorCodeEnum; +import cn.iocoder.mall.product.biz.enums.product.ProductAttrConstants; +import cn.iocoder.mall.product.biz.service.product.ProductAttrService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.google.common.collect.ImmutableListMultimap; +import com.google.common.collect.Multimaps; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 商品规格 Service 实现类 + * + * @see cn.iocoder.mall.product.biz.dataobject.product.ProductAttrDO + * @see cn.iocoder.mall.product.biz.dataobject.product.ProductAttrValueDO + */ +@Service +public class ProductAttrServiceImpl implements ProductAttrService { + + @Autowired + private ProductAttrMapper productAttrMapper; + @Autowired + private ProductAttrValueMapper productAttrValueMapper; + + @Override + public PageResult getProductAttrPage(AdminProductAttrPageDTO productAttrPageDTO) { + //查询分页 + Page page = new Page<>(productAttrPageDTO.getPageNo(), productAttrPageDTO.getPageSize()); + LambdaQueryWrapper queryWrapper = Wrappers.query().lambda() + .like(StringUtils.isNotBlank(productAttrPageDTO.getName()), ProductAttrDO::getName, productAttrPageDTO.getName()) + .eq(ProductAttrDO::getDeleted, false); + IPage attrPage = productAttrMapper.selectPage(page, queryWrapper); + PageResult productAttrPage = ProductAttrConvert.INSTANCE.convertPage(attrPage); + // 将规格值拼接上去 + if (!CollectionUtil.isEmpty(productAttrPage.getList())) { + Set attrIds = productAttrPage.getList().stream().map(ProductAttrBO::getId).collect(Collectors.toSet()); + List attrValues = productAttrValueMapper.selectList(Wrappers.query().lambda() + .in(ProductAttrValueDO::getAttrId, attrIds) + .eq(ProductAttrValueDO::getDeleted, false)); + Map> attrValueMap = attrValues.stream().collect(Collectors.groupingBy(ProductAttrValueDO::getAttrId)); + for (ProductAttrBO productAttrBO : productAttrPage.getList()) { + productAttrBO.setValues(ProductAttrConvert.INSTANCE.convertAttrValue(attrValueMap.get(productAttrBO.getId()))); + } + } + // 返回结果 + return productAttrPage; + } + + public List validProductAttrAndValue(Set productAttrValueIds, boolean validStatus) { + // 首先,校验规格值 + List attrValues = productAttrValueMapper.selectBatchIds(productAttrValueIds); + if (attrValues.size() != productAttrValueIds.size()) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_VALUE_NOT_EXIST.getCode()); + } + if (validStatus) { + // 同时,校验下状态 + for (ProductAttrValueDO attrValue : attrValues) { + if (ProductAttrConstants.ATTR_STATUS_DISABLE.equals(attrValue.getStatus())) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_VALUE_NOT_EXIST.getCode()); + } + } + } + // 然后,校验规格 + Set attrIds = attrValues.stream().map(ProductAttrValueDO::getAttrId).collect(Collectors.toSet()); + List attrs = productAttrMapper.selectBatchIds(attrIds); + if (attrs.size() != attrIds.size()) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_NOT_EXIST.getCode()); + } + if (validStatus) { + // 同时,校验下状态 + for (ProductAttrDO attr : attrs) { + if (ProductAttrConstants.ATTR_VALUE_STATUS_DISABLE.equals(attr.getStatus())) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_NOT_EXIST.getCode()); + } + } + } + // 返回成功 + // ProductAttrDO 的映射,方便查找。 + Map attrMap = attrs.stream().collect(Collectors.toMap(ProductAttrDO::getId, productAttrDO -> productAttrDO)); + return attrValues.stream().map(productAttrValueDO -> new ProductAttrAndValuePairBO() + .setAttrId(productAttrValueDO.getAttrId()).setAttrName(attrMap.get(productAttrValueDO.getAttrId()).getName()) + .setAttrValueId(productAttrValueDO.getId()).setAttrValueName(productAttrValueDO.getName())).collect(Collectors.toList()); + } + + + + @Override + public List getProductAttrList() { + // 查询所有开启的规格数组 + List attrDos = productAttrMapper.selectList(Wrappers.query().lambda() + .in(ProductAttrDO::getStatus, ProductAttrConstants.ATTR_STATUS_ENABLE) + .eq(ProductAttrDO::getDeleted, false)); + List attrs = ProductAttrConvert2.INSTANCE.convert3(attrDos); + // 如果为空,则返回空 + if (attrs.isEmpty()) { + return Collections.emptyList(); + } + // 将规格值拼接上去 + List attrValues = productAttrValueMapper.selectList(Wrappers.query().lambda() + .in(ProductAttrValueDO::getStatus, ProductAttrConstants.ATTR_STATUS_ENABLE) + .eq(ProductAttrValueDO::getDeleted, false)); + // KEY 是 attrId ,VALUE 是 ProductAttrValueDO 数组 + ImmutableListMultimap attrValueMap = Multimaps.index(attrValues, ProductAttrValueDO::getAttrId); + for (ProductAttrSimpleBO productAttrSimpleBO : attrs) { + productAttrSimpleBO.setValues(ProductAttrConvert2.INSTANCE.convert4(((attrValueMap).get(productAttrSimpleBO.getId())))); + } + return attrs; + } + + @Override + public ProductAttrBO2 addProductAttr(Integer adminId, ProductAttrAddDTO productAttrAddDTO) { + // 校验规格名不重复 + int count = productAttrMapper.selectCount(Wrappers.query().lambda() + .eq(ProductAttrDO::getName, productAttrAddDTO.getName()) + .eq(ProductAttrDO::getDeleted, false)); + if (count > 0) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_EXISTS.getCode()); + } + // 插入到数据库 + ProductAttrDO productAttrDO = ProductAttrConvert2.INSTANCE.convert(productAttrAddDTO) + .setStatus(ProductAttrConstants.ATTR_STATUS_ENABLE); + productAttrDO.setCreateTime(new Date()); + productAttrDO.setDeleted(DeletedStatusEnum.DELETED_NO.getValue()); + productAttrMapper.insert(productAttrDO); + // 返回成功 + return ProductAttrConvert2.INSTANCE.convert(productAttrDO); + } + + @Override + public Boolean updateProductAttr(Integer adminId, ProductAttrUpdateDTO productAttrUpdateDTO) { + // 校验存在 + if (productAttrMapper.selectById(productAttrUpdateDTO.getId()) == null) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_NOT_EXIST.getCode()); + } + // 校验规格名不重复 + ProductAttrDO existsAttrDO = productAttrMapper.selectOne(Wrappers.query().lambda() + .eq(ProductAttrDO::getName, productAttrUpdateDTO.getName()) + .eq(ProductAttrDO::getDeleted, false)); + if (existsAttrDO != null && !existsAttrDO.getId().equals(productAttrUpdateDTO.getId())) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_EXISTS.getCode()); + } + // 更新到数据库 + ProductAttrDO updateProductAttr = ProductAttrConvert2.INSTANCE.convert(productAttrUpdateDTO); + productAttrMapper.updateById(updateProductAttr); + // 返回成功 + return true; + } + + @Override + public Boolean updateProductAttrStatus(Integer adminId, Integer productAttrId, Integer status) { + // 校验存在 + ProductAttrDO productAttrDO = productAttrMapper.selectById(productAttrId); + if (productAttrDO == null) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_NOT_EXIST.getCode()); + } + // 校验状态 + if (productAttrDO.getStatus().equals(status)) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_STATUS_EQUALS.getCode()); + } + // 更新到数据库 + ProductAttrDO updateProductAttr = new ProductAttrDO().setId(productAttrId).setStatus(status); + productAttrMapper.updateById(updateProductAttr); + // 返回成功 + return true; + } + + @Override + public ProductAttrValueBO addProductAttrValue(Integer adminId, ProductAttrValueAddDTO productAttrValueAddDTO) { + // 校验规格名不重复 + int count = productAttrValueMapper.selectCount(Wrappers.query().lambda() + .eq(ProductAttrValueDO::getName, productAttrValueAddDTO.getName()) + .eq(ProductAttrValueDO::getAttrId, productAttrValueAddDTO.getAttrId()) + .eq(ProductAttrValueDO::getDeleted, false)); + if (count > 0) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_VALUE_EXISTS.getCode()); + } + // 插入到数据库 + ProductAttrValueDO productAttrValueDO = ProductAttrConvert2.INSTANCE.convert(productAttrValueAddDTO) + .setStatus(ProductAttrConstants.ATTR_VALUE_STATUS_ENABLE); + productAttrValueDO.setCreateTime(new Date()); + productAttrValueDO.setDeleted(DeletedStatusEnum.DELETED_NO.getValue()); + productAttrValueMapper.insert(productAttrValueDO); + // 返回成功 + return ProductAttrConvert2.INSTANCE.convert2(productAttrValueDO); + } + + @Override + public Boolean updateProductAttrValue(Integer adminId, ProductAttrValueUpdateDTO productAttrValueUpdateDTO) { + // 校验存在 + ProductAttrValueDO productAttrValueDO = productAttrValueMapper.selectById(productAttrValueUpdateDTO.getId()); + if (productAttrValueDO == null) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_VALUE_NOT_EXIST.getCode()); + } + // 校验规格名不重复 + ProductAttrValueDO existsAttrDO = productAttrValueMapper.selectOne(Wrappers.query().lambda() + .eq(ProductAttrValueDO::getName, productAttrValueDO.getName()) + .eq(ProductAttrValueDO::getAttrId, productAttrValueDO.getAttrId()) + .eq(ProductAttrValueDO::getDeleted, false)); + if (existsAttrDO != null && !existsAttrDO.getId().equals(productAttrValueUpdateDTO.getId())) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_VALUE_EXISTS.getCode()); + } + // 更新到数据库 + ProductAttrValueDO updateProductValue = ProductAttrConvert2.INSTANCE.convert(productAttrValueUpdateDTO); + productAttrValueMapper.updateById(updateProductValue); + // 返回成功 + return true; + } + + @Override + public Boolean updateProductAttrValueStatus(Integer adminId, Integer productAttrValueId, Integer status) { + // 校验存在 + ProductAttrValueDO productAttrValueDO = productAttrValueMapper.selectById(productAttrValueId); + if (productAttrValueDO == null) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_VALUE_NOT_EXIST.getCode()); + } + // 校验状态 + if (productAttrValueDO.getStatus().equals(status)) { + throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_VALUE_STATUS_EQUALS.getCode()); + } + // 更新到数据库 + ProductAttrValueDO updateProductAttrValue = new ProductAttrValueDO().setId(productAttrValueId).setStatus(status); + productAttrValueMapper.updateById(updateProductAttrValue); + // 返回成功 + return true; + } + +} diff --git a/product/product-biz/src/main/resources/biz.properties b/product/product-biz/src/main/resources/biz.properties new file mode 100644 index 000000000..9275a3bfb --- /dev/null +++ b/product/product-biz/src/main/resources/biz.properties @@ -0,0 +1,2 @@ +##################### 业务模块 ##################### + diff --git a/product/product-biz/src/main/resources/biz.yaml b/product/product-biz/src/main/resources/biz.yaml new file mode 100644 index 000000000..f2aa6a7b5 --- /dev/null +++ b/product/product-biz/src/main/resources/biz.yaml @@ -0,0 +1,19 @@ +spring: + # 数据源配置项 + datasource: + url: jdbc:mysql://s1.iocoder.cn:3306/mall_product?useSSL=false&useUnicode=true&characterEncoding=UTF-8 + driver-class-name: com.mysql.jdbc.Driver + username: root + password: 3WLiVUBEwTbvAfsh + +# 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) + mapper-locations: classpath*:mapper/*.xml + type-aliases-package: cn.iocoder.mall.product.biz.dataobject diff --git a/product/product-biz/src/main/resources/mapper/ProductSpuMapper.xml b/product/product-biz/src/main/resources/mapper/ProductSpuMapper.xml new file mode 100644 index 000000000..dc3d2b7c7 --- /dev/null +++ b/product/product-biz/src/main/resources/mapper/ProductSpuMapper.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/product/product-rest/pom.xml b/product/product-rest/pom.xml new file mode 100644 index 000000000..3ff0fd551 --- /dev/null +++ b/product/product-rest/pom.xml @@ -0,0 +1,41 @@ + + + + system + cn.iocoder.mall + 1.0-SNAPSHOT + + 4.0.0 + + product-rest + 提供 system 服务的 Rest 接口的实现,提供对外调用 + + + + + cn.iocoder.mall + product-biz + 1.0-SNAPSHOT + + + + + cn.iocoder.mall + mall-spring-boot-starter-web + 1.0-SNAPSHOT + + + cn.iocoder.mall + mall-spring-boot-starter-security + 1.0-SNAPSHOT + + + cn.iocoder.mall + mall-spring-boot-starter-swagger + 1.0-SNAPSHOT + + + + diff --git a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/admins/AdminsProductAttrController.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/admins/AdminsProductAttrController.java new file mode 100644 index 000000000..f6bbb50f0 --- /dev/null +++ b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/admins/AdminsProductAttrController.java @@ -0,0 +1,134 @@ +package cn.iocoder.mall.product.rest.controller.admins; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.product.biz.bo.attr.ProductAttrBO; +import cn.iocoder.mall.product.biz.dto.attr.AdminProductAttrPageDTO; +import cn.iocoder.mall.product.biz.service.product.ProductAttrService; +import cn.iocoder.mall.product.rest.convert.attr.ProductAttrConvert; +import cn.iocoder.mall.product.rest.request.attr.AdminProductAttrPageRequest; +import cn.iocoder.mall.product.rest.response.attr.AdminsProductAttrPageResponse; +import io.swagger.annotations.Api; +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.RestController; + +/** + * 商品规格 + * + * @author lanmao + * @version 1.0 + * @date 2020/05/06 16:36 + */ +@RestController +@RequestMapping("admins") +@Api("商品规格") +public class AdminsProductAttrController { + + @Autowired + private ProductAttrService productAttrService; + + @GetMapping("/attr/page") + @ApiOperation("获得规格分页") + public CommonResult> attrPage(AdminProductAttrPageRequest request) { + AdminProductAttrPageDTO pageDTO = ProductAttrConvert.INSTANCE.convert(request); + PageResult productAttrPage = productAttrService.getProductAttrPage(pageDTO); + PageResult adminPageResponse = ProductAttrConvert.INSTANCE.convertPage(productAttrPage); + return CommonResult.success(adminPageResponse); + } + +// @GetMapping("/attr/tree") +// @ApiOperation(value = "获得规格树结构", notes = "该接口返回的信息更为精简。一般用于前端缓存数据字典到本地。") +// public CommonResult> tree() { +// // 查询全列表 +// List result = productAttrService.getProductAttrList(); +// // 返回结果 +// return success(ProductAttrConvert.INSTANCE.convert(result)); +// } +// +// @PostMapping("/attr/add") +// @ApiOperation(value = "创建商品规格") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "name", value = "规格名", required = true, example = "颜色") +// }) +// public CommonResult addAttr(@RequestParam("name") String name) { +// // 创建 ProductAttrAddDTO 对象 +// ProductAttrAddDTO productAttrAddDTO = new ProductAttrAddDTO().setName(name); +// // 添加 +// ProductAttrBO result = productAttrService.addProductAttr(AdminSecurityContextHolder.getContext().getAdminId(), productAttrAddDTO); +// // 返回结果 +// return success(ProductAttrConvert.INSTANCE.convert3(result)); +// } +// +// @PostMapping("/attr/update") +// @ApiOperation(value = "修改商品规格") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "id", value = "规格编号", required = true, example = "1"), +// @ApiImplicitParam(name = "name", value = "规格名", required = true, example = "颜色") +// }) +// public CommonResult updateAttr(@RequestParam("id") Integer id, +// @RequestParam("name") String name) { +// // 创建 ProductAttrUpdateDTO 对象 +// ProductAttrUpdateDTO productAttrUpdateDTO = new ProductAttrUpdateDTO().setId(id).setName(name); +// // 更新 +// return success(productAttrService.updateProductAttr(AdminSecurityContextHolder.getContext().getAdminId(), productAttrUpdateDTO)); +// } +// +// @PostMapping("/attr/update_status") +// @ApiOperation(value = "修改商品规格状态") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "id", value = "规格编号", required = true, example = "100"), +// @ApiImplicitParam(name = "status", value = "状态", required = true, example = "1") +// }) +// public CommonResult updateAttrStatus(@RequestParam("id") Integer id, +// @RequestParam("status") Integer status) { +// return success(productAttrService.updateProductAttrStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status)); +// } +// +// // TODO 芋艿 暂时不考虑 delete Attr 。因为关联逻辑比较多 +// +// @PostMapping("/attr_value/add") +// @ApiOperation(value = "创建商品规格值") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "attrId", value = "规格编号", required = true, example = "100"), +// @ApiImplicitParam(name = "name", value = "规格值", required = true, example = "蓝色") +// }) +// public CommonResult addAttrValue(@RequestParam("attrId") Integer attrId, +// @RequestParam("name") String name) { +// // 创建 ProductAttrValueAddDTO 对象 +// ProductAttrValueAddDTO productAttrValueAddDTO = new ProductAttrValueAddDTO().setAttrId(attrId).setName(name); +// // 添加 +// ProductAttrValueBO result = productAttrService.addProductAttrValue(AdminSecurityContextHolder.getContext().getAdminId(), productAttrValueAddDTO); +// // 返回结果 +// return success(ProductAttrConvert.INSTANCE.convert4(result)); +// } +// +// @PostMapping("/attr_value/update") +// @ApiOperation(value = "修改商品规格值") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "id", value = "规格值编号", required = true, example = "100"), +// @ApiImplicitParam(name = "name", value = "规格值", required = true, example = "蓝色") +// }) +// public CommonResult updateAttrValue(@RequestParam("id") Integer id, +// @RequestParam("name") String name) { +// // 创建 ProductAttrValueUpdateDTO 对象 +// ProductAttrValueUpdateDTO productAttrValueUpdateDTO = new ProductAttrValueUpdateDTO().setId(id).setName(name); +// // 更新 +// return success(productAttrService.updateProductAttrValue(AdminSecurityContextHolder.getContext().getAdminId(), productAttrValueUpdateDTO)); +// } +// +// @PostMapping("/attr_value/update_status") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "id", value = "规格编号", required = true, example = "100"), +// @ApiImplicitParam(name = "status", value = "状态", required = true, example = "1") +// }) +// public CommonResult updateAttrValueStatus(@RequestParam("id") Integer id, +// @RequestParam("status") Integer status) { +// return success(productAttrService.updateProductAttrValueStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status)); +// } + + // TODO 芋艿 暂时不考虑 delete Attr Value 。因为关联逻辑比较多 + +} diff --git a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/users/UserFavoriteController.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/users/UserFavoriteController.java new file mode 100644 index 000000000..6f5ba4993 --- /dev/null +++ b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/users/UserFavoriteController.java @@ -0,0 +1,18 @@ +package cn.iocoder.mall.product.rest.controller.users; + +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 用户收藏 + * @author xiaofeng + * @date 2019/07/07 11:06 + * @version 1.0 + */ +@RestController +@RequestMapping("users/favorite") +@Api("用户收藏") +public class UserFavoriteController { + +} diff --git a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/convert/attr/ProductAttrConvert.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/convert/attr/ProductAttrConvert.java new file mode 100644 index 000000000..13415d7c9 --- /dev/null +++ b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/convert/attr/ProductAttrConvert.java @@ -0,0 +1,19 @@ +package cn.iocoder.mall.product.rest.convert.attr; + +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.product.biz.bo.attr.ProductAttrBO; +import cn.iocoder.mall.product.biz.dto.attr.AdminProductAttrPageDTO; +import cn.iocoder.mall.product.rest.request.attr.AdminProductAttrPageRequest; +import cn.iocoder.mall.product.rest.response.attr.AdminsProductAttrPageResponse; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface ProductAttrConvert { + + ProductAttrConvert INSTANCE = Mappers.getMapper(ProductAttrConvert.class); + + AdminProductAttrPageDTO convert(AdminProductAttrPageRequest bean); + + PageResult convertPage(PageResult productAttrPage); +} diff --git a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/request/attr/AdminProductAttrPageRequest.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/request/attr/AdminProductAttrPageRequest.java new file mode 100644 index 000000000..7b663875c --- /dev/null +++ b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/request/attr/AdminProductAttrPageRequest.java @@ -0,0 +1,19 @@ +package cn.iocoder.mall.product.rest.request.attr; + +import cn.iocoder.common.framework.vo.PageParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +@ApiModel("商品 - 规格模块 - 商品规格 Request") +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +public class AdminProductAttrPageRequest extends PageParam { + + @ApiModelProperty(value = "商品规格名字,模糊匹配", example = "材料") + private String name; + +} diff --git a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/response/attr/AdminsProductAttrPageResponse.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/response/attr/AdminsProductAttrPageResponse.java new file mode 100644 index 000000000..0e24246c7 --- /dev/null +++ b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/response/attr/AdminsProductAttrPageResponse.java @@ -0,0 +1,66 @@ +package cn.iocoder.mall.product.rest.response.attr; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; +import java.util.List; + +@ApiModel("商品管理 - 商品规格模块 - 商品规格分页信息 Response") +@Data +@Accessors(chain = true) +public class AdminsProductAttrPageResponse { + + /** + * 规格编号 + */ + private Integer id; + /** + * 规格名 + */ + private String name; + /** + * 状态 + */ + private Integer status; + /** + * 创建时间 + */ + private Date createTime; + + /** + * 规格值数组 + */ + private List values; + + @ApiModel("规格值") + @Data + @Accessors(chain = true) + public static class ProductAttrValue { + + /** + * 规格值编号 + */ + @ApiModelProperty(value = "规格值编号", required = true, example = "1") + private Integer id; + /** + * 规格值名 + */ + @ApiModelProperty(value = "规格值名", required = true, example = "小") + private String name; + /** + * 状态 + */ + @ApiModelProperty(value = "状态", required = true, example = "1") + private Integer status; + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") + private Date createTime; + } + + +} diff --git a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/response/attr/AdminsProdutAttrResponse.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/response/attr/AdminsProdutAttrResponse.java new file mode 100644 index 000000000..3ca9c3330 --- /dev/null +++ b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/response/attr/AdminsProdutAttrResponse.java @@ -0,0 +1,4 @@ +package cn.iocoder.mall.product.rest.response.attr; + +public class AdminsProdutAttrResponse { +} diff --git a/product/product-rest/src/main/resources/rest.yaml b/product/product-rest/src/main/resources/rest.yaml new file mode 100644 index 000000000..37801cc94 --- /dev/null +++ b/product/product-rest/src/main/resources/rest.yaml @@ -0,0 +1,12 @@ +# 服务器的配置项 +server: + port: 18081 + servlet: + context-path: /product-api/ + +# Swagger 配置项 +swagger: + title: 商品子系统 + description: 商品子系统 + version: 1.0.0 + base-package: cn.iocoder.mall.system.rest.controller diff --git a/product/product-rpc-api/pom.xml b/product/product-rpc-api/pom.xml new file mode 100644 index 000000000..8cb7a6478 --- /dev/null +++ b/product/product-rpc-api/pom.xml @@ -0,0 +1,34 @@ + + + + system + cn.iocoder.mall + 1.0-SNAPSHOT + + 4.0.0 + + product-rpc-api + + + + + cn.iocoder.mall + product-biz-api + 1.0-SNAPSHOT + + + + + javax.validation + validation-api + + + org.projectlombok + lombok + + + + + diff --git a/product/product-rpc-api/src/main/java/cn/iocoder/mall/product/rpc/package-info.java b/product/product-rpc-api/src/main/java/cn/iocoder/mall/product/rpc/package-info.java new file mode 100644 index 000000000..4c49428c5 --- /dev/null +++ b/product/product-rpc-api/src/main/java/cn/iocoder/mall/product/rpc/package-info.java @@ -0,0 +1,4 @@ +/** + * 提供 system 服务的 RPC 接口的定义,提供内部调用 + */ +package cn.iocoder.mall.product.rpc; diff --git a/product/product-rpc/pom.xml b/product/product-rpc/pom.xml new file mode 100644 index 000000000..010865b94 --- /dev/null +++ b/product/product-rpc/pom.xml @@ -0,0 +1,40 @@ + + + + system + cn.iocoder.mall + 1.0-SNAPSHOT + + 4.0.0 + + product-rpc + + + + + cn.iocoder.mall + product-rpc-api + 1.0-SNAPSHOT + + + cn.iocoder.mall + product-biz + 1.0-SNAPSHOT + + + + + com.alibaba.cloud + spring-cloud-starter-dubbo + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + diff --git a/product/product-rpc/src/main/java/cn/iocoder/mall/product/rpc/package-info.java b/product/product-rpc/src/main/java/cn/iocoder/mall/product/rpc/package-info.java new file mode 100644 index 000000000..045fb0f93 --- /dev/null +++ b/product/product-rpc/src/main/java/cn/iocoder/mall/product/rpc/package-info.java @@ -0,0 +1,4 @@ +/** + * 提供 product 服务的 RPC 接口的实现,提供内部调用 + */ +package cn.iocoder.mall.product.rpc; diff --git a/product/product-rpc/src/main/resources/rpc-local.yaml b/product/product-rpc/src/main/resources/rpc-local.yaml new file mode 100644 index 000000000..e056170af --- /dev/null +++ b/product/product-rpc/src/main/resources/rpc-local.yaml @@ -0,0 +1,14 @@ +spring: + # Spring Cloud 配置项 + cloud: + nacos: + # Spring Cloud Nacos Discovery 配置项 + discovery: + server-addr: s1.iocoder.cn:8848 # Nacos 服务器地址 + namespace: local # Nacos 命名空间 + +# Dubbo 配置项 +dubbo: + # Dubbo 注册中心 + registry: + address: spring-cloud://s1.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址 diff --git a/product/product-rpc/src/main/resources/rpc-test.yaml b/product/product-rpc/src/main/resources/rpc-test.yaml new file mode 100644 index 000000000..d3d0e9e69 --- /dev/null +++ b/product/product-rpc/src/main/resources/rpc-test.yaml @@ -0,0 +1,14 @@ +spring: + # Spring Cloud 配置项 + cloud: + nacos: + # Spring Cloud Nacos Discovery 配置项 + discovery: + server-addr: s1.iocoder.cn:8848 # Nacos 服务器地址 + namespace: test # Nacos 命名空间 + +# Dubbo 配置项 +dubbo: + # Dubbo 注册中心 + registry: + address: spring-cloud://s1.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址 diff --git a/product/product-rpc/src/main/resources/rpc.yaml b/product/product-rpc/src/main/resources/rpc.yaml new file mode 100644 index 000000000..e056da380 --- /dev/null +++ b/product/product-rpc/src/main/resources/rpc.yaml @@ -0,0 +1,40 @@ +# Dubbo 配置项 +dubbo: + # Spring Cloud Alibaba Dubbo 专属配置 + cloud: + subscribed-services: '' # 设置订阅的应用列表,默认为 * 订阅所有应用 + # Dubbo 提供者的协议 + protocol: + name: dubbo + port: -1 + # Dubbo 提供服务的扫描基础包 + scan: + base-packages: cn.iocoder.mall.system.rpc.rpc + # Dubbo 服务提供者的配置 + provider: + filter: -exception + SystemLogRPC: + version: 1.0.0 + OAuth2RPC: + version: 1.0.0 + AuthorizationRPC: + version: 1.0.0 + AdminRPC: + version: 1.0.0 + UserRPC: + version: 1.0.0 + UserAddressRPC: + version: 1.0.0 + + # Dubbo 服务消费者的配置 + consumer: + SystemLogRPC: # 用于 AccessLogInterceptor 等拦截器,记录 HTTP API 请求的访问日志 + version: 1.0.0 + OAuth2RPC: # 用于 AccountAuthInterceptor 拦截器,执行认证 + version: 1.0.0 + AuthorizationRPC: # 用于 AccountAuthInterceptor 拦截器,执行鉴权(权限验证) + version: 1.0.0 + AdminRPC: + version: 1.0.0 + UserRPC: + version: 1.0.0 diff --git a/product/product-start/pom.xml b/product/product-start/pom.xml new file mode 100644 index 000000000..594e99ee6 --- /dev/null +++ b/product/product-start/pom.xml @@ -0,0 +1,104 @@ + + + + product + cn.iocoder.mall + 1.0-SNAPSHOT + + 4.0.0 + + product-start + + + + + cn.iocoder.mall + common-framework + 1.0-SNAPSHOT + + + cn.iocoder.mall + mall-spring-boot + 1.0-SNAPSHOT + + + cn.iocoder.mall + product-service-api + 1.0-SNAPSHOT + + + cn.iocoder.mall + product-service-impl + 1.0-SNAPSHOT + + + cn.iocoder.mall + user-sdk + 1.0-SNAPSHOT + + + cn.iocoder.mall + system-sdk + 1.0-SNAPSHOT + + + + + org.springframework.boot + spring-boot-starter-web + + + + io.springfox + springfox-swagger2 + + + com.github.xiaoymin + swagger-bootstrap-ui + + + + + com.alibaba.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/product/product-start/src/main/java/cn/iocoder/mall/product/application/ProductApplication.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/ProductApplication.java new file mode 100644 index 000000000..81aed8b6a --- /dev/null +++ b/product/product-start/src/main/java/cn/iocoder/mall/product/application/ProductApplication.java @@ -0,0 +1,26 @@ +package cn.iocoder.mall.product.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.product"}) +@EnableAsync(proxyTargetClass = true) +public class ProductApplication { + + /** + * 设置需要读取的配置文件的名字。 + * 基于 {@link org.springframework.boot.context.config.ConfigFileApplicationListener#CONFIG_NAME_PROPERTY} 实现。 + */ + private static final String CONFIG_NAME_VALUE = "biz,rest,rpc,application"; + + public static void main(String[] args) { + // 设置环境变量 + System.setProperty(ConfigFileApplicationListener.CONFIG_NAME_PROPERTY, CONFIG_NAME_VALUE); + + // 启动 Spring Boot 应用 + SpringApplication.run(ProductApplication.class, args); + } + +} diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductAttrController.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductAttrController.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductAttrController.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductAttrController.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductBrandController.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductBrandController.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductBrandController.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductBrandController.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductCategoryController.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductCategoryController.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductCategoryController.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductCategoryController.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductSpuController.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductSpuController.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductSpuController.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductSpuController.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UserFavoriteController.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/users/UserFavoriteController.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UserFavoriteController.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/users/UserFavoriteController.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductSpuCollectionController.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductSpuCollectionController.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductSpuCollectionController.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductSpuCollectionController.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductSpuController.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductSpuController.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductSpuController.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductSpuController.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductAttrConvert.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/convert/ProductAttrConvert.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductAttrConvert.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/convert/ProductAttrConvert.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductBrandConvert.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/convert/ProductBrandConvert.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductBrandConvert.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/convert/ProductBrandConvert.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductCategoryConvert.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/convert/ProductCategoryConvert.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductCategoryConvert.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/convert/ProductCategoryConvert.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductSpuConvert.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/convert/ProductSpuConvert.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductSpuConvert.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/convert/ProductSpuConvert.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrAndValuePairVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrAndValuePairVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrAndValuePairVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrAndValuePairVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrDetailVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrDetailVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrDetailVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrDetailVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrPageVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrPageVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrPageVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrPageVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrSimpleVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrSimpleVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrSimpleVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrSimpleVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrValueDetailVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrValueDetailVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrValueDetailVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrValueDetailVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrValueSimpleVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrValueSimpleVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrValueSimpleVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrValueSimpleVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrValueVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrValueVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrValueVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductAttrValueVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductBrandVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductBrandVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductBrandVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductBrandVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductBrangPageVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductBrangPageVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductBrangPageVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductBrangPageVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductCategoryTreeNodeVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductCategoryTreeNodeVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductCategoryTreeNodeVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductCategoryTreeNodeVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductCategoryVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductCategoryVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductCategoryVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductCategoryVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSkuDetailVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSkuDetailVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSkuDetailVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSkuDetailVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuDetailVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuDetailVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuDetailVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuDetailVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuPageVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuPageVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuPageVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuPageVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductAttrAndValuePairVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductAttrAndValuePairVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductAttrAndValuePairVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductAttrAndValuePairVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductCategoryVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductCategoryVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductCategoryVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductCategoryVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSkuDetailVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSkuDetailVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSkuDetailVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSkuDetailVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuDetailVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuDetailVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuDetailVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuDetailVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuPageVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuPageVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuPageVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuPageVO.java diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuVO.java similarity index 100% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuVO.java rename to product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuVO.java diff --git a/product/product-start/src/main/resources/application-test.yaml b/product/product-start/src/main/resources/application-test.yaml new file mode 100644 index 000000000..22be4ba61 --- /dev/null +++ b/product/product-start/src/main/resources/application-test.yaml @@ -0,0 +1,6 @@ +swagger: + enable: true + title: 商品子系统 + description: 商品子系统 + version: 1.0.0 + base-package: cn.iocoder.mall.product.application.controller diff --git a/product/product-start/src/main/resources/application.yaml b/product/product-start/src/main/resources/application.yaml new file mode 100644 index 000000000..a5f4207ce --- /dev/null +++ b/product/product-start/src/main/resources/application.yaml @@ -0,0 +1,34 @@ +spring: + application: + name: product-application + + # Spring Cloud 配置项 + cloud: + # Spring Cloud Sentinel 配置项 + sentinel: + transport: + dashboard: s1.iocoder.cn:12088 # Sentinel Dashboard 服务地址 + eager: true # 项目启动时,直接连接到 Sentinel + +# server +server: + port: 18081 + servlet: + context-path: /product-api/ + + + +management: + endpoints: + web: + exposure: + include: health,info,env,metrics,prometheus + metrics: + enabled: true + +swagger: + enable: true + title: 商品子系统 + description: 商品子系统 + version: 1.0.0 + base-package: cn.iocoder.mall.product.application.controller