From b209505f9953e5602e53ad952e3ca4b4a8742e07 Mon Sep 17 00:00:00 2001
From: YunaiV <>
Date: Fri, 24 Jul 2020 18:55:51 +0800
Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=86=E7=B1=BB=E7=9A=84?=
=?UTF-8?q?=E8=BF=81=E7=A7=BB=EF=BC=8C=E6=9C=AA=E5=AE=8C=E6=88=90=EF=BC=8C?=
=?UTF-8?q?=E5=85=88=E6=8F=90=E4=BA=A4=E4=B8=8B~?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../core/handler/GlobalExceptionHandler.java | 12 +-
pom.xml | 3 +-
{user => product-service-project}/pom.xml | 17 +-
.../product-service-api}/pom.xml | 16 +-
.../enums/ProductErrorCodeConstants.java | 41 +++++
.../enums/category/ProductCategoryIdEnum.java | 23 +++
.../product-service-app/pom.xml | 76 +++++++++
.../ProductServiceApplication.java | 13 ++
.../config/DatabaseConfiguration.java | 28 ++++
.../category/ProductCategoryConvert.java | 25 +++
.../category/ProductCategoryDO.java | 52 ++++++
.../category/ProductCategoryMapper.java | 15 ++
.../category/ProductCategoryService.java | 129 +++++++++++++++
.../category/bo/ProductCategoryBO.java | 48 ++++++
.../category/bo/ProductCategoryCreateBO.java | 45 +++++
.../category/bo/ProductCategoryUpdateBO.java | 50 ++++++
.../src/main/resources/application-dev.yaml | 20 +++
.../src/main/resources/application-local.yaml | 24 +++
.../src/main/resources/application.yaml | 67 ++++++++
product/product-application/pom.xml | 29 ----
.../application/ProductApplication.java | 26 ---
.../src/main/resources/application-test.yaml | 6 -
.../src/main/resources/application.yaml | 9 -
.../biz/enums/ProductErrorCodeEnum.java | 63 -------
.../biz/enums/attr/ProductAttrConstants.java | 23 ---
.../category/ProductCategoryNodeEnum.java | 28 ----
.../category/ProductCategoryStatusEnum.java | 46 ------
.../biz/enums/spu/ProductSpuConstants.java | 14 --
.../mall/product/biz/package-info.java | 6 -
.../category/ProductCategoryServiceImpl.java | 114 -------------
product/product-mq/pom.xml | 15 --
.../cn/iocoder/mall/demo/mq/package-info.java | 1 -
.../service/ProductCategoryServiceImpl.java | 154 ------------------
.../enums/permission/ResourceIdEnum.java | 2 +-
.../system-service-app/pom.xml | 8 -
.../controller/address/AddressController.http | 5 +
.../address/UserAddressController.java | 7 +
.../manager/address/UserAddressManager.java | 18 +-
user/user-rest/pom.xml | 41 -----
.../user/UsersUserAddressController.java | 81 ---------
.../request/user/UserAddressAddRequest.java | 41 -----
.../user/UserAddressUpdateRequest.java | 45 -----
.../response/user/UserAddressResponse.java | 41 -----
43 files changed, 721 insertions(+), 806 deletions(-)
rename {user => product-service-project}/pom.xml (67%)
rename {product/product-biz-api => product-service-project/product-service-api}/pom.xml (59%)
create mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/enums/ProductErrorCodeConstants.java
create mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/enums/category/ProductCategoryIdEnum.java
create mode 100644 product-service-project/product-service-app/pom.xml
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/ProductServiceApplication.java
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/config/DatabaseConfiguration.java
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/category/ProductCategoryConvert.java
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/category/ProductCategoryDO.java
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/category/ProductCategoryMapper.java
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/ProductCategoryService.java
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/bo/ProductCategoryBO.java
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/bo/ProductCategoryCreateBO.java
create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/bo/ProductCategoryUpdateBO.java
create mode 100644 product-service-project/product-service-app/src/main/resources/application-dev.yaml
create mode 100644 product-service-project/product-service-app/src/main/resources/application-local.yaml
create mode 100644 product-service-project/product-service-app/src/main/resources/application.yaml
delete mode 100644 product/product-application/pom.xml
delete mode 100644 product/product-application/src/main/java/cn/iocoder/mall/product/application/ProductApplication.java
delete mode 100644 product/product-application/src/main/resources/application-test.yaml
delete mode 100644 product/product-application/src/main/resources/application.yaml
delete mode 100644 product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/ProductErrorCodeEnum.java
delete mode 100644 product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/attr/ProductAttrConstants.java
delete mode 100644 product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/category/ProductCategoryNodeEnum.java
delete mode 100644 product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/category/ProductCategoryStatusEnum.java
delete mode 100644 product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/spu/ProductSpuConstants.java
delete mode 100644 product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/package-info.java
delete mode 100644 product/product-mq/pom.xml
delete mode 100644 product/product-mq/src/main/java/cn/iocoder/mall/demo/mq/package-info.java
delete mode 100644 product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductCategoryServiceImpl.java
create mode 100644 user-web-app/src/main/java/cn/iocoder/mall/userweb/controller/address/AddressController.http
delete mode 100644 user/user-rest/pom.xml
delete mode 100644 user/user-rest/src/main/java/cn/iocoder/mall/user/rest/controller/user/UsersUserAddressController.java
delete mode 100644 user/user-rest/src/main/java/cn/iocoder/mall/user/rest/request/user/UserAddressAddRequest.java
delete mode 100644 user/user-rest/src/main/java/cn/iocoder/mall/user/rest/request/user/UserAddressUpdateRequest.java
delete mode 100644 user/user-rest/src/main/java/cn/iocoder/mall/user/rest/response/user/UserAddressResponse.java
diff --git a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/handler/GlobalExceptionHandler.java b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/handler/GlobalExceptionHandler.java
index 7a5dff9c3..d036fce45 100644
--- a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/handler/GlobalExceptionHandler.java
+++ b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/handler/GlobalExceptionHandler.java
@@ -31,6 +31,7 @@ import org.springframework.web.servlet.NoHandlerFoundException;
import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
+import javax.validation.ValidationException;
import java.util.Date;
import static cn.iocoder.common.framework.exception.enums.GlobalErrorCodeConstants.*;
@@ -162,7 +163,6 @@ public class GlobalExceptionHandler {
public CommonResult globalExceptionHandler(HttpServletRequest req, GlobalException ex) {
// 系统异常时,才打印异常日志
if (INTERNAL_SERVER_ERROR.getCode().equals(ex.getCode())) {
- logger.error("[globalExceptionHandler]", ex);
// 插入异常日志
this.createExceptionLog(req, ex);
// 普通全局异常,打印 info 日志即可
@@ -173,6 +173,16 @@ public class GlobalExceptionHandler {
return CommonResult.error(ex);
}
+ /**
+ * 处理 Dubbo Consumer 本地参数校验时,抛出的 ValidationException 异常
+ */
+ @ExceptionHandler(value = ValidationException.class)
+ public CommonResult validationException(ValidationException ex) {
+ logger.warn("[constraintViolationExceptionHandler]", ex);
+ // 无法拼接明细的错误信息,因为 Dubbo Consumer 抛出 ValidationException 异常时,是直接的字符串信息,且人类不可读
+ return CommonResult.error(BAD_REQUEST.getCode(), "请求参数不正确");
+ }
+
/**
* 处理系统异常,兜底处理所有的一切
*/
diff --git a/pom.xml b/pom.xml
index 60e431a00..85928c013 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,7 +16,6 @@
- user
common
@@ -24,13 +23,13 @@
mall-dependencies
-
user-service-project
user-web-app
system-service-project
pay-service-project
management-web-app
shop-web-app
+ product-service-project
pom
diff --git a/user/pom.xml b/product-service-project/pom.xml
similarity index 67%
rename from user/pom.xml
rename to product-service-project/pom.xml
index f2d71e10b..9a3f4adca 100644
--- a/user/pom.xml
+++ b/product-service-project/pom.xml
@@ -9,18 +9,16 @@
4.0.0
- user
+ product-service-project
pom
-
-
-
- user-rest
- user-biz
+ product-service-api
+ product-service-app
+
cn.iocoder.mall
mall-dependencies
@@ -28,6 +26,13 @@
pom
import
+
+
+
+ cn.iocoder.mall
+ product-service-api
+ 1.0-SNAPSHOT
+
diff --git a/product/product-biz-api/pom.xml b/product-service-project/product-service-api/pom.xml
similarity index 59%
rename from product/product-biz-api/pom.xml
rename to product-service-project/product-service-api/pom.xml
index 24925d7a7..e267473c8 100644
--- a/product/product-biz-api/pom.xml
+++ b/product-service-project/product-service-api/pom.xml
@@ -3,20 +3,28 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- product
+ product-service-project
cn.iocoder.mall
1.0-SNAPSHOT
4.0.0
- product-biz-api
+ product-service-api
-
cn.iocoder.mall
common-framework
- 1.0-SNAPSHOT
+
+
+
+
+ javax.validation
+ validation-api
+
+
+ org.projectlombok
+ lombok
diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/enums/ProductErrorCodeConstants.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/enums/ProductErrorCodeConstants.java
new file mode 100644
index 000000000..90f638270
--- /dev/null
+++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/enums/ProductErrorCodeConstants.java
@@ -0,0 +1,41 @@
+package cn.iocoder.mall.productservice.enums;
+
+import cn.iocoder.common.framework.exception.ErrorCode;
+
+/**
+ * 错误码枚举类
+ *
+ * 商品系统,使用 1-003-000-000 段
+ */
+public interface ProductErrorCodeConstants {
+
+ // ========== PRODUCT CATEGORY 模块 ==========
+ ErrorCode PRODUCT_CATEGORY_PARENT_NOT_EXISTS = new ErrorCode(1003001000, "父分类不存在");
+ ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1003001001, "商品分类不存在");
+ ErrorCode PRODUCT_CATEGORY_STATUS_NOT_EXISTS = new ErrorCode(1003001001, "商品分类状态不存在");
+ ErrorCode PRODUCT_CATEGORY_PARENT_NOT_SELF = new ErrorCode(1003001002, "不能设置自己为父分类");
+ ErrorCode PRODUCT_CATEGORY_STATUS_EQUALS = new ErrorCode(1002001003, "商品分类已经是该状态");
+ ErrorCode PRODUCT_CATEGORY_DELETE_ONLY_DISABLE = new ErrorCode(1002001004, "只有关闭的商品分类才可以删除");
+ ErrorCode PRODUCT_CATEGORY_DELETE_ONLY_NO_CHILD = new ErrorCode(1002001004, "只有无子分类的商品分类才可以删除");
+ ErrorCode PRODUCT_CATEGORY_MUST_ENABLE = new ErrorCode(1002001005, "只有开启的商品分类,才可以使用");
+ ErrorCode PRODUCT_CATEGORY_PARENT_CAN_NOT_BE_LEVEL2 = new ErrorCode(1002001005, "父分类必须是一级分类");
+
+ // ========== PRODUCT SPU + SKU 模块 ==========
+ ErrorCode PRODUCT_SKU_ATTR_CANT_NOT_DUPLICATE = new ErrorCode(1003002000, "一个 Sku 下,不能有重复的规格");
+ ErrorCode PRODUCT_SPU_ATTR_NUMBERS_MUST_BE_EQUALS = new ErrorCode(1003002001, "一个 Spu 下的每个 Sku ,其规格数必须一致");
+ ErrorCode PRODUCT_SPU_SKU__NOT_DUPLICATE = new ErrorCode(1003002002, "一个 Spu 下的每个 Sku ,必须不重复");
+ ErrorCode PRODUCT_SPU_NOT_EXISTS = new ErrorCode(1003002003, "Spu 不存在");
+ ErrorCode PRODUCT_SPU_CATEGORY_MUST_BE_LEVEL2 = new ErrorCode(1003002003, "Spu 只能添加在二级分类下");
+
+ // ========== PRODUCT ATTR + ATTR_VALUE 模块 ==========
+ ErrorCode PRODUCT_ATTR_VALUE_NOT_EXIST = new ErrorCode(1003003000, "商品属性值不存在");
+ ErrorCode PRODUCT_ATTR_NOT_EXIST = new ErrorCode(1003003001, "商品属性值不存在");
+ ErrorCode PRODUCT_ATTR_EXISTS = new ErrorCode(1003003002, "商品规格已经存在");
+ ErrorCode PRODUCT_ATTR_STATUS_EQUALS = new ErrorCode(1003003003, "商品规格已经是该状态");
+ ErrorCode PRODUCT_ATTR_VALUE_EXISTS = new ErrorCode(1003003004, "商品规格值已经存在");
+ ErrorCode PRODUCT_ATTR_VALUE_STATUS_EQUALS = new ErrorCode(1003003005, "商品规格值已经是该状态");
+
+ // ========== PRODUCT BRAND模块 ==========
+ ErrorCode PRODUCT_BRAND_EXIST = new ErrorCode(1003004000,"品牌值已经存在");
+
+}
diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/enums/category/ProductCategoryIdEnum.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/enums/category/ProductCategoryIdEnum.java
new file mode 100644
index 000000000..dd1807b6c
--- /dev/null
+++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/enums/category/ProductCategoryIdEnum.java
@@ -0,0 +1,23 @@
+package cn.iocoder.mall.productservice.enums.category;
+
+/**
+ * 商品分类的编号枚举
+ */
+public enum ProductCategoryIdEnum {
+
+ /**
+ * 根节点
+ */
+ ROOT(0);
+
+ private final Integer id;
+
+ ProductCategoryIdEnum(Integer id) {
+ this.id = id;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+}
diff --git a/product-service-project/product-service-app/pom.xml b/product-service-project/product-service-app/pom.xml
new file mode 100644
index 000000000..2b19dc8ef
--- /dev/null
+++ b/product-service-project/product-service-app/pom.xml
@@ -0,0 +1,76 @@
+
+
+
+ product-service-project
+ cn.iocoder.mall
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ product-service-app
+
+
+
+ cn.iocoder.mall
+ mall-spring-boot-starter-dubbo
+
+
+
+
+ cn.iocoder.mall
+ system-service-api
+
+
+
+
+ cn.iocoder.mall
+ product-service-api
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+ com.alibaba
+ druid-spring-boot-starter
+
+
+
+ cn.iocoder.mall
+ mall-spring-boot-starter-mybatis
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+ org.mapstruct
+ mapstruct
+
+
+ org.mapstruct
+ mapstruct-jdk8
+
+
+
+
+
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/ProductServiceApplication.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/ProductServiceApplication.java
new file mode 100644
index 000000000..ac41a7aab
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/ProductServiceApplication.java
@@ -0,0 +1,13 @@
+package cn.iocoder.mall.productservice;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ProductServiceApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ProductServiceApplication.class, args);
+ }
+
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/config/DatabaseConfiguration.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/config/DatabaseConfiguration.java
new file mode 100644
index 000000000..84fcef6fa
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/config/DatabaseConfiguration.java
@@ -0,0 +1,28 @@
+package cn.iocoder.mall.productservice.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.productservice.dal.mysql.mapper") // 扫描对应的 Mapper 接口
+@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理。
+public class DatabaseConfiguration {
+
+ // 数据库连接池 Druid
+
+ @Bean
+ public ISqlInjector sqlInjector() {
+ return new DefaultSqlInjector(); // MyBatis Plus 逻辑删除
+ }
+
+ @Bean
+ public PaginationInterceptor paginationInterceptor() {
+ return new PaginationInterceptor(); // MyBatis Plus 分页插件
+ }
+
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/category/ProductCategoryConvert.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/category/ProductCategoryConvert.java
new file mode 100644
index 000000000..aada2b4d4
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/category/ProductCategoryConvert.java
@@ -0,0 +1,25 @@
+package cn.iocoder.mall.productservice.convert.category;
+
+import cn.iocoder.mall.productservice.dal.mysql.dataobject.category.ProductCategoryDO;
+import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryBO;
+import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryCreateBO;
+import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryUpdateBO;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+
+@Mapper
+public interface ProductCategoryConvert {
+
+ ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class);
+
+ ProductCategoryDO convert(ProductCategoryCreateBO bean);
+
+ ProductCategoryBO convert(ProductCategoryDO bean);
+
+ List convertList(List list);
+
+ ProductCategoryDO convert(ProductCategoryUpdateBO bean);
+
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/category/ProductCategoryDO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/category/ProductCategoryDO.java
new file mode 100644
index 000000000..4ffcc962b
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/category/ProductCategoryDO.java
@@ -0,0 +1,52 @@
+package cn.iocoder.mall.productservice.dal.mysql.dataobject.category;
+
+import cn.iocoder.common.framework.enums.CommonStatusEnum;
+import cn.iocoder.mall.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+* 商品分类表
+*/
+@TableName("product_category")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+public class ProductCategoryDO extends BaseDO {
+
+ /**
+ * 分类编号
+ */
+ @TableId
+ private Integer id;
+ /**
+ * 父分类编号
+ */
+ private Integer pid;
+ /**
+ * 分类名称
+ */
+ private String name;
+ /**
+ * 分类描述
+ */
+ private String description;
+ /**
+ * 分类图片
+ */
+ private String picUrl;
+ /**
+ * 分类排序
+ */
+ private Integer sort;
+ /**
+ * 状态
+ *
+ * 枚举 {@link CommonStatusEnum}
+ */
+ private Integer status;
+
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/category/ProductCategoryMapper.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/category/ProductCategoryMapper.java
new file mode 100644
index 000000000..8d86d1242
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/category/ProductCategoryMapper.java
@@ -0,0 +1,15 @@
+package cn.iocoder.mall.productservice.dal.mysql.mapper.category;
+
+import cn.iocoder.mall.productservice.dal.mysql.dataobject.category.ProductCategoryDO;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface ProductCategoryMapper extends BaseMapper {
+
+ default Integer selectCountByPid(Integer pid) {
+ return selectCount(new QueryWrapper().eq("pid", pid));
+ }
+
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/ProductCategoryService.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/ProductCategoryService.java
new file mode 100644
index 000000000..722da2c55
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/ProductCategoryService.java
@@ -0,0 +1,129 @@
+package cn.iocoder.mall.productservice.service.category;
+
+import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
+import cn.iocoder.mall.productservice.convert.category.ProductCategoryConvert;
+import cn.iocoder.mall.productservice.dal.mysql.dataobject.category.ProductCategoryDO;
+import cn.iocoder.mall.productservice.dal.mysql.mapper.category.ProductCategoryMapper;
+import cn.iocoder.mall.productservice.enums.category.ProductCategoryIdEnum;
+import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryBO;
+import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryCreateBO;
+import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryUpdateBO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.validation.Valid;
+import java.util.List;
+
+import static cn.iocoder.mall.productservice.enums.ProductErrorCodeConstants.*;
+
+/**
+* 商品分类表 Service
+*/
+@Service
+@Validated
+public class ProductCategoryService {
+
+ @Autowired
+ private ProductCategoryMapper productCategoryMapper;
+
+ /**
+ * 创建商品分类表
+ *
+ * @param createBO 创建商品分类表 BO
+ * @return 商品分类表
+ */
+ public ProductCategoryBO createProductCategory(@Valid ProductCategoryCreateBO createBO) {
+ // 校验父分类
+ validParent(createBO.getPid());
+ // 插入到数据库
+ ProductCategoryDO productCategoryDO = ProductCategoryConvert.INSTANCE.convert(createBO);
+ productCategoryMapper.insert(productCategoryDO);
+ // 返回
+ return ProductCategoryConvert.INSTANCE.convert(productCategoryDO);
+ }
+
+ /**
+ * 更新商品分类表
+ *
+ * @param updateBO 更新商品分类表 BO
+ */
+ public void updateProductCategory(@Valid ProductCategoryUpdateBO updateBO) {
+ // 校验父分类
+ validParent(updateBO.getPid());
+ // 校验不能设置自己为父分类
+ if (updateBO.getId().equals(updateBO.getPid())) {
+ throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_PARENT_NOT_SELF);
+ }
+ // 校验更新的商品分类表是否存在
+ if (productCategoryMapper.selectById(updateBO.getId()) == null) {
+ throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS);
+ }
+ // 更新到数据库
+ ProductCategoryDO updateObject = ProductCategoryConvert.INSTANCE.convert(updateBO);
+ productCategoryMapper.updateById(updateObject);
+ }
+
+ /**
+ * 删除商品分类表
+ *
+ * @param productCategoryId 商品分类表编号
+ */
+ public void deleteProductCategory(Integer productCategoryId) {
+ // 校验删除的商品分类表是否存在
+ if (productCategoryMapper.selectById(productCategoryId) == null) {
+ throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS);
+ }
+ // 只有不存在子分类才可以删除
+ Integer childCount = productCategoryMapper.selectCountByPid(productCategoryId);
+ if (childCount > 0) {
+ throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_DELETE_ONLY_NO_CHILD);
+ }
+ // TODO 芋艿 补充只有不存在商品才可以删除
+ // 标记删除
+ productCategoryMapper.deleteById(productCategoryId);
+ }
+
+ /**
+ * 获得商品分类表
+ *
+ * @param productCategoryId 商品分类表编号
+ * @return 商品分类表
+ */
+ public ProductCategoryBO getProductCategory(Integer productCategoryId) {
+ ProductCategoryDO productCategoryDO = productCategoryMapper.selectById(productCategoryId);
+ return ProductCategoryConvert.INSTANCE.convert(productCategoryDO);
+ }
+
+ /**
+ * 获得商品分类表列表
+ *
+ * @param productCategoryIds 商品分类表编号列表
+ * @return 商品分类表列表
+ */
+ public List listProductCategories(List productCategoryIds) {
+ List productCategoryDOs = productCategoryMapper.selectBatchIds(productCategoryIds);
+ return ProductCategoryConvert.INSTANCE.convertList(productCategoryDOs);
+ }
+
+ private void validParent(Integer pid) {
+ if (!ProductCategoryIdEnum.ROOT.getId().equals(pid)) {
+ ProductCategoryDO parentCategory = productCategoryMapper.selectById(pid);
+ // 校验父分类是否存在
+ if (parentCategory == null) {
+ throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_PARENT_NOT_EXISTS);
+ }
+ // 父分类必须是一级分类
+ if (!ProductCategoryIdEnum.ROOT.getId().equals(parentCategory.getPid())) {
+ throw ServiceExceptionUtil.exception((PRODUCT_CATEGORY_PARENT_CAN_NOT_BE_LEVEL2));
+ }
+ }
+ }
+
+// @Override
+// public List getListByPid(Integer pid) {
+// List categoryList = productCategoryMapper.selectListByPidAndStatusOrderBySort(pid, ProductCategoryConstants.STATUS_ENABLE);
+// return ProductCategoryConvert.INSTANCE.convertToBO(categoryList);
+// }
+
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/bo/ProductCategoryBO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/bo/ProductCategoryBO.java
new file mode 100644
index 000000000..c09bb3719
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/bo/ProductCategoryBO.java
@@ -0,0 +1,48 @@
+package cn.iocoder.mall.productservice.service.category.bo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+* 商品分类表 BO
+*/
+@Data
+@Accessors(chain = true)
+public class ProductCategoryBO {
+
+ /**
+ * 分类编号
+ */
+ private Integer id;
+ /**
+ * 父分类编号
+ */
+ private Integer pid;
+ /**
+ * 分类名称
+ */
+ private String name;
+ /**
+ * 分类描述
+ */
+ private String description;
+ /**
+ * 分类图片
+ */
+ private String picUrl;
+ /**
+ * 分类排序
+ */
+ private Integer sort;
+ /**
+ * 状态
+ */
+ private Integer status;
+ /**
+ * 创建时间
+ */
+ private Date createTime;
+
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/bo/ProductCategoryCreateBO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/bo/ProductCategoryCreateBO.java
new file mode 100644
index 000000000..d6b0610fb
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/bo/ProductCategoryCreateBO.java
@@ -0,0 +1,45 @@
+package cn.iocoder.mall.productservice.service.category.bo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+/**
+* 商品分类表创建 BO
+*/
+@Data
+@Accessors(chain = true)
+public class ProductCategoryCreateBO {
+
+ /**
+ * 父分类编号
+ */
+ @NotNull(message = "父分类编号不能为空")
+ private Integer pid;
+ /**
+ * 分类名称
+ */
+ @NotEmpty(message = "分类名称不能为空")
+ private String name;
+ /**
+ * 分类描述
+ */
+ private String description;
+ /**
+ * 分类图片
+ */
+ private String picUrl;
+ /**
+ * 分类排序
+ */
+ @NotNull(message = "分类排序不能为空")
+ private Integer sort;
+ /**
+ * 状态
+ */
+ @NotNull(message = "状态不能为空")
+ private Integer status;
+
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/bo/ProductCategoryUpdateBO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/bo/ProductCategoryUpdateBO.java
new file mode 100644
index 000000000..5268602e3
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/category/bo/ProductCategoryUpdateBO.java
@@ -0,0 +1,50 @@
+package cn.iocoder.mall.productservice.service.category.bo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+/**
+* 商品分类表更新 BO
+*/
+@Data
+@Accessors(chain = true)
+public class ProductCategoryUpdateBO {
+
+ /**
+ * 分类编号
+ */
+ @NotNull(message = "分类编号不能为空")
+ private Integer id;
+ /**
+ * 父分类编号
+ */
+ @NotNull(message = "父分类编号不能为空")
+ private Integer pid;
+ /**
+ * 分类名称
+ */
+ @NotEmpty(message = "分类名称不能为空")
+ private String name;
+ /**
+ * 分类描述
+ */
+ private String description;
+ /**
+ * 分类图片
+ */
+ private String picUrl;
+ /**
+ * 分类排序
+ */
+ @NotNull(message = "分类排序不能为空")
+ private Integer sort;
+ /**
+ * 状态
+ */
+ @NotNull(message = "状态不能为空")
+ private Integer status;
+
+}
diff --git a/product-service-project/product-service-app/src/main/resources/application-dev.yaml b/product-service-project/product-service-app/src/main/resources/application-dev.yaml
new file mode 100644
index 000000000..cfae12b0d
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/resources/application-dev.yaml
@@ -0,0 +1,20 @@
+spring:
+ # 数据源配置项
+ datasource:
+ url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_system?useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ driver-class-name: com.mysql.jdbc.Driver
+ username: root
+ password: 3WLiVUBEwTbvAfsh
+ # Spring Cloud 配置项
+ cloud:
+ nacos:
+ # Spring Cloud Nacos Discovery 配置项
+ discovery:
+ server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ namespace: dev # Nacos 命名空间
+
+# Dubbo 配置项
+dubbo:
+ # Dubbo 注册中心
+ registry:
+ address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
diff --git a/product-service-project/product-service-app/src/main/resources/application-local.yaml b/product-service-project/product-service-app/src/main/resources/application-local.yaml
new file mode 100644
index 000000000..1b5420bef
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/resources/application-local.yaml
@@ -0,0 +1,24 @@
+spring:
+ # 数据源配置项
+ datasource:
+ url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_system?useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ driver-class-name: com.mysql.jdbc.Driver
+ username: root
+ password: 3WLiVUBEwTbvAfsh
+ # Spring Cloud 配置项
+ cloud:
+ nacos:
+ # Spring Cloud Nacos Discovery 配置项
+ discovery:
+ server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
+ namespace: dev # Nacos 命名空间
+
+# Dubbo 配置项
+dubbo:
+ # Dubbo 注册中心
+ registry:
+# address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
+ address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
+ # Dubbo 服务提供者的配置
+ provider:
+ tag: ${DUBBO_TAG} # Dubbo 路由分组
diff --git a/product-service-project/product-service-app/src/main/resources/application.yaml b/product-service-project/product-service-app/src/main/resources/application.yaml
new file mode 100644
index 000000000..f1cb94c44
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/resources/application.yaml
@@ -0,0 +1,67 @@
+spring:
+ # Application 的配置项
+ application:
+ name: product-service
+ # Profile 的配置项
+ profiles:
+ active: local
+
+# 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.productservice.dal.mysql.dataobject
+
+# Dubbo 配置项
+dubbo:
+ # Spring Cloud Alibaba Dubbo 专属配置
+ cloud:
+ subscribed-services: '' # 设置订阅的应用列表,默认为 * 订阅所有应用
+ # Dubbo 提供者的协议
+ protocol:
+ name: dubbo
+ port: -1
+ # Dubbo 提供服务的扫描基础包
+ scan:
+ base-packages: cn.iocoder.mall.productservice.rpc
+ # Dubbo 服务提供者的配置
+ provider:
+ filter: -exception
+ validation: true # 开启 Provider 参数校验
+ OAuth2Rpc:
+ version: 1.0.0
+ AdminRpc:
+ version: 1.0.0
+ ResourceRpc:
+ version: 1.0.0
+ RoleRpc:
+ version: 1.0.0
+ PermissionRpc:
+ version: 1.0.0
+ DepartmentRpc:
+ version: 1.0.0
+ DataDictRpc:
+ version: 1.0.0
+ ProductExceptionLogRpc:
+ version: 1.0.0
+ ProductAccessLogRpc:
+ version: 1.0.0
+ ErrorCodeRpc:
+ version: 1.0.0
+ # Dubbo 服务消费者的配置
+ consumer:
+ ErrorCodeRpc:
+ version: 1.0.0
+
+# Mall 配置项
+mall:
+ # 错误码配置项对应 ErrorCodeProperties 配置类
+ error-code:
+ group: ${spring.application.name}
+ constants-class: cn.iocoder.mall.productservice.enums.ProductErrorCodeConstants
diff --git a/product/product-application/pom.xml b/product/product-application/pom.xml
deleted file mode 100644
index 3dec4c1e0..000000000
--- a/product/product-application/pom.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
- product
- cn.iocoder.mall
- 1.0-SNAPSHOT
-
- 4.0.0
-
- product-application
-
-
-
-
- cn.iocoder.mall
- product-rest
- 1.0-SNAPSHOT
-
-
- cn.iocoder.mall
- product-rpc
- 1.0-SNAPSHOT
-
-
-
-
-
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
deleted file mode 100644
index 81aed8b6a..000000000
--- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/ProductApplication.java
+++ /dev/null
@@ -1,26 +0,0 @@
-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/resources/application-test.yaml b/product/product-application/src/main/resources/application-test.yaml
deleted file mode 100644
index 22be4ba61..000000000
--- a/product/product-application/src/main/resources/application-test.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-swagger:
- enable: true
- title: 商品子系统
- description: 商品子系统
- version: 1.0.0
- base-package: cn.iocoder.mall.product.application.controller
diff --git a/product/product-application/src/main/resources/application.yaml b/product/product-application/src/main/resources/application.yaml
deleted file mode 100644
index 003331d9f..000000000
--- a/product/product-application/src/main/resources/application.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-spring:
- # Application 的配置项
- application:
- name: product-application
- # Profile 的配置项
- profiles:
- active: local
-
-
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
deleted file mode 100644
index 3543d2d34..000000000
--- a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/ProductErrorCodeEnum.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package cn.iocoder.mall.product.biz.enums;
-
-import cn.iocoder.common.framework.util.ServiceExceptionUtil;
-
-/**
- * 错误码枚举类
- *
- * 商品系统,使用 1-003-000-000 段
- */
-public enum ProductErrorCodeEnum implements ServiceExceptionUtil.Enumerable {
-
- // ========== PRODUCT CATEGORY 模块 ==========
- PRODUCT_CATEGORY_PARENT_NOT_EXISTS(1003001000, "父分类不存在"),
- PRODUCT_CATEGORY_NOT_EXISTS(1003001001, "商品分类不存在"),
- PRODUCT_CATEGORY_STATUS_NOT_EXISTS(1003001001, "商品分类状态不存在"),
- PRODUCT_CATEGORY_PARENT_NOT_SELF(1003001002, "不能设置自己为父分类"),
- PRODUCT_CATEGORY_STATUS_EQUALS(1002001003, "商品分类已经是该状态"),
- PRODUCT_CATEGORY_DELETE_ONLY_DISABLE(1002001004, "只有关闭的商品分类才可以删除"),
- PRODUCT_CATEGORY_DELETE_ONLY_NO_CHILD(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 String getMessage() {
- return message;
- }
-
- @Override
- public int getGroup() {
- return 0;
- }
-
- @Override
- public int getCode() {
- return code;
- }
-}
diff --git a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/attr/ProductAttrConstants.java b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/attr/ProductAttrConstants.java
deleted file mode 100644
index b65aac0a1..000000000
--- a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/attr/ProductAttrConstants.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package cn.iocoder.mall.product.biz.enums.attr;
-
-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/category/ProductCategoryNodeEnum.java b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/category/ProductCategoryNodeEnum.java
deleted file mode 100644
index 9f32d1df7..000000000
--- a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/category/ProductCategoryNodeEnum.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package cn.iocoder.mall.product.biz.enums.category;
-
-import cn.iocoder.common.framework.core.IntArrayValuable;
-
-import java.util.Arrays;
-
-/**
- * @Author: jiangweifan
- * @Date: 2020/5/12
- * @Description: 商品分类节点枚举
- */
-public enum ProductCategoryNodeEnum{
-
- /**
- * 根节点
- */
- ROOT(0);
-
- private final Integer id;
-
- ProductCategoryNodeEnum(Integer id) {
- this.id = id;
- }
-
- public Integer getId() {
- return id;
- }
-}
diff --git a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/category/ProductCategoryStatusEnum.java b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/category/ProductCategoryStatusEnum.java
deleted file mode 100644
index f90d4670f..000000000
--- a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/category/ProductCategoryStatusEnum.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package cn.iocoder.mall.product.biz.enums.category;
-
-import cn.iocoder.common.framework.core.IntArrayValuable;
-
-import java.util.Arrays;
-
-/**
- * @Author: jiangweifan
- * @Date: 2020/5/12
- * @Description: 商品分类状态枚举
- */
-public enum ProductCategoryStatusEnum implements IntArrayValuable {
-
- ENABLED(1, "启用"),
- DISABLED(2, "禁用");
-
- public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductCategoryStatusEnum::getStatus).toArray();
-
- /**
- * 状态
- */
- private final Integer status;
- /**
- * 描述
- */
- private final String name;
-
- ProductCategoryStatusEnum(Integer status, String name) {
- this.status = status;
- this.name = name;
- }
-
- public Integer getStatus() {
- return status;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public int[] array() {
- return ARRAYS;
- }
-
-}
diff --git a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/spu/ProductSpuConstants.java b/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/spu/ProductSpuConstants.java
deleted file mode 100644
index 366545e81..000000000
--- a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/enums/spu/ProductSpuConstants.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package cn.iocoder.mall.product.biz.enums.spu;
-
-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
deleted file mode 100644
index d68b31026..000000000
--- a/product/product-biz-api/src/main/java/cn/iocoder/mall/product/biz/package-info.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/**
- * 该项目,主要用于暴露一些共享的枚举类等。
- *
- * 例如说,RPC 接口提供错误码给调用方
- */
-package cn.iocoder.mall.product.biz;
diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/category/ProductCategoryServiceImpl.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/category/ProductCategoryServiceImpl.java
index 16a0231f6..447f92d04 100644
--- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/category/ProductCategoryServiceImpl.java
+++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/category/ProductCategoryServiceImpl.java
@@ -39,118 +39,4 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
return ProductCategoryConvert.INSTANCE.convertToAllListBO(categoryList);
}
- @Override
- public ProductCategoryBO addProductCategory(ProductCategoryAddDTO productCategoryAddDTO) {
- // 校验父分类
- validParent(productCategoryAddDTO.getPid());
- // 保存到数据库
- ProductCategoryDO productCategory = ProductCategoryConvert.INSTANCE.convertToDO(productCategoryAddDTO)
- .setStatus(ProductCategoryStatusEnum.ENABLED.getStatus());
- productCategory.setCreateTime(new Date());
- productCategory.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
- productCategoryMapper.insert(productCategory);
- // TODO 伟帆 操作日志
- // 返回成功
- return ProductCategoryConvert.INSTANCE.convertToBO(productCategory);
- }
-
- @Override
- public Boolean updateProductCategory(ProductCategoryUpdateDTO productCategoryUpdateDTO) {
- // 校验当前分类是否存在
- if (productCategoryMapper.selectById(productCategoryUpdateDTO.getId()) == null) {
- throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS);
- }
- // 校验父分类
- validParent(productCategoryUpdateDTO.getPid());
- // 校验不能设置自己为父分类
- if (productCategoryUpdateDTO.getId().equals(productCategoryUpdateDTO.getPid())) {
- throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_PARENT_NOT_SELF);
- }
- // 校验父分类是否存在
- if (!ProductCategoryNodeEnum.ROOT.getId().equals(productCategoryUpdateDTO.getPid())
- && productCategoryMapper.selectById(productCategoryUpdateDTO.getPid()) == null) {
- throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_PARENT_NOT_EXISTS);
- }
- // 更新到数据库
- ProductCategoryDO updateProductCategory = ProductCategoryConvert.INSTANCE.convertToDO(productCategoryUpdateDTO);
- productCategoryMapper.updateById(updateProductCategory);
- // TODO 伟帆 操作日志
- return true;
- }
-
- @Override
- public Boolean updateProductCategoryStatus(ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO) {
- // 校验商品分类是否存在
- ProductCategoryDO productCategoryDO = productCategoryMapper.selectById(productCategoryUpdateStatusDTO.getId());
- if (productCategoryDO == null) {
- throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS);
- }
- // 判断更新状态是否存在
- if (Arrays.stream(ProductCategoryStatusEnum.ARRAYS).noneMatch(status -> status == productCategoryUpdateStatusDTO.getStatus())) {
- throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_STATUS_NOT_EXISTS);
- }
- // 如果状态相同,则返回错误
- if (productCategoryDO.getStatus().equals(productCategoryUpdateStatusDTO.getStatus())) {
- throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_STATUS_EQUALS);
- }
- // 更新商品分类状态
- ProductCategoryDO updateCategoryStatus = ProductCategoryConvert.INSTANCE.convertToDO(productCategoryUpdateStatusDTO);
- productCategoryMapper.updateById(updateCategoryStatus);
- // TODO 伟帆 操作日志
- return true;
- }
-
- @Override
- public Boolean deleteProductCategory(ProductCategoryDeleteDTO productCategoryDeleteDTO) {
- Integer productCategoryId = productCategoryDeleteDTO.getId();
- // 校验分类是否存在
- ProductCategoryDO productCategory = productCategoryMapper.selectById(productCategoryId);
- if (productCategory == null) {
- throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS);
- }
- // 只有禁用的商品分类才可以删除
- if (ProductCategoryStatusEnum.ENABLED.getStatus().equals(productCategory.getStatus())) {
- throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_DELETE_ONLY_DISABLE);
- }
- // 只有不存在子分类才可以删除
- // TODO FROM 芋艿 to jiangweifan:Wrappers 只用在 Mapper 层 [DONE]
- Integer childCount = productCategoryMapper.selectChildCategoryCount(productCategoryId);
- if (childCount > 0) {
- throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_DELETE_ONLY_NO_CHILD);
- }
- // TODO 伟帆 补充只有不存在商品才可以删除
- // 标记删除商品分类
- productCategoryMapper.deleteById(productCategoryId);
- // TODO 伟帆 操作日志
- return true;
- }
-
- private void validParent(Integer pid) {
- if (!ProductCategoryNodeEnum.ROOT.getId().equals(pid)) {
- ProductCategoryDO parentCategory = productCategoryMapper.selectById(pid);
- // 校验父分类是否存在
- if (parentCategory == null) {
- throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_PARENT_NOT_EXISTS);
- }
- // 父分类必须是一级分类
- if (!ProductCategoryNodeEnum.ROOT.getId().equals(parentCategory.getPid())) {
- throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_PARENT_CAN_NOT_BE_LEVEL2);
- }
- }
- }
-
- @Override
- public ProductCategoryDO validProductCategory(Integer productCategoryId) {
- // 校验分类是否存在
- ProductCategoryDO productCategory = productCategoryMapper.selectById(productCategoryId);
- if (productCategory == null) {
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_NOT_EXISTS.getCode());
- }
- // 只有禁用的商品分类才可以删除
- if (ProductCategoryStatusEnum.DISABLED.getStatus().equals(productCategory.getStatus())) {
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_MUST_ENABLE.getCode());
- }
- // 返回结果
- return productCategory;
- }
}
diff --git a/product/product-mq/pom.xml b/product/product-mq/pom.xml
deleted file mode 100644
index 857d7b9c4..000000000
--- a/product/product-mq/pom.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
- demo
- cn.iocoder.mall
- 1.0-SNAPSHOT
-
- 4.0.0
-
- product-mq
-
-
-
diff --git a/product/product-mq/src/main/java/cn/iocoder/mall/demo/mq/package-info.java b/product/product-mq/src/main/java/cn/iocoder/mall/demo/mq/package-info.java
deleted file mode 100644
index 8172d958c..000000000
--- a/product/product-mq/src/main/java/cn/iocoder/mall/demo/mq/package-info.java
+++ /dev/null
@@ -1 +0,0 @@
-package cn.iocoder.mall.demo.mq;
diff --git a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductCategoryServiceImpl.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductCategoryServiceImpl.java
deleted file mode 100644
index 1818194ef..000000000
--- a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductCategoryServiceImpl.java
+++ /dev/null
@@ -1,154 +0,0 @@
-package cn.iocoder.mall.product.service;
-
-import cn.iocoder.common.framework.util.ServiceExceptionUtil;
-import cn.iocoder.mall.mybatis.core.enums.DeletedStatusEnum;
-import cn.iocoder.mall.product.api.ProductCategoryService;
-import cn.iocoder.mall.product.api.bo.ProductCategoryBO;
-import cn.iocoder.mall.product.api.constant.ProductCategoryConstants;
-import cn.iocoder.mall.product.api.constant.ProductErrorCodeEnum;
-import cn.iocoder.mall.product.api.dto.ProductCategoryAddDTO;
-import cn.iocoder.mall.product.api.dto.ProductCategoryUpdateDTO;
-import cn.iocoder.mall.product.convert.ProductCategoryConvert;
-import cn.iocoder.mall.product.dao.ProductCategoryMapper;
-import cn.iocoder.mall.product.dataobject.ProductCategoryDO;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
-@Service // 实际上不用添加。添加的原因是,必须 Spring 报错提示
-@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.ProductCategoryService.version}")
-public class ProductCategoryServiceImpl implements ProductCategoryService {
-
- @Autowired
- private ProductCategoryMapper productCategoryMapper;
-
- @Override
- public List getListByPid(Integer pid) {
- List categoryList = productCategoryMapper.selectListByPidAndStatusOrderBySort(pid, ProductCategoryConstants.STATUS_ENABLE);
- return ProductCategoryConvert.INSTANCE.convertToBO(categoryList);
- }
-
- @Override
- public List getListByIds(Collection ids) {
- List categoryList = productCategoryMapper.selectByIds(ids);
- return ProductCategoryConvert.INSTANCE.convertToBO(categoryList);
- }
-
- @Override
- public List getAll() {
- List categoryList = productCategoryMapper.selectList();
- return ProductCategoryConvert.INSTANCE.convertToBO(categoryList);
- }
-
- @Override
- public ProductCategoryBO addProductCategory(Integer adminId, ProductCategoryAddDTO productCategoryAddDTO) {
- // 校验父分类
- validParent(productCategoryAddDTO.getPid());
- // 保存到数据库
- ProductCategoryDO productCategory = ProductCategoryConvert.INSTANCE.convert(productCategoryAddDTO)
- .setStatus(ProductCategoryConstants.STATUS_ENABLE);
- productCategory.setCreateTime(new Date());
- productCategory.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
- productCategoryMapper.insert(productCategory);
- // TODO 操作日志
- // 返回成功
- return ProductCategoryConvert.INSTANCE.convertToBO(productCategory);
- }
-
- @Override
- public Boolean updateProductCategory(Integer adminId, ProductCategoryUpdateDTO productCategoryUpdateDTO) {
- // 校验父分类
- validParent(productCategoryUpdateDTO.getPid());
- // 校验不能设置自己为父分类
- if (productCategoryUpdateDTO.getId().equals(productCategoryUpdateDTO.getPid())) {
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_NOT_SELF.getCode());
- }
- // 校验父分类是否存在
- if (!ProductCategoryConstants.PID_ROOT.equals(productCategoryUpdateDTO.getPid())
- && productCategoryMapper.selectById(productCategoryUpdateDTO.getPid()) == null) {
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_NOT_EXISTS.getCode());
- }
- // 更新到数据库
- ProductCategoryDO updateProductCategory = ProductCategoryConvert.INSTANCE.convert(productCategoryUpdateDTO);
- productCategoryMapper.update(updateProductCategory);
- // TODO 操作日志
- return true;
- }
-
- @Override
- public Boolean updateProductCategoryStatus(Integer adminId, Integer productCategoryId, Integer status) {
- // 校验分类是否存在
- ProductCategoryDO productCategory = productCategoryMapper.selectById(productCategoryId);
- if (productCategory == null) {
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_NOT_EXISTS.getCode());
- }
- // 如果状态相同,则返回错误
- if (productCategory.getStatus().equals(status)) {
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_STATUS_EQUALS.getCode());
- }
- // 更新商品分类
- ProductCategoryDO updateProductCategory = new ProductCategoryDO()
- .setId(productCategoryId).setStatus(status);
- productCategoryMapper.update(updateProductCategory);
- // TODO 操作日志
- return true;
- }
-
- @Override
- public Boolean deleteProductCategory(Integer admin, Integer productCategoryId) {
- // 校验分类是否存在
- ProductCategoryDO productCategory = productCategoryMapper.selectById(productCategoryId);
- if (productCategory == null) {
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_NOT_EXISTS.getCode());
- }
- // 只有禁用的商品分类才可以删除
- if (ProductCategoryConstants.STATUS_ENABLE.equals(productCategory.getStatus())) {
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_DELETE_ONLY_DISABLE.getCode());
- }
- // TODO 芋艿:考虑下,是否需要判断下该分类下是否有商品
- // TODO 芋艿,需要补充下,还有子分类
- // 标记删除商品分类
- ProductCategoryDO updateProductCategory = new ProductCategoryDO()
- .setId(productCategoryId);
- updateProductCategory.setDeleted(DeletedStatusEnum.DELETED_YES.getValue());
- productCategoryMapper.update(updateProductCategory);
- // TODO 操作日志
- return true;
- }
-
- public ProductCategoryDO getProductCategory(Integer productCategoryId) {
- return productCategoryMapper.selectById(productCategoryId);
- }
-
- public ProductCategoryDO validProductCategory(Integer productCategoryId) {
- // 校验分类是否存在
- ProductCategoryDO productCategory = productCategoryMapper.selectById(productCategoryId);
- if (productCategory == null) {
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_NOT_EXISTS.getCode());
- }
- // 只有禁用的商品分类才可以删除
- if (ProductCategoryConstants.STATUS_DISABLE.equals(productCategory.getStatus())) {
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_MUST_ENABLE.getCode());
- }
- // 返回结果
- return productCategory;
- }
-
- private void validParent(Integer pid) {
- if (!ProductCategoryConstants.PID_ROOT.equals(pid)) {
- ProductCategoryDO parentCategory = productCategoryMapper.selectById(pid);
- // 校验父分类是否存在
- if (parentCategory == null) {
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_NOT_EXISTS.getCode());
- }
- // 父分类必须是一级分类
- if (!ProductCategoryConstants.PID_ROOT.equals(parentCategory.getPid())) {
- throw ServiceExceptionUtil.exception((ProductErrorCodeEnum.PRODUCT_CATEGORY_PARENT_CAN_NOT_BE_LEVEL2.getCode()));
- }
- }
- }
-
-}
diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/permission/ResourceIdEnum.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/permission/ResourceIdEnum.java
index 3b48a3eb8..69ce57a37 100644
--- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/permission/ResourceIdEnum.java
+++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/permission/ResourceIdEnum.java
@@ -3,7 +3,7 @@ package cn.iocoder.mall.systemservice.enums.permission;
/**
* Resource 编号枚举
*/
-public enum ResourceIdEnum {
+public enum ResourceIdEnum {
/**
* 根节点
diff --git a/system-service-project/system-service-app/pom.xml b/system-service-project/system-service-app/pom.xml
index 740786b84..58dafdfc7 100644
--- a/system-service-project/system-service-app/pom.xml
+++ b/system-service-project/system-service-app/pom.xml
@@ -40,14 +40,6 @@
mysql-connector-java
-
- org.springframework
- spring-tx
-
-
- org.springframework
- spring-jdbc
-
com.alibaba
druid-spring-boot-starter
diff --git a/user-web-app/src/main/java/cn/iocoder/mall/userweb/controller/address/AddressController.http b/user-web-app/src/main/java/cn/iocoder/mall/userweb/controller/address/AddressController.http
new file mode 100644
index 000000000..440a895ef
--- /dev/null
+++ b/user-web-app/src/main/java/cn/iocoder/mall/userweb/controller/address/AddressController.http
@@ -0,0 +1,5 @@
+### /user-address/get-default 成功
+GET {{user-api-base-url}}/user-address/get-default
+Authorization: Bearer {{user-access-token}}
+
+###
diff --git a/user-web-app/src/main/java/cn/iocoder/mall/userweb/controller/address/UserAddressController.java b/user-web-app/src/main/java/cn/iocoder/mall/userweb/controller/address/UserAddressController.java
index d22d56210..f1ec7ab71 100644
--- a/user-web-app/src/main/java/cn/iocoder/mall/userweb/controller/address/UserAddressController.java
+++ b/user-web-app/src/main/java/cn/iocoder/mall/userweb/controller/address/UserAddressController.java
@@ -63,6 +63,13 @@ public class UserAddressController {
return success(userAddressManager.getUserAddress(UserSecurityContextHolder.getUserId(), userAddressId));
}
+ @GetMapping("/get-default")
+ @ApiOperation("获得默认的用户收件地址")
+ @RequiresPermissions
+ public CommonResult getDefaultUserAddress() {
+ return success(userAddressManager.getDefaultUserAddress(UserSecurityContextHolder.getUserId()));
+ }
+
@GetMapping("/list")
@ApiOperation("获得用户收件地址列表")
@RequiresPermissions
diff --git a/user-web-app/src/main/java/cn/iocoder/mall/userweb/manager/address/UserAddressManager.java b/user-web-app/src/main/java/cn/iocoder/mall/userweb/manager/address/UserAddressManager.java
index de5657c31..940bd1c76 100644
--- a/user-web-app/src/main/java/cn/iocoder/mall/userweb/manager/address/UserAddressManager.java
+++ b/user-web-app/src/main/java/cn/iocoder/mall/userweb/manager/address/UserAddressManager.java
@@ -1,7 +1,9 @@
package cn.iocoder.mall.userweb.manager.address;
import cn.iocoder.common.framework.exception.GlobalException;
+import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.vo.CommonResult;
+import cn.iocoder.mall.userservice.enums.address.UserAddressType;
import cn.iocoder.mall.userservice.rpc.address.UserAddressRpc;
import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressRespDTO;
import cn.iocoder.mall.userweb.controller.address.vo.UserAddressCreateReqVO;
@@ -48,7 +50,8 @@ public class UserAddressManager {
// 校验是否能够操作
check(userId, updateVO.getId());
// 执行更新
- CommonResult updateUserAddressResult = userAddressRpc.updateUserAddress(UserAddressConvert.INSTANCE.convert(updateVO));
+ CommonResult updateUserAddressResult = userAddressRpc.updateUserAddress(UserAddressConvert.INSTANCE.convert(updateVO)
+ .setUserId(userId));
updateUserAddressResult.checkError();
}
@@ -93,6 +96,19 @@ public class UserAddressManager {
return UserAddressConvert.INSTANCE.convertList(listUserAddressResult.getData());
}
+ /**
+ * 获得用户的默认收件地址
+ *
+ * @param userId 用户编号
+ * @return 用户收件地址
+ */
+ public UserAddressRespVO getDefaultUserAddress(Integer userId) {
+ CommonResult> listUserAddressResult = userAddressRpc.listUserAddresses(userId, UserAddressType.DEFAULT.getType());
+ listUserAddressResult.checkError();
+ return !CollectionUtils.isEmpty(listUserAddressResult.getData()) ?
+ UserAddressConvert.INSTANCE.convert(listUserAddressResult.getData().get(0)) : null;
+ }
+
/**
* 校验用户收件地址是不是属于该用户
*
diff --git a/user/user-rest/pom.xml b/user/user-rest/pom.xml
deleted file mode 100644
index 88bfd5d54..000000000
--- a/user/user-rest/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
- user
- cn.iocoder.mall
- 1.0-SNAPSHOT
-
- 4.0.0
-
- user-rest
-
-
-
-
- cn.iocoder.mall
- user-biz
- 1.0-SNAPSHOT
- compile
-
-
-
-
- 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/user/user-rest/src/main/java/cn/iocoder/mall/user/rest/controller/user/UsersUserAddressController.java b/user/user-rest/src/main/java/cn/iocoder/mall/user/rest/controller/user/UsersUserAddressController.java
deleted file mode 100644
index 65d19c730..000000000
--- a/user/user-rest/src/main/java/cn/iocoder/mall/user/rest/controller/user/UsersUserAddressController.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package cn.iocoder.mall.user.rest.controller.user;
-
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.security.core.context.UserSecurityContextHolder;
-import cn.iocoder.mall.user.biz.dto.user.UserAddressAddDTO;
-import cn.iocoder.mall.user.biz.dto.user.UserAddressUpdateDTO;
-import cn.iocoder.mall.user.biz.service.user.UserAddressService;
-import cn.iocoder.mall.user.rest.convert.UserAddressConvert;
-import cn.iocoder.mall.user.rest.request.user.UserAddressAddRequest;
-import cn.iocoder.mall.user.rest.request.user.UserAddressUpdateRequest;
-import cn.iocoder.mall.user.rest.response.user.UserAddressResponse;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import javax.validation.Valid;
-import java.util.List;
-
-/**
- * 用户地址(user API)
- *
- * author: sin
- * time: 2020/5/8 9:50
- */
-@RestController
-@Api(tags = "用户地址(user API)") // TODO FROM 芋艿 to 小范:"管理员 - 管理员 API" 按照类似酱紫的格式哈。= = 虽然我也没想太好格式。
-@RequestMapping("/users/user-address")
-public class UsersUserAddressController {
-
- @Autowired
- private UserAddressService userAddressService;
-
- @GetMapping("list-address")
- @ApiOperation("获取 - 地址列表(all)")
- public CommonResult> listAddress() {
- Integer userId = UserSecurityContextHolder.getContext().getUserId();
- return CommonResult.success(UserAddressConvert.INSTANCE.convert(userAddressService.listAddress(userId)));
- }
-
- @GetMapping("{addressId}")
- @ApiOperation("获取 - 根据id获取")
- public CommonResult getAddress(@PathVariable("addressId") Integer addressId) {
- return CommonResult.success(UserAddressConvert.INSTANCE.convert(userAddressService.getAddress(addressId)));
- }
-
- @GetMapping("default")
- @ApiOperation("获取 - 获取默认地址")
- public CommonResult getDefaultAddress() {
- Integer userId = UserSecurityContextHolder.getContext().getUserId();
- return CommonResult.success(UserAddressConvert.INSTANCE.convert(userAddressService.getDefaultAddress(userId)));
- }
-
- @DeleteMapping("/{addressId}/remove")
- @ApiOperation("删除 - 根据id删除")
- public CommonResult getDefaultAddress(@PathVariable("addressId") Integer addressId) {
- Integer userId = UserSecurityContextHolder.getContext().getUserId();
- userAddressService.removeAddress(userId, addressId);
- return CommonResult.success(null);
- }
-
- @PostMapping("/add-address")
- @ApiOperation("添加地址")
- public CommonResult addAddress(@RequestBody @Valid UserAddressAddRequest userAddressAddRequest) {
- Integer userId = UserSecurityContextHolder.getContext().getUserId();
- UserAddressAddDTO userAddressAddDTO = UserAddressConvert.INSTANCE.convert(userAddressAddRequest);
- userAddressAddDTO.setUserId(userId);
- userAddressService.addAddress(userAddressAddDTO);
- return CommonResult.success(null);
- }
-
- @PutMapping("/update-address")
- @ApiOperation("更新地址")
- public CommonResult updateAddress(@RequestBody @Valid UserAddressUpdateRequest userAddressAddRequest) {
- Integer userId = UserSecurityContextHolder.getContext().getUserId();
- UserAddressUpdateDTO userAddressAddDTO = UserAddressConvert.INSTANCE.convert(userAddressAddRequest);
- userAddressAddDTO.setUserId(userId);
- userAddressService.updateAddress(userAddressAddDTO);
- return CommonResult.success(null);
- }
-}
diff --git a/user/user-rest/src/main/java/cn/iocoder/mall/user/rest/request/user/UserAddressAddRequest.java b/user/user-rest/src/main/java/cn/iocoder/mall/user/rest/request/user/UserAddressAddRequest.java
deleted file mode 100644
index 05353b9f0..000000000
--- a/user/user-rest/src/main/java/cn/iocoder/mall/user/rest/request/user/UserAddressAddRequest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package cn.iocoder.mall.user.rest.request.user;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-import javax.validation.constraints.NotNull;
-import java.io.Serializable;
-
-/**
- * 用户地址 add
- *
- * @author Sin
- * @time 2019-04-06 13:25
- */
-@Data
-@Accessors(chain = true)
-@ApiModel("用户地址(添加)")
-public class UserAddressAddRequest implements Serializable {
-
- @NotNull
- @ApiModelProperty("收件区域编号")
- private String areaNo;
-
- @NotNull
- @ApiModelProperty("收件人名称")
- private String name;
-
- @NotNull
- @ApiModelProperty("收件手机号")
- private String mobile;
-
- @NotNull
- @ApiModelProperty("收件详细地址")
- private String address;
-
- @NotNull
- @ApiModelProperty("是否默认 1 不是 2 是")
- private Integer hasDefault;
-}
diff --git a/user/user-rest/src/main/java/cn/iocoder/mall/user/rest/request/user/UserAddressUpdateRequest.java b/user/user-rest/src/main/java/cn/iocoder/mall/user/rest/request/user/UserAddressUpdateRequest.java
deleted file mode 100644
index e443db1a7..000000000
--- a/user/user-rest/src/main/java/cn/iocoder/mall/user/rest/request/user/UserAddressUpdateRequest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package cn.iocoder.mall.user.rest.request.user;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-import javax.validation.constraints.NotNull;
-import java.io.Serializable;
-
-/**
- * 用户地址 更新
- *
- * @author Sin
- * @time 2019-04-06 13:28
- */
-@Data
-@Accessors(chain = true)
-@ApiModel("用户地址(更新)")
-public class UserAddressUpdateRequest implements Serializable {
-
- @NotNull
- @ApiModelProperty("编号")
- private Integer id;
-
- @NotNull
- @ApiModelProperty("收件区域编号")
- private String areaNo;
-
- @NotNull
- @ApiModelProperty("收件人名称")
- private String name;
-
- @NotNull
- @ApiModelProperty("收件手机号")
- private String mobile;
-
- @NotNull
- @ApiModelProperty("收件详细地址")
- private String address;
-
- @NotNull
- @ApiModelProperty("是否默认地址")
- private Integer hasDefault;
-}
diff --git a/user/user-rest/src/main/java/cn/iocoder/mall/user/rest/response/user/UserAddressResponse.java b/user/user-rest/src/main/java/cn/iocoder/mall/user/rest/response/user/UserAddressResponse.java
deleted file mode 100644
index 0de88b4cd..000000000
--- a/user/user-rest/src/main/java/cn/iocoder/mall/user/rest/response/user/UserAddressResponse.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package cn.iocoder.mall.user.rest.response.user;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-import java.io.Serializable;
-
-/**
- * 用户地址
- *
- * @author Sin
- * @time 2019-04-06 13:28
- */
-@Data
-@Accessors(chain = true)
-@ApiModel(value = "用户地址")
-public class UserAddressResponse implements Serializable {
-
- @ApiModelProperty("编号")
- private Integer id;
-
- @ApiModelProperty("用户编号")
- private Integer userId;
-
- @ApiModelProperty("收件区域编号")
- private String areaNo;
-
- @ApiModelProperty("收件人名称")
- private String name;
-
- @ApiModelProperty("收件手机号")
- private String mobile;
-
- @ApiModelProperty("收件详细地址")
- private String address;
-
- @ApiModelProperty("是否默认")
- private Integer hasDefault;
-}