diff --git a/common/mall-spring-boot-starter-rocketmq/pom.xml b/common/mall-spring-boot-starter-rocketmq/pom.xml
new file mode 100644
index 000000000..f5b6d52ac
--- /dev/null
+++ b/common/mall-spring-boot-starter-rocketmq/pom.xml
@@ -0,0 +1,22 @@
+
+
+
+ common
+ cn.iocoder.mall
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ mall-spring-boot-starter-rocketmq
+
+
+
+
+ org.apache.rocketmq
+ rocketmq-spring-boot-starter
+
+
+
+
diff --git a/common/pom.xml b/common/pom.xml
index 3161de94a..6a472828e 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -22,6 +22,7 @@
mall-spring-boot-starter-mybatis
mall-spring-boot-starter-dubbo
mall-spring-boot-starter-system-error-code
+ mall-spring-boot-starter-rocketmq
diff --git a/mall-dependencies/pom.xml b/mall-dependencies/pom.xml
index 64255fcc6..a2ff54112 100644
--- a/mall-dependencies/pom.xml
+++ b/mall-dependencies/pom.xml
@@ -42,6 +42,8 @@
3.2.5.RELEASE
2.7.7
+
+ 2.1.0
2.0.1
@@ -219,12 +221,25 @@
1.0-SNAPSHOT
-
+
cn.iocoder.mall
mall-spring-boot-starter-system-error-code
1.0-SNAPSHOT
+
+
+ org.apache.rocketmq
+ rocketmq-spring-boot-starter
+ ${rocketmq-spring-boot-starter.version}
+
+
+
+ cn.iocoder.mall
+ mall-spring-boot-starter-rocketmq
+ 1.0-SNAPSHOT
+
+
com.xuxueli
diff --git a/pom.xml b/pom.xml
index ad03db84f..7761ee9c3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,7 @@
onemall
1.0-SNAPSHOT
-
+ product
common
@@ -31,6 +31,7 @@
shop-web-app
product-service-project
promotion-service-project
+ search-service-project
pom
diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpc.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpc.java
new file mode 100644
index 000000000..89b20d488
--- /dev/null
+++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpc.java
@@ -0,0 +1,30 @@
+package cn.iocoder.mall.productservice.rpc.sku;
+
+import cn.iocoder.common.framework.vo.CommonResult;
+import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
+import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
+
+import java.util.List;
+
+/**
+ * 商品 SKU Rpc 接口
+ */
+public interface ProductSkuRpc {
+
+ /**
+ * 获得商品 SKU
+ *
+ * @param productSkuId 商品 SKU 编号
+ * @return 商品 SKU
+ */
+ CommonResult getProductSku(Integer productSkuId);
+
+ /**
+ * 获得商品 SKU 列表
+ *
+ * @param queryReqDTO 商品 SKU 列表的查询请求 DTO
+ * @return 商品 SKU 列表
+ */
+ CommonResult> listProductSkus(ProductSkuListQueryReqDTO queryReqDTO);
+
+}
diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/dto/ProductSkuListQueryReqDTO.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/dto/ProductSkuListQueryReqDTO.java
new file mode 100644
index 000000000..9243f8ecd
--- /dev/null
+++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/dto/ProductSkuListQueryReqDTO.java
@@ -0,0 +1,24 @@
+package cn.iocoder.mall.productservice.rpc.sku.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 商品 SKU 列表查询 DTO
+ */
+@Data
+@Accessors(chain = true)
+public class ProductSkuListQueryReqDTO implements Serializable {
+
+ /**
+ * 商品 SKU 编号
+ */
+ private Integer productSkuId;
+ /**
+ * 商品 SPU 编号
+ */
+ private Integer productSpuId;
+
+}
diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/dto/ProductSkuRespDTO.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/dto/ProductSkuRespDTO.java
new file mode 100644
index 000000000..a256e9099
--- /dev/null
+++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/dto/ProductSkuRespDTO.java
@@ -0,0 +1,50 @@
+package cn.iocoder.mall.productservice.rpc.sku.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 商品 SKU Response DTO
+ */
+@Data
+@Accessors(chain = true)
+public class ProductSkuRespDTO implements Serializable {
+
+ /**
+ * sku 编号
+ */
+ private Integer id;
+ /**
+ * 商品编号
+ */
+ private Integer spuId;
+ /**
+ * 状态
+ */
+ private Integer status;
+ /**
+ * 图片地址
+ */
+ private String picUrl;
+ /**
+ * 规格值编号数组
+ */
+ private List attrValueIds;
+ /**
+ * 价格,单位:分
+ */
+ private Integer price;
+ /**
+ * 库存数量
+ */
+ private Integer quantity;
+ /**
+ * 创建时间
+ */
+ private Date createTime;
+
+}
diff --git a/product-service-project/product-service-app/pom.xml b/product-service-project/product-service-app/pom.xml
index 4fcc517cb..5a91e83a9 100644
--- a/product-service-project/product-service-app/pom.xml
+++ b/product-service-project/product-service-app/pom.xml
@@ -30,6 +30,12 @@
product-service-api
+
+
+ cn.iocoder.mall
+ mall-spring-boot-starter-rocketmq
+
+
com.alibaba.cloud
@@ -72,6 +78,11 @@
mapstruct-jdk8
+
+ org.aspectj
+ aspectjweaver
+ 1.9.6
+
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/config/AopConfiguration.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/config/AopConfiguration.java
new file mode 100644
index 000000000..8de5329ef
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/config/AopConfiguration.java
@@ -0,0 +1,12 @@
+package cn.iocoder.mall.productservice.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+
+/**
+ * Spring Aop 配置类
+ */
+@Configuration
+@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
+public class AopConfiguration {
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/sku/ProductSkuConvert.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/sku/ProductSkuConvert.java
index 94f2225fc..2d3848cb2 100644
--- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/sku/ProductSkuConvert.java
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/sku/ProductSkuConvert.java
@@ -1,8 +1,12 @@
package cn.iocoder.mall.productservice.convert.sku;
import cn.iocoder.common.framework.util.StringUtils;
-import cn.iocoder.mall.productservice.dal.mysql.dataobject.spu.ProductSkuDO;
+import cn.iocoder.mall.productservice.dal.mysql.dataobject.sku.ProductSkuDO;
+import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
+import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
+import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuBO;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuCreateOrUpdateBO;
+import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuListQueryBO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
@@ -18,7 +22,18 @@ public interface ProductSkuConvert {
List convertList(List list);
@Mapping(source = "attrValueIds", target = "attrs", qualifiedByName = "translatePicUrlsFromStringList")
- ProductSkuDO convert(ProductSkuCreateOrUpdateBO skuUpdateDTO);
+ ProductSkuDO convert(ProductSkuCreateOrUpdateBO bean);
+
+ @Mapping(source = "attrs", target = "attrValueIds", qualifiedByName = "translateAttrValueIdsFromString")
+ ProductSkuBO convert(ProductSkuDO bean);
+
+ List convertList02(List list);
+
+ ProductSkuRespDTO convert(ProductSkuBO bean);
+
+ ProductSkuListQueryBO convert(ProductSkuListQueryReqDTO bean);
+
+ List convertList03(List list);
@Named("translateAttrValueIdsFromString")
default List translateAttrValueIdsFromString(String attrValueIdsStar) {
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/spu/ProductSkuDO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/sku/ProductSkuDO.java
similarity index 95%
rename from product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/spu/ProductSkuDO.java
rename to product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/sku/ProductSkuDO.java
index b7c61e3c2..a0f2f31e3 100644
--- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/spu/ProductSkuDO.java
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/sku/ProductSkuDO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.mall.productservice.dal.mysql.dataobject.spu;
+package cn.iocoder.mall.productservice.dal.mysql.dataobject.sku;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/sku/ProductSkuMapper.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/sku/ProductSkuMapper.java
index fe3edbc7d..356251c09 100644
--- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/sku/ProductSkuMapper.java
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/sku/ProductSkuMapper.java
@@ -1,7 +1,8 @@
package cn.iocoder.mall.productservice.dal.mysql.mapper.sku;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
-import cn.iocoder.mall.productservice.dal.mysql.dataobject.spu.ProductSkuDO;
+import cn.iocoder.mall.productservice.dal.mysql.dataobject.sku.ProductSkuDO;
+import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuListQueryBO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@@ -18,4 +19,9 @@ public interface ProductSkuMapper extends BaseMapper {
void insertList(@Param("productSkuDOs") List productSkuDOs);
+ default List selectList(ProductSkuListQueryBO queryBO) {
+ return selectList(new QueryWrapperX().eqIfPresent("id", queryBO.getProductSkuId())
+ .eqIfPresent("spu_id", queryBO.getProductSpuId()));
+ }
+
}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/manager/sku/ProductSkuManager.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/manager/sku/ProductSkuManager.java
new file mode 100644
index 000000000..a262370df
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/manager/sku/ProductSkuManager.java
@@ -0,0 +1,45 @@
+package cn.iocoder.mall.productservice.manager.sku;
+
+import cn.iocoder.mall.productservice.convert.sku.ProductSkuConvert;
+import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
+import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
+import cn.iocoder.mall.productservice.service.sku.ProductSkuService;
+import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuBO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 商品 SKU Manager
+ */
+@Service
+public class ProductSkuManager {
+
+ @Autowired
+ private ProductSkuService productSkuService;
+
+ /**
+ * 获得商品 SKU
+ *
+ * @param productSkuId 商品 SKU编号
+ * @return 商品 SKU
+ */
+ public ProductSkuRespDTO getProductSku(Integer productSkuId) {
+ ProductSkuBO productSkuBO = productSkuService.getProductSku(productSkuId);
+ return ProductSkuConvert.INSTANCE.convert(productSkuBO);
+ }
+
+ /**
+ * 获得商品 SKU 列表
+ *
+ * @param queryReqDTO 商品 SKU 列表的查询请求 DTO
+ * @return 商品 SKU列表
+ */
+ public List listProductSkus(ProductSkuListQueryReqDTO queryReqDTO) {
+ List productSkuBOs = productSkuService.listProductSkus(
+ ProductSkuConvert.INSTANCE.convert(queryReqDTO));
+ return ProductSkuConvert.INSTANCE.convertList03(productSkuBOs);
+ }
+
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/manager/spu/ProductSpuManager.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/manager/spu/ProductSpuManager.java
index dec14d2b2..a15928150 100644
--- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/manager/spu/ProductSpuManager.java
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/manager/spu/ProductSpuManager.java
@@ -4,6 +4,7 @@ import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.convert.spu.ProductSpuConvert;
import cn.iocoder.mall.productservice.enums.category.ProductCategoryIdEnum;
+import cn.iocoder.mall.productservice.mq.producer.ProductMQProducer;
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuAndSkuCreateReqDTO;
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuAndSkuUpdateReqDTO;
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuPageReqDTO;
@@ -18,6 +19,7 @@ import cn.iocoder.mall.productservice.service.spu.ProductSpuService;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuBO;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuCreateBO;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuUpdateBO;
+import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -42,14 +44,25 @@ public class ProductSpuManager {
@Autowired
private ProductAttrService productAttrService;
+ @Autowired
+ private ProductMQProducer productMQProducer;
+
/**
* 创建商品 SPU 和 SKU
*
* @param createDTO 创建商品 SPU 和 SKU DTO
* @return 商品 SPU
*/
- @Transactional
public Integer createProductSpu(ProductSpuAndSkuCreateReqDTO createDTO) {
+ // 创建商品 SPU 和 SKU。注意,这里要调用 self() 方法,因为需要创建事务,否则会失效
+ Integer spuId = self().createProductSpu0(createDTO);
+ // 发送商品创建的 MQ 消息
+ productMQProducer.sendProductUpdateMessage(spuId);
+ return spuId;
+ }
+
+ @Transactional
+ public Integer createProductSpu0(ProductSpuAndSkuCreateReqDTO createDTO) {
// 校验商品分类是否合法
this.checkProductCategory(createDTO.getCid());
// 创建商品 SKU 对象,并进行校验
@@ -71,6 +84,14 @@ public class ProductSpuManager {
* @param updateDTO 更新商品 SPU DTO
*/
public void updateProductSpu(ProductSpuAndSkuUpdateReqDTO updateDTO) {
+ // 更新商品 SPU 和 SKU。注意,这里要调用 self() 方法,因为需要创建事务,否则会失效
+ self().updateProductSpu0(updateDTO);
+ // 发送商品创建的 MQ 消息
+ productMQProducer.sendProductUpdateMessage(updateDTO.getId());
+ }
+
+ @Transactional
+ public void updateProductSpu0(ProductSpuAndSkuUpdateReqDTO updateDTO) {
// 校验商品分类是否合法
this.checkProductCategory(updateDTO.getCid());
// 创建商品 SKU 对象,并进行校验
@@ -171,4 +192,8 @@ public class ProductSpuManager {
return attrKeyValueBOs;
}
+ private ProductSpuManager self() {
+ return (ProductSpuManager) AopContext.currentProxy();
+ }
+
}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/mq/producer/ProductMQProducer.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/mq/producer/ProductMQProducer.java
new file mode 100644
index 000000000..9eb8805ef
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/mq/producer/ProductMQProducer.java
@@ -0,0 +1,30 @@
+package cn.iocoder.mall.productservice.mq.producer;
+
+import cn.iocoder.mall.productservice.mq.producer.message.ProductUpdateMessage;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.client.producer.SendStatus;
+import org.apache.rocketmq.spring.core.RocketMQTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+@Slf4j
+public class ProductMQProducer {
+
+ @Autowired
+ private RocketMQTemplate rocketMQTemplate;
+
+ public void sendProductUpdateMessage(Integer id) {
+ // TODO 芋艿:后续优化下,考虑下一致性
+ try {
+ SendResult sendResult = rocketMQTemplate.syncSend(ProductUpdateMessage.TOPIC, new ProductUpdateMessage().setId(id));
+ if (!SendStatus.SEND_OK.equals(sendResult.getSendStatus())) {
+ log.error("[sendProductUpdateMessage][product({}) 发送更新消息失败,结果为({})]", id, sendResult);
+ }
+ } catch (Throwable throwable) {
+ log.error("[sendProductUpdateMessage][product({}) 发送更新消息失败,发生异常]", id, throwable);
+ }
+ }
+
+}
diff --git a/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/message/ProductUpdateMessage.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/mq/producer/message/ProductUpdateMessage.java
similarity index 83%
rename from product/product-service-api/src/main/java/cn/iocoder/mall/product/api/message/ProductUpdateMessage.java
rename to product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/mq/producer/message/ProductUpdateMessage.java
index 27fce3bbb..8a40d5c0f 100644
--- a/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/message/ProductUpdateMessage.java
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/mq/producer/message/ProductUpdateMessage.java
@@ -1,4 +1,4 @@
-package cn.iocoder.mall.product.api.message;
+package cn.iocoder.mall.productservice.mq.producer.message;
import lombok.Data;
import lombok.experimental.Accessors;
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpcImpl.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpcImpl.java
new file mode 100644
index 000000000..0528b5d63
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpcImpl.java
@@ -0,0 +1,33 @@
+package cn.iocoder.mall.productservice.rpc.sku;
+
+import cn.iocoder.common.framework.vo.CommonResult;
+import cn.iocoder.mall.productservice.manager.sku.ProductSkuManager;
+import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
+import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+
+import static cn.iocoder.common.framework.vo.CommonResult.success;
+
+/**
+ * 商品 SKU Rpc 实现类
+ */
+@DubboService
+public class ProductSkuRpcImpl implements ProductSkuRpc {
+
+ @Autowired
+ private ProductSkuManager productSkuManager;
+
+ @Override
+ public CommonResult getProductSku(Integer productSkuId) {
+ return success(productSkuManager.getProductSku(productSkuId));
+ }
+
+ @Override
+ public CommonResult> listProductSkus(ProductSkuListQueryReqDTO queryReqDTO) {
+ return success(productSkuManager.listProductSkus(queryReqDTO));
+ }
+
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/sku/ProductSkuService.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/sku/ProductSkuService.java
index 5040fc414..36e08183d 100644
--- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/sku/ProductSkuService.java
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/sku/ProductSkuService.java
@@ -4,9 +4,11 @@ import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.util.StringUtils;
import cn.iocoder.mall.productservice.convert.sku.ProductSkuConvert;
-import cn.iocoder.mall.productservice.dal.mysql.dataobject.spu.ProductSkuDO;
+import cn.iocoder.mall.productservice.dal.mysql.dataobject.sku.ProductSkuDO;
import cn.iocoder.mall.productservice.dal.mysql.mapper.sku.ProductSkuMapper;
+import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuBO;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuCreateOrUpdateBO;
+import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuListQueryBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -88,4 +90,27 @@ public class ProductSkuService {
return null;
}
+ /**
+ * 获得商品 SKU
+ *
+ * @param productSkuId 商品 SKU 编号
+ * @return 商品 SKU
+ */
+ public ProductSkuBO getProductSku(Integer productSkuId) {
+ ProductSkuDO productSkuDO = productSkuMapper.selectById(productSkuId);
+ return ProductSkuConvert.INSTANCE.convert(productSkuDO);
+ }
+
+ /**
+ * 获得商品 SKU 列表
+ *
+ * @param queryBO 商品 SKU 列表查询条件 BO
+ * @return 商品 SKU 列表
+ */
+ public List listProductSkus(ProductSkuListQueryBO queryBO) {
+ // TODO FROM 芋艿:可能要考虑下,是不是要必须传递条件
+ List productSkuDOs = productSkuMapper.selectList(queryBO);
+ return ProductSkuConvert.INSTANCE.convertList02(productSkuDOs);
+ }
+
}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/sku/bo/ProductSkuBO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/sku/bo/ProductSkuBO.java
new file mode 100644
index 000000000..f934f964f
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/sku/bo/ProductSkuBO.java
@@ -0,0 +1,62 @@
+package cn.iocoder.mall.productservice.service.sku.bo;
+
+import cn.iocoder.mall.productservice.dal.mysql.dataobject.attr.ProductAttrValueDO;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+ * 商品 SKU BO
+ */
+@Data
+@Accessors(chain = true)
+public class ProductSkuBO {
+
+ /**
+ * sku 编号
+ */
+ private Integer id;
+ /**
+ * 商品编号
+ */
+ private Integer spuId;
+ /**
+ * 状态
+ *
+ * 1-正常
+ * 2-禁用
+ */
+ private Integer status;
+ /**
+ * 图片地址
+ */
+ private String picUrl;
+ /**
+ * 规格值({@link ProductAttrValueDO})数组
+ *
+ * 数组,以逗号分隔
+ */
+ private String attrs;
+ /**
+ * 价格,单位:分
+ */
+ private Integer price;
+ /**
+ * 库存数量
+ */
+ private Integer quantity;
+ /**
+ * 创建时间
+ */
+ private Date createTime;
+ /**
+ * 最后更新时间
+ */
+ private Date updateTime;
+ /**
+ * 是否删除
+ */
+ private Integer deleted;
+
+}
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/sku/bo/ProductSkuCreateOrUpdateBO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/sku/bo/ProductSkuCreateOrUpdateBO.java
index c6b3097fc..7a6c7edbe 100644
--- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/sku/bo/ProductSkuCreateOrUpdateBO.java
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/sku/bo/ProductSkuCreateOrUpdateBO.java
@@ -10,7 +10,7 @@ import java.util.List;
/**
* 商品 SKU 创建或者修改 BO
*
- * 注意,目前该对象是
+ * 注意,目前该对象是搭配 {@link}
*/
@Data
@Accessors(chain = true)
diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/sku/bo/ProductSkuListQueryBO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/sku/bo/ProductSkuListQueryBO.java
new file mode 100644
index 000000000..6c59211d5
--- /dev/null
+++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/sku/bo/ProductSkuListQueryBO.java
@@ -0,0 +1,22 @@
+package cn.iocoder.mall.productservice.service.sku.bo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 商品 SKU 列表查询 BO
+ */
+@Data
+@Accessors(chain = true)
+public class ProductSkuListQueryBO {
+
+ /**
+ * 商品 SKU 编号
+ */
+ private Integer productSkuId;
+ /**
+ * 商品 SPU 编号
+ */
+ private Integer productSpuId;
+
+}
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
index aed565dff..3caf2f162 100644
--- a/product-service-project/product-service-app/src/main/resources/application.yaml
+++ b/product-service-project/product-service-app/src/main/resources/application.yaml
@@ -40,6 +40,12 @@ dubbo:
ErrorCodeRpc:
version: 1.0.0
+# RocketMQ 配置项
+rocketmq:
+ name-server: 400-infra.server.iocoder.cn:9876
+ producer:
+ group: ${spring.application.name}-producer-group
+
# Mall 配置项
mall:
# 错误码配置项对应 ErrorCodeProperties 配置类
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
deleted file mode 100644
index 50600fa6c..000000000
--- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrValueBO.java
+++ /dev/null
@@ -1,37 +0,0 @@
-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 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/dto/attr/ProductAttrAddDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/attr/ProductAttrAddDTO.java
deleted file mode 100644
index ed3a64596..000000000
--- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/attr/ProductAttrAddDTO.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package cn.iocoder.mall.product.biz.dto.attr;
-
-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/attr/ProductAttrPageDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/attr/ProductAttrPageDTO.java
deleted file mode 100644
index e6d23c62a..000000000
--- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/attr/ProductAttrPageDTO.java
+++ /dev/null
@@ -1,19 +0,0 @@
-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 ProductAttrPageDTO extends PageParam {
- /**
- * 商品规格名字
- */
- private String name;
-}
diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/attr/ProductAttrUpdateDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/attr/ProductAttrUpdateDTO.java
deleted file mode 100644
index 13fa35a18..000000000
--- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/attr/ProductAttrUpdateDTO.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package cn.iocoder.mall.product.biz.dto.attr;
-
-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/attr/ProductAttrValueAddDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/attr/ProductAttrValueAddDTO.java
deleted file mode 100644
index aea837d1a..000000000
--- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/attr/ProductAttrValueAddDTO.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package cn.iocoder.mall.product.biz.dto.attr;
-
-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/attr/ProductAttrValueUpdateDTO.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/attr/ProductAttrValueUpdateDTO.java
deleted file mode 100644
index 8b5997772..000000000
--- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dto/attr/ProductAttrValueUpdateDTO.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package cn.iocoder.mall.product.biz.dto.attr;
-
-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/message/MQStreamProducer.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/message/MQStreamProducer.java
deleted file mode 100644
index f6175be9c..000000000
--- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/message/MQStreamProducer.java
+++ /dev/null
@@ -1,27 +0,0 @@
-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
deleted file mode 100644
index e1f915643..000000000
--- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/message/UserProductSpuCollectionsConsumer.java
+++ /dev/null
@@ -1,109 +0,0 @@
-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/attr/ProductAttrService.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/attr/ProductAttrService.java
index a2c965f8e..437e35a57 100644
--- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/attr/ProductAttrService.java
+++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/attr/ProductAttrService.java
@@ -1,26 +1,10 @@
package cn.iocoder.mall.product.biz.service.attr;
-import cn.iocoder.common.framework.enums.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.attr.ProductAttrSimpleWithValueBO;
-import cn.iocoder.mall.product.biz.bo.attr.ProductAttrValueBO;
-import cn.iocoder.mall.product.biz.bo.attr.ProductAttrWithValueBO;
-import cn.iocoder.mall.product.biz.bo.product.ProductAttrAndValuePairBO;
-import cn.iocoder.mall.product.biz.dto.attr.*;
import java.util.List;
-import java.util.Set;
public interface ProductAttrService {
- /**
- * 获取规格分页数据
- *
- * @param productAttrPageDTO 查询参数
- * @return 规格分页信息
- */
- PageResult getProductAttrPage(ProductAttrPageDTO productAttrPageDTO);
/**
* 获得规格属性数组
@@ -31,40 +15,4 @@ public interface ProductAttrService {
*/
List getProductAttrList();
- /**
- * 添加商品规格
- *
- * @param adminId 操作人ID
- * @param productAttrAddDTO 添加参数
- * @return 添加的规格
- */
- ProductAttrBO addProductAttr(Integer adminId, ProductAttrAddDTO productAttrAddDTO);
-
- /**
- * 更新规格
- *
- * @param adminId 操作人
- * @param productAttrUpdateDTO 更新规格
- * @return 成功标识
- */
- Boolean updateProductAttr(Integer adminId, ProductAttrUpdateDTO productAttrUpdateDTO);
-
- /**
- * 更新规格状态
- *
- * @param adminId 操作人
- * @param productAttrId 规格ID
- * @param status 状态
- * @return 成功标识
- */
- Boolean updateProductAttrStatus(Integer adminId, Integer productAttrId, 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);
-
- List validProductAttrAndValue(Set productAttrValueIds, boolean validStatus);
}
diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/attr/ProductAttrServiceImpl.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/attr/ProductAttrServiceImpl.java
index ec75c8f69..77c7af0c3 100644
--- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/attr/ProductAttrServiceImpl.java
+++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/attr/ProductAttrServiceImpl.java
@@ -37,34 +37,6 @@ import java.util.stream.Collectors;
@Service
public class ProductAttrServiceImpl implements ProductAttrService {
- @Autowired
- private ProductAttrMapper productAttrMapper;
- @Autowired
- private ProductAttrValueMapper productAttrValueMapper;
-
- @Override
- public PageResult getProductAttrPage(ProductAttrPageDTO 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 (ProductAttrWithValueBO item : productAttrPage.getList()) {
- item.setValues(ProductAttrConvert.INSTANCE.convertAttrValues(attrValueMap.get(item.getId())));
- }
- }
- return productAttrPage;
- }
-
@Override
public List getProductAttrList() {
// 查询所有开启的规格数组
@@ -87,157 +59,4 @@ public class ProductAttrServiceImpl implements ProductAttrService {
return attrs;
}
- @Override
- public ProductAttrBO 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 = new ProductAttrDO().setName(productAttrAddDTO.getName())
- .setStatus(ProductAttrConstants.ATTR_STATUS_ENABLE);
- productAttrDO.setCreateTime(new Date());
- productAttrDO.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
- productAttrMapper.insert(productAttrDO);
- // 返回成功
- return ProductAttrConvert.INSTANCE.convertAttr(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 = ProductAttrConvert.INSTANCE.convertUpdate(productAttrUpdateDTO);
- updateProductAttr.setUpdateTime(new Date());
- int i = productAttrMapper.updateById(updateProductAttr);
- // 返回成功
- return i > 0;
- }
-
-
- @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);
- int i = productAttrMapper.updateById(updateProductAttr);
- return i > 0;
- }
-
- @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 = ProductAttrConvert.INSTANCE.convertValueAdd(productAttrValueAddDTO)
- .setStatus(ProductAttrConstants.ATTR_VALUE_STATUS_ENABLE);
- productAttrValueDO.setCreateTime(new Date());
- productAttrValueDO.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
- productAttrValueMapper.insert(productAttrValueDO);
- return ProductAttrConvert.INSTANCE.convertAttrValue(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 = ProductAttrConvert.INSTANCE.convertValueUpdate(productAttrValueUpdateDTO);
- updateProductValue.setUpdateTime(new Date());
- int i = productAttrValueMapper.updateById(updateProductValue);
- return i > 0;
- }
-
- @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);
- int i = productAttrValueMapper.updateById(updateProductAttrValue);
- return i > 0;
- }
-
- @Override
- 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());
- }
-
}
diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/spu/ProductSpuServiceImpl.java b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/spu/ProductSpuServiceImpl.java
index 006aff641..38c9c9ee8 100644
--- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/spu/ProductSpuServiceImpl.java
+++ b/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/service/spu/ProductSpuServiceImpl.java
@@ -62,109 +62,4 @@ public class ProductSpuServiceImpl implements ProductSpuService {
return ProductSpuConvert.INSTANCE.convert2(spu, skus, attrAndValuePairList, category);
}
- public ProductSpuDetailBO addProductSpu(Integer adminId, ProductSpuAddDTO productSpuAddDTO) {
- ProductSpuDetailBO productSpuDetailBO = addProductSpu0(adminId, productSpuAddDTO);
- // 如果新增生成,发送创建商品 Topic 消息
- // TODO 芋艿,先不考虑事务的问题。等后面的 fescar 一起搞
-// sendProductUpdateMessage(productSpuDetailBO.getId());
- // 返回成功
- return productSpuDetailBO;
- }
-
- @SuppressWarnings("Duplicates")
- @Transactional
- public ProductSpuDetailBO addProductSpu0(Integer adminId, ProductSpuAddDTO productSpuAddDTO) {
- // 校验商品分类分类存在
- ProductCategoryDO category = productCategoryService.validProductCategory(productSpuAddDTO.getCid());
- if (ProductCategoryNodeEnum.ROOT.getId().equals(category.getPid())) {
- // 商品只能添加到二级分类下
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_SPU_CATEGORY_MUST_BE_LEVEL2.getCode());
- }
- // 校验规格是否存在
- Set productAttrValueIds = new HashSet<>();
- productSpuAddDTO.getSkus().forEach(productSkuAddDTO -> productAttrValueIds.addAll(productSkuAddDTO.getAttrs()));
- // 读取规格时,需要考虑规格是否被禁用
- List attrAndValuePairList = productAttrService.validProductAttrAndValue(productAttrValueIds, true);
- // 保存 Spu
- ProductSpuDO spu = ProductSpuConvert.INSTANCE.convertToSpuDO(productSpuAddDTO)
- .setPicUrls(StringUtil.join(productSpuAddDTO.getPicUrls(), ","))
- .setSort(0); // 排序为 0
- spu.setCreateTime(new Date());
- spu.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
- // 初始化 sku 相关信息到 spu 中
- initSpuFromSkus(spu, productSpuAddDTO.getSkus());
- productSpuMapper.insert(spu);
- // 保存 Sku
- List skus = productSpuAddDTO.getSkus().stream().map(productSkuAddDTO -> {
- ProductSkuDO sku = ProductSpuConvert.INSTANCE.convertToSkuDO(productSkuAddDTO)
- .setSpuId(spu.getId())
- .setStatus(ProductSpuConstants.SKU_STATUS_ENABLE)
- .setAttrs(StringUtil.join(productSkuAddDTO.getAttrs(), ","));
- sku.setCreateTime(new Date());
- sku.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
- return sku;
- }).collect(Collectors.toList());
- // 校验 Sku 规格
- validProductSku(productSpuAddDTO.getSkus(), attrAndValuePairList);
- // 插入 SKU 到数据库
- productSkuMapper.insertList(skus);
- // 返回成功
- return ProductSpuConvert.INSTANCE.convert2(spu, skus, attrAndValuePairList, category);
- }
-
- /**
- * 根据 sku 数组,计算相关的字段到 spu 中。
- *
- * @param spu spu
- * @param skus sku 数组
- */
- private void initSpuFromSkus(ProductSpuDO spu, List skus) {
- assert skus.size() > 0; // 写个断言,避免下面警告
- spu.setPrice(skus.stream().min(Comparator.comparing(ProductSkuAddOrUpdateDTO::getPrice)).get().getPrice()); // 求最小价格
- spu.setQuantity(skus.stream().mapToInt(ProductSkuAddOrUpdateDTO::getQuantity).sum()); // 求库存之和
- }
-
-// private boolean sendProductUpdateMessage(Integer id) {
-// // 创建 Message 对象
-// ProductUpdateMessage message = new ProductUpdateMessage().setId(id);
-// // 创建 Spring Message 对象
-// Message springMessage = MessageBuilder.withPayload(message)
-// .build();
-// // 发送消息
-// return mqStreamProducer.productUpdateOutput().send(springMessage);
-// }
-
- /**
- * 校验 sku 是否合法
- *
- * @param productSkuAddDTOs sku 添加或修改信息
- * @param productAttrDetailBOs 商品规格明细数组
- */
- private void validProductSku(List productSkuAddDTOs, List productAttrDetailBOs) {
- // 创建 ProductAttrDetailBO 的映射。其中,KEY 为 ProductAttrDetailBO.attrValueId ,即规格值的编号
- Map productAttrDetailBOMap = productAttrDetailBOs.stream().collect(
- Collectors.toMap(ProductAttrAndValuePairBO::getAttrValueId, productAttrDetailBO -> productAttrDetailBO));
- // 1. 先校验,一个 Sku 下,没有重复的规格。校验方式是,遍历每个 Sku ,看看是否有重复的规格 attrId
- for (ProductSkuAddOrUpdateDTO sku : productSkuAddDTOs) {
- Set attrIds = sku.getAttrs().stream().map(attrValueId -> productAttrDetailBOMap.get(attrValueId).getAttrId())
- .collect(Collectors.toSet());
- if (attrIds.size() != sku.getAttrs().size()) {
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_SKU_ATTR_CANT_NOT_DUPLICATE.getCode());
- }
- }
- // 2. 再校验,每个 Sku 的规格值的数量,是一致的。
- int attrSize = productSkuAddDTOs.get(0).getAttrs().size();
- for (int i = 1; i < productSkuAddDTOs.size(); i++) {
- if (attrSize != productSkuAddDTOs.get(i).getAttrs().size()) {
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_SPU_ATTR_NUMBERS_MUST_BE_EQUALS.getCode());
- }
- }
- // 3. 最后校验,每个 Sku 之间不是重复的
- Set> skuAttrValues = new HashSet<>(); // 每个元素,都是一个 Sku 的 attrValueId 集合。这样,通过最外层的 Set ,判断是否有重复的.
- for (ProductSkuAddOrUpdateDTO sku : productSkuAddDTOs) {
- if (!skuAttrValues.add(new HashSet<>(sku.getAttrs()))) { // 添加失败,说明重复
- throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_SPU_SKU__NOT_DUPLICATE.getCode());
- }
- }
- }
}
diff --git a/product/product-biz/src/main/resources/biz.properties b/product/product-biz/src/main/resources/biz.properties
deleted file mode 100644
index 9275a3bfb..000000000
--- a/product/product-biz/src/main/resources/biz.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-##################### 业务模块 #####################
-
diff --git a/product/product-biz/src/main/resources/biz.yaml b/product/product-biz/src/main/resources/biz.yaml
deleted file mode 100644
index f2aa6a7b5..000000000
--- a/product/product-biz/src/main/resources/biz.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-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/ProductSkuMapper.xml b/product/product-biz/src/main/resources/mapper/ProductSkuMapper.xml
deleted file mode 100644
index 8ce298bcd..000000000
--- a/product/product-biz/src/main/resources/mapper/ProductSkuMapper.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
- INSERT INTO product_sku (
- spu_id, status, pic_url, attrs, price,
- quantity, deleted, create_time
- ) VALUES
-
- (#{productSkuDO.spuId}, #{productSkuDO.status}, #{productSkuDO.picUrl}, #{productSkuDO.attrs}, #{productSkuDO.price},
- #{productSkuDO.quantity}, #{productSkuDO.deleted}, #{productSkuDO.createTime}
- )
-
-
-
-
-
diff --git a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/attr/AdminsProductAttrController.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/attr/AdminsProductAttrController.java
index ce06cba69..e2b537b37 100644
--- a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/attr/AdminsProductAttrController.java
+++ b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/attr/AdminsProductAttrController.java
@@ -43,15 +43,6 @@ public class AdminsProductAttrController {
@Autowired
private ProductAttrService productAttrService;
- @GetMapping("/attr/page")
- @ApiOperation("获得规格分页")
- public CommonResult> attrPage(ProductAttrPageRequest request) {
- ProductAttrPageDTO 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() {
@@ -60,76 +51,4 @@ public class AdminsProductAttrController {
return CommonResult.success(ProductAttrConvert.INSTANCE.convertSimple(result));
}
- @PostMapping("/attr/add")
- @ApiOperation(value = "创建商品规格")
- public CommonResult addAttr(@Validated ProductAttrAddRequest addRequest) {
- // 创建 ProductAttrAddDTO 对象
- ProductAttrAddDTO productAttrAddDTO = new ProductAttrAddDTO().setName(addRequest.getName());
- // 添加
- ProductAttrBO result = productAttrService.addProductAttr(AdminSecurityContextHolder.getContext().getAdminId(), productAttrAddDTO);
- return CommonResult.success(ProductAttrConvert.INSTANCE.convertAttr(result));
- }
-
- @PostMapping("/attr/update")
- @ApiOperation(value = "修改商品规格")
- public CommonResult updateAttr(@Validated ProductAttrUpdateRequest updateRequest) {
- ProductAttrUpdateDTO productAttrUpdateDTO = ProductAttrConvert.INSTANCE.convertUpdate(updateRequest);
- // 更新
- return CommonResult.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 CommonResult.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(@Validated ProductAttrValueAddRequest addRequest) {
- // 创建 ProductAttrValueAddDTO 对象
- ProductAttrValueAddDTO productAttrValueAddDTO = new ProductAttrValueAddDTO().setAttrId(addRequest.getAttrId()).setName(addRequest.getName());
- // 添加
- ProductAttrValueBO result = productAttrService.addProductAttrValue(AdminSecurityContextHolder.getContext().getAdminId(), productAttrValueAddDTO);
- // 返回结果
- return CommonResult.success(ProductAttrConvert.INSTANCE.convertAddResponse(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 CommonResult.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 CommonResult.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/brand/AdminsProductBrandController.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/brand/AdminsProductBrandController.java
deleted file mode 100644
index 79814d9f3..000000000
--- a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/controller/brand/AdminsProductBrandController.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package cn.iocoder.mall.product.rest.controller.brand;
-
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.common.framework.vo.PageResult;
-import cn.iocoder.mall.product.biz.bo.brand.ProductBrandBO;
-import cn.iocoder.mall.product.biz.dto.brand.ProductBrandAddDTO;
-import cn.iocoder.mall.product.biz.dto.brand.ProductBrandPageDTO;
-import cn.iocoder.mall.product.biz.dto.brand.ProductBrandUpdateDTO;
-import cn.iocoder.mall.product.biz.service.brand.ProductBrandService;
-import cn.iocoder.mall.product.rest.convert.brand.ProductBrandConvert;
-import cn.iocoder.mall.product.rest.request.brand.ProductBrandAddRequest;
-import cn.iocoder.mall.product.rest.request.brand.ProductBrandPageRequest;
-import cn.iocoder.mall.product.rest.request.brand.ProductBrandUpdateRequest;
-import cn.iocoder.mall.product.rest.response.brand.AdminsProductBrandResponse;
-import cn.iocoder.mall.security.core.context.AdminSecurityContextHolder;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import lombok.AllArgsConstructor;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import static cn.iocoder.common.framework.vo.CommonResult.success;
-
-@RestController
-@RequestMapping("admins/brand")
-@Api("管理员 - 商品品牌 API")
-@AllArgsConstructor
-public class AdminsProductBrandController {
-
- private final ProductBrandService productBrandService;
-
- @PostMapping("/add")
- @ApiOperation("创建品牌")
- public CommonResult add(@Validated ProductBrandAddRequest addRequest) {
- // 创建 ProductBrandAddDTO 对象
- ProductBrandAddDTO productBrandAddDTO = ProductBrandConvert.INSTANCE.convertAdd(addRequest);
- // 保存品牌
- ProductBrandBO result = productBrandService.addProductBrand(AdminSecurityContextHolder.getContext().getAdminId(), productBrandAddDTO);
- // 返回结果
- return success(ProductBrandConvert.INSTANCE.convert(result));
- }
-
- @PostMapping("/update")
- @ApiOperation("更新商品")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "id", value = "品牌主键", required = true, example = "1"),
- @ApiImplicitParam(name = "name", value = "品牌名称", required = true, example = "安踏"),
- @ApiImplicitParam(name = "description", value = "品牌描述", required = true, example = "安踏拖鞋"),
- @ApiImplicitParam(name = "picUrl", value = "品牌图片", required = true, example = "http://www.iocoder.cn"),
- @ApiImplicitParam(name = "status", value = "状态 1开启 2禁用", required = true, example = "1")
- })
- // TODO FROM 芋艿 to q2118cs:只要改成了 bean 接收,就不用在写 @ApiImplicitParam 注解啦,直接在 bean 里写就 ok 啦
- public CommonResult update(@Validated ProductBrandUpdateRequest updateRequest) {
- // 创建 productBrandUpdateDTO 对象
- ProductBrandUpdateDTO productBrandUpdateDTO = ProductBrandConvert.INSTANCE.convertUpdate(updateRequest);
- // 更新商品
- return success(productBrandService.updateProductBrand(AdminSecurityContextHolder.getContext().getAdminId(), productBrandUpdateDTO));
- }
-
- @GetMapping("/get")
- @ApiOperation("获取品牌")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "id", value = "品牌主键", required = true, example = "1")
- })
- public CommonResult add(@RequestParam("id") Integer id) {
- // 保存商品
- ProductBrandBO result = productBrandService.getProductBrand(id);
- // 返回结果
- return success(ProductBrandConvert.INSTANCE.convert(result));
- }
-
- @GetMapping("/page")
- @ApiOperation("获得品牌分页")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "name", value = "品牌名称", required = true, example = "安踏"),
- @ApiImplicitParam(name = "description", value = "品牌描述", required = true, example = "安踏拖鞋"),
- @ApiImplicitParam(name = "status", value = "状态 1开启 2禁用", required = true, example = "1"),
- @ApiImplicitParam(name = "pageNo", value = "页码", required = true, example = "1"),
- @ApiImplicitParam(name = "pageSize", value = "页面大小", required = true, example = "10")
- })
- public CommonResult> attrPage(ProductBrandPageRequest pageRequest) {
- // 创建 ProductBrandPageDTO 对象
- ProductBrandPageDTO productBrandPageDTO = ProductBrandConvert.INSTANCE.convertPageRequest(pageRequest);
- // 查询分页
- PageResult productBrandPage = productBrandService.getProductBrandPage(productBrandPageDTO);
- PageResult adminPageResponse = ProductBrandConvert.INSTANCE.convertPage(productBrandPage);
- return CommonResult.success(adminPageResponse);
- }
-
-
-}
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
index 0e5e571c5..fb9c4b7ee 100644
--- 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
@@ -1,18 +1,7 @@
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.bo.attr.ProductAttrSimpleWithValueBO;
-import cn.iocoder.mall.product.biz.bo.attr.ProductAttrValueBO;
-import cn.iocoder.mall.product.biz.bo.attr.ProductAttrWithValueBO;
-import cn.iocoder.mall.product.biz.dto.attr.ProductAttrPageDTO;
-import cn.iocoder.mall.product.biz.dto.attr.ProductAttrUpdateDTO;
-import cn.iocoder.mall.product.rest.request.attr.ProductAttrPageRequest;
-import cn.iocoder.mall.product.rest.request.attr.ProductAttrUpdateRequest;
-import cn.iocoder.mall.product.rest.response.attr.AdminsProductAttrPageResponse;
import cn.iocoder.mall.product.rest.response.attr.AdminsProductAttrSimpleResponse;
-import cn.iocoder.mall.product.rest.response.attr.AdminsProdutAttrResponse;
-import cn.iocoder.mall.product.rest.response.attr.AdminsProductAttrValueResponse;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
@@ -24,22 +13,8 @@ public interface ProductAttrConvert {
ProductAttrConvert INSTANCE = Mappers.getMapper(ProductAttrConvert.class);
- @Mappings({})
- ProductAttrPageDTO convert(ProductAttrPageRequest bean);
-
- @Mappings({})
- PageResult convertPage(PageResult productAttrPage);
-
@Mappings({})
List convertSimple(List simpleList);
- @Mappings({})
- AdminsProdutAttrResponse convertAttr(ProductAttrBO attrBO);
-
- @Mappings({})
- ProductAttrUpdateDTO convertUpdate(ProductAttrUpdateRequest updateRequest);
-
- @Mappings({})
- AdminsProductAttrValueResponse convertAddResponse(ProductAttrValueBO result);
}
diff --git a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/convert/brand/ProductBrandConvert.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/convert/brand/ProductBrandConvert.java
deleted file mode 100644
index 2110b7537..000000000
--- a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/convert/brand/ProductBrandConvert.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package cn.iocoder.mall.product.rest.convert.brand;
-
-import cn.iocoder.common.framework.vo.PageResult;
-import cn.iocoder.mall.product.biz.bo.brand.ProductBrandBO;
-import cn.iocoder.mall.product.biz.dto.brand.ProductBrandAddDTO;
-import cn.iocoder.mall.product.biz.dto.brand.ProductBrandPageDTO;
-import cn.iocoder.mall.product.biz.dto.brand.ProductBrandUpdateDTO;
-import cn.iocoder.mall.product.rest.request.brand.ProductBrandAddRequest;
-import cn.iocoder.mall.product.rest.request.brand.ProductBrandPageRequest;
-import cn.iocoder.mall.product.rest.request.brand.ProductBrandUpdateRequest;
-import cn.iocoder.mall.product.rest.response.brand.AdminsProductBrandResponse;
-import org.mapstruct.Mapper;
-import org.mapstruct.Mappings;
-import org.mapstruct.factory.Mappers;
-
-@Mapper
-public interface ProductBrandConvert {
-
- ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class);
-
- @Mappings({})
- AdminsProductBrandResponse convert(ProductBrandBO brand);
-
- @Mappings({})
- ProductBrandAddDTO convertAdd(ProductBrandAddRequest addRequest);
-
- @Mappings({})
- ProductBrandUpdateDTO convertUpdate(ProductBrandUpdateRequest updateRequest);
-
- @Mappings({})
- ProductBrandPageDTO convertPageRequest(ProductBrandPageRequest pageRequest);
-
- @Mappings({})
- PageResult convertPage(PageResult productBrandPage);
-}
\ No newline at end of file
diff --git a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/response/brand/AdminsProductBrandResponse.java b/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/response/brand/AdminsProductBrandResponse.java
deleted file mode 100644
index fad12f1c5..000000000
--- a/product/product-rest/src/main/java/cn/iocoder/mall/product/rest/response/brand/AdminsProductBrandResponse.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package cn.iocoder.mall.product.rest.response.brand;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-import javax.validation.constraints.NotEmpty;
-
-/**
- * VO
- */
-@ApiModel(value = "商品品牌", description = "商品品牌")
-@Data
-@Accessors(chain = true)
-public class AdminsProductBrandResponse {
- /**
- * 规格编号
- */
- @ApiModelProperty(value = "品牌编号", required = true, example = "1")
- private Integer id;
-
- @ApiModelProperty(name = "name", value = "品牌名称", required = true, example = "安踏")
- @NotEmpty(message = "品牌名称不能为空")
- private String name;
-
- @ApiModelProperty(name = "description", value = "品牌描述", required = true, example = "安踏拖鞋")
- private String description;
-
- @ApiModelProperty(name = "picUrl", value = "品牌图片", required = true, example = "http://www.iocoder.cn")
- private String picUrl;
-
- @ApiModelProperty(name = "status", value = "状态 1开启 2禁用", required = true, example = "1")
- private Integer status;
-
-}
diff --git a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductSpuServiceImpl.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductSpuServiceImpl.java
index a89767c46..c8efda863 100644
--- a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductSpuServiceImpl.java
+++ b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductSpuServiceImpl.java
@@ -151,14 +151,4 @@ public class ProductSpuServiceImpl implements ProductSpuService {
return ProductSpuConvert.INSTANCE.convert3(skus, spus, attrAndValuePairList);
}
- private boolean sendProductUpdateMessage(Integer id) {
- // 创建 Message 对象
- ProductUpdateMessage message = new ProductUpdateMessage().setId(id);
- // 创建 Spring Message 对象
- Message springMessage = MessageBuilder.withPayload(message)
- .build();
- // 发送消息
- return mqStreamProducer.productUpdateOutput().send(springMessage);
- }
-
}
diff --git a/product/product-start/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
index 5f16bd7e1..fe7430e72 100644
--- a/product/product-start/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
@@ -68,8 +68,4 @@ public class AdminsProductSpuController {
return success(ProductSpuConvert.INSTANCE.convert3(list));
}
- private List parseSkus(String skuStr, Class clazz) {
- return JSON.parseArray(skuStr, clazz);
- }
-
}
diff --git a/search-service-project/pom.xml b/search-service-project/pom.xml
new file mode 100644
index 000000000..6ee80429a
--- /dev/null
+++ b/search-service-project/pom.xml
@@ -0,0 +1,39 @@
+
+
+
+ onemall
+ cn.iocoder.mall
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ search-service-project
+ pom
+
+ search-service-api
+ search-service-app
+
+
+
+
+
+
+ cn.iocoder.mall
+ mall-dependencies
+ 1.0-SNAPSHOT
+ pom
+ import
+
+
+
+
+ cn.iocoder.mall
+ search-service-api
+ 1.0-SNAPSHOT
+
+
+
+
+
diff --git a/search-service-project/search-service-api/pom.xml b/search-service-project/search-service-api/pom.xml
new file mode 100644
index 000000000..7df14779d
--- /dev/null
+++ b/search-service-project/search-service-api/pom.xml
@@ -0,0 +1,31 @@
+
+
+
+ search-service-project
+ cn.iocoder.mall
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ search-service-api
+
+
+
+ cn.iocoder.mall
+ common-framework
+
+
+
+
+ javax.validation
+ validation-api
+
+
+ org.projectlombok
+ lombok
+
+
+
+
diff --git a/search-service-project/search-service-app/pom.xml b/search-service-project/search-service-app/pom.xml
new file mode 100644
index 000000000..5020ba6b2
--- /dev/null
+++ b/search-service-project/search-service-app/pom.xml
@@ -0,0 +1,80 @@
+
+
+
+ search-service-project
+ cn.iocoder.mall
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ search-service-app
+
+
+
+
+ cn.iocoder.mall
+ mall-spring-boot-starter-dubbo
+
+
+
+
+
+
+
+
+
+
+
+ cn.iocoder.mall
+ product-service-api
+ 1.0-SNAPSHOT
+
+
+
+
+ cn.iocoder.mall
+ mall-spring-boot-starter-rocketmq
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-elasticsearch
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+ org.mapstruct
+ mapstruct
+
+
+ org.mapstruct
+ mapstruct-jdk8
+
+
+
+ org.aspectj
+ aspectjweaver
+ 1.9.6
+
+
+
+
diff --git a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/SearchServiceApplication.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/SearchServiceApplication.java
new file mode 100644
index 000000000..257bf5668
--- /dev/null
+++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/SearchServiceApplication.java
@@ -0,0 +1,4 @@
+package cn.iocoder.mall.searchservice;
+
+public class SearchServiceApplication {
+}
diff --git a/search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/config/JPAConfiguration.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/config/ElasticsearchConfiguration.java
similarity index 74%
rename from search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/config/JPAConfiguration.java
rename to search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/config/ElasticsearchConfiguration.java
index acb35fd21..8d743e10d 100644
--- a/search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/config/JPAConfiguration.java
+++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/config/ElasticsearchConfiguration.java
@@ -1,9 +1,9 @@
-package cn.iocoder.mall.search.biz.config;
+package cn.iocoder.mall.searchservice.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
@Configuration
@EnableElasticsearchRepositories(basePackages = "cn.iocoder.mall.search.biz.dao")
-public class JPAConfiguration {
+public class ElasticsearchConfiguration {
}
diff --git a/search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/constant/FieldAnalyzer.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/dal/es/FieldAnalyzer.java
similarity index 93%
rename from search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/constant/FieldAnalyzer.java
rename to search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/dal/es/FieldAnalyzer.java
index 5b5315769..8be69ff70 100644
--- a/search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/constant/FieldAnalyzer.java
+++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/dal/es/FieldAnalyzer.java
@@ -1,4 +1,4 @@
-package cn.iocoder.mall.search.biz.constant;
+package cn.iocoder.mall.searchservice.dal.es;
/**
* ES 字段分析器的枚举类
diff --git a/search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/dataobject/ESProductDO.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/dal/es/dataobject/ESProductDO.java
similarity index 91%
rename from search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/dataobject/ESProductDO.java
rename to search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/dal/es/dataobject/ESProductDO.java
index bd06b0abf..05e0598cb 100644
--- a/search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/dataobject/ESProductDO.java
+++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/dal/es/dataobject/ESProductDO.java
@@ -1,6 +1,6 @@
-package cn.iocoder.mall.search.biz.dataobject;
+package cn.iocoder.mall.searchservice.dal.es.dataobject;
-import cn.iocoder.mall.search.biz.constant.FieldAnalyzer;
+import cn.iocoder.mall.searchservice.dal.es.FieldAnalyzer;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
@@ -13,7 +13,7 @@ import java.util.List;
/**
* 商品 ES DO
*/
-@Document(indexName = "product", type = "spu", shards = 1, replicas = 0)
+@Document(indexName = "product", type = "product", shards = 1, replicas = 0)
@Data
@Accessors(chain = true)
public class ESProductDO {
diff --git a/search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/dao/ProductRepository.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/dal/es/repository/ProductRepository.java
similarity index 90%
rename from search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/dao/ProductRepository.java
rename to search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/dal/es/repository/ProductRepository.java
index 1b4b869d0..8a630ad17 100644
--- a/search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/dao/ProductRepository.java
+++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/dal/es/repository/ProductRepository.java
@@ -1,9 +1,9 @@
-package cn.iocoder.mall.search.biz.dao;
+package cn.iocoder.mall.searchservice.dal.es.repository;
-import cn.iocoder.common.framework.util.CollectionUtil;
-import cn.iocoder.common.framework.util.StringUtil;
+import cn.iocoder.common.framework.util.CollectionUtils;
+import cn.iocoder.common.framework.util.StringUtils;
import cn.iocoder.common.framework.vo.SortingField;
-import cn.iocoder.mall.search.biz.dataobject.ESProductDO;
+import cn.iocoder.mall.searchservice.dal.es.dataobject.ESProductDO;
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
@@ -35,7 +35,7 @@ public interface ProductRepository extends ElasticsearchRepository nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort(sortField.getField())
.order(SortOrder.fromString(sortField.getOrder()))));
- } else if (StringUtil.hasText(keyword)) {
+ } else if (StringUtils.hasText(keyword)) {
nativeSearchQueryBuilder.withSort(SortBuilders.scoreSort().order(SortOrder.DESC));
} else {
nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort("sort").order(SortOrder.DESC));
diff --git a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/package-info.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/package-info.java
new file mode 100644
index 000000000..ff9569ee8
--- /dev/null
+++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * 占位
+ */
+package cn.iocoder.mall.searchservice.manager;
diff --git a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/ProductSearchManager.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/ProductSearchManager.java
new file mode 100644
index 000000000..aa0084e06
--- /dev/null
+++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/ProductSearchManager.java
@@ -0,0 +1,40 @@
+package cn.iocoder.mall.searchservice.manager.product;
+
+import cn.iocoder.common.framework.vo.CommonResult;
+import cn.iocoder.mall.productservice.rpc.category.ProductCategoryRpc;
+import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc;
+import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
+import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
+import cn.iocoder.mall.productservice.rpc.spu.ProductSpuRpc;
+import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class ProductSearchManager {
+
+ @DubboReference(version = "${dubbo.consumer.ProductSpuRpc.version}")
+ private ProductSpuRpc productSpuRpc;
+ @DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}")
+ private ProductSkuRpc productSkuRpc;
+ @DubboReference(version = "${dubbo.consumer.ProductCategoryRpc.version}")
+ private ProductCategoryRpc productCategoryRpc;
+
+// @DubboReference( version = "${dubbo.consumer.CartService.version}")
+// private CartService cartService;
+
+ public Boolean saveProduct(Integer id) {
+ // 获得商品 SPU
+ CommonResult productSpuResult = productSpuRpc.getProductSpu(id);
+ productSpuResult.checkError();
+ // 获得商品 SKU
+ CommonResult> listProductSkusResult =
+ productSkuRpc.listProductSkus(new ProductSkuListQueryReqDTO().setProductSpuId(id));
+ listProductSkusResult.checkError();
+
+ return true;
+ }
+
+}
diff --git a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/service/package-info.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/service/package-info.java
new file mode 100644
index 000000000..edcc8abe4
--- /dev/null
+++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/service/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * 占位
+ */
+package cn.iocoder.mall.searchservice.service;
diff --git a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/service/product/ProductSearchService.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/service/product/ProductSearchService.java
new file mode 100644
index 000000000..40fab0a6d
--- /dev/null
+++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/service/product/ProductSearchService.java
@@ -0,0 +1,7 @@
+package cn.iocoder.mall.searchservice.service.product;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class ProductSearchService {
+}
diff --git a/search-service-project/search-service-app/src/main/resources/application-dev.yaml b/search-service-project/search-service-app/src/main/resources/application-dev.yaml
new file mode 100644
index 000000000..4cfe1567c
--- /dev/null
+++ b/search-service-project/search-service-app/src/main/resources/application-dev.yaml
@@ -0,0 +1,14 @@
+spring:
+ # 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/search-service-project/search-service-app/src/main/resources/application-local.yaml b/search-service-project/search-service-app/src/main/resources/application-local.yaml
new file mode 100644
index 000000000..9671ef1d8
--- /dev/null
+++ b/search-service-project/search-service-app/src/main/resources/application-local.yaml
@@ -0,0 +1,18 @@
+spring:
+ # 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/search-service-project/search-service-app/src/main/resources/application.yaml b/search-service-project/search-service-app/src/main/resources/application.yaml
new file mode 100644
index 000000000..cb31e8c15
--- /dev/null
+++ b/search-service-project/search-service-app/src/main/resources/application.yaml
@@ -0,0 +1,46 @@
+spring:
+ # Application 的配置项
+ application:
+ name: search-service
+ # Profile 的配置项
+ profiles:
+ active: local
+
+# Dubbo 配置项
+dubbo:
+ # Spring Cloud Alibaba Dubbo 专属配置
+ cloud:
+ subscribed-services: '' # 设置订阅的应用列表,默认为 * 订阅所有应用
+ # Dubbo 提供者的协议
+ protocol:
+ name: dubbo
+ port: -1
+ # Dubbo 提供服务的扫描基础包
+ scan:
+ base-packages: cn.iocoder.mall.searrchservice.rpc
+ # Dubbo 服务提供者的配置
+ provider:
+ filter: -exception
+ validation: true # 开启 Provider 参数校验
+ version: 1.0.0 # 服务的版本号
+ # Dubbo 服务消费者的配置
+ consumer:
+ ErrorCodeRpc:
+ version: 1.0.0
+ ProductCategoryRpc:
+ version: 1.0.0
+ ProductSpuRpc:
+ version: 1.0.0
+
+# RocketMQ 配置项
+rocketmq:
+ name-server: 400-infra.server.iocoder.cn:9876
+ producer:
+ group: ${spring.application.name}-producer-group
+
+# Mall 配置项
+mall:
+ # 错误码配置项对应 ErrorCodeProperties 配置类
+ error-code:
+ group: ${spring.application.name}
+ constants-class: cn.iocoder.mall.searrchservice.enums.ProductErrorCodeConstants
diff --git a/search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/service/ProductSearchServiceImpl.java b/search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/service/ProductSearchServiceImpl.java
index 1adda27c5..1b3be0fe3 100644
--- a/search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/service/ProductSearchServiceImpl.java
+++ b/search/search-service-impl/src/main/java/cn/iocoder/mall/search/biz/service/ProductSearchServiceImpl.java
@@ -46,13 +46,6 @@ public class ProductSearchServiceImpl implements ProductSearchService {
@Autowired
private ElasticsearchTemplate elasticsearchTemplate; // 因为需要使用到聚合操作,只好引入 ElasticsearchTemplate 。
- @Reference(validation = "true", version = "${dubbo.consumer.ProductSpuService.version}")
- private ProductSpuService productSpuService;
- @Reference(validation = "true", version = "${dubbo.consumer.ProductCategoryService.version}")
- private ProductCategoryService productCategoryService;
- @Reference(validation = "true", version = "${dubbo.consumer.CartService.version}")
- private CartService cartService;
-
@Override
public Integer rebuild() {
// TODO 芋艿,因为目前商品比较少,所以写的很粗暴。等未来重构