Skip to content

Commit

Permalink
开始迁移搜索服务
Browse files Browse the repository at this point in the history
  • Loading branch information
YunaiV committed Jul 30, 2020
1 parent d88da82 commit 981b3d8
Show file tree
Hide file tree
Showing 59 changed files with 745 additions and 989 deletions.
22 changes: 22 additions & 0 deletions common/mall-spring-boot-starter-rocketmq/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>common</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>mall-spring-boot-starter-rocketmq</artifactId>

<dependencies>
<!-- MQ 相关 -->
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
</dependency>
</dependencies>

</project>
1 change: 1 addition & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<module>mall-spring-boot-starter-mybatis</module>
<module>mall-spring-boot-starter-dubbo</module>
<module>mall-spring-boot-starter-system-error-code</module>
<module>mall-spring-boot-starter-rocketmq</module>
</modules>

<dependencyManagement>
Expand Down
17 changes: 16 additions & 1 deletion mall-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
<spring-boot-starter-data-jest.version>3.2.5.RELEASE</spring-boot-starter-data-jest.version>
<!-- RPC 相关 -->
<dubbo.version>2.7.7</dubbo.version>
<!-- MQ 相关 -->
<rocketmq-spring-boot-starter.version>2.1.0</rocketmq-spring-boot-starter.version>
<!-- Job 相关 -->
<xxl-job.version>2.0.1</xxl-job.version>
<!-- Transaction 相关 -->
Expand Down Expand Up @@ -219,12 +221,25 @@
<version>1.0-SNAPSHOT</version>
</dependency>

<dependency>
<dependency> <!-- TODO 需要思考下,归类到哪里 -->
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-system-error-code</artifactId> <!-- 错误码 -->
<version>1.0-SNAPSHOT</version>
</dependency>

<!-- MQ 相关 -->
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
<version>${rocketmq-spring-boot-starter.version}</version>
</dependency>

<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-rocketmq</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

<!-- Job 相关 -->
<dependency>
<groupId>com.xuxueli</groupId>
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<artifactId>onemall</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
<!-- <module>product</module>-->
<module>product</module>
<!-- <module>order</module>-->
<module>common</module>
<!-- <module>system</module>-->
Expand All @@ -31,6 +31,7 @@
<module>shop-web-app</module>
<module>product-service-project</module>
<module>promotion-service-project</module>
<module>search-service-project</module>
</modules>
<packaging>pom</packaging>

Expand Down
Original file line number Diff line number Diff line change
@@ -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<ProductSkuRespDTO> getProductSku(Integer productSkuId);

/**
* 获得商品 SKU 列表
*
* @param queryReqDTO 商品 SKU 列表的查询请求 DTO
* @return 商品 SKU 列表
*/
CommonResult<List<ProductSkuRespDTO>> listProductSkus(ProductSkuListQueryReqDTO queryReqDTO);

}
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -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<Integer> attrValueIds;
/**
* 价格,单位:分
*/
private Integer price;
/**
* 库存数量
*/
private Integer quantity;
/**
* 创建时间
*/
private Date createTime;

}
11 changes: 11 additions & 0 deletions product-service-project/product-service-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
<artifactId>product-service-api</artifactId>
</dependency>

<!-- MQ 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-rocketmq</artifactId>
</dependency>

<!-- Registry 和 Config 相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
Expand Down Expand Up @@ -72,6 +78,11 @@
<artifactId>mapstruct-jdk8</artifactId>
</dependency>

<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.6</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,7 +22,18 @@ public interface ProductSkuConvert {
List<ProductSkuDO> convertList(List<ProductSkuCreateOrUpdateBO> 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<ProductSkuBO> convertList02(List<ProductSkuDO> list);

ProductSkuRespDTO convert(ProductSkuBO bean);

ProductSkuListQueryBO convert(ProductSkuListQueryReqDTO bean);

List<ProductSkuRespDTO> convertList03(List<ProductSkuBO> list);

@Named("translateAttrValueIdsFromString")
default List<String> translateAttrValueIdsFromString(String attrValueIdsStar) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,4 +19,9 @@ default List<ProductSkuDO> selectListBySpuIdAndStatus(Integer spuId, Integer sta

void insertList(@Param("productSkuDOs") List<ProductSkuDO> productSkuDOs);

default List<ProductSkuDO> selectList(ProductSkuListQueryBO queryBO) {
return selectList(new QueryWrapperX<ProductSkuDO>().eqIfPresent("id", queryBO.getProductSkuId())
.eqIfPresent("spu_id", queryBO.getProductSpuId()));
}

}
Original file line number Diff line number Diff line change
@@ -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<ProductSkuRespDTO> listProductSkus(ProductSkuListQueryReqDTO queryReqDTO) {
List<ProductSkuBO> productSkuBOs = productSkuService.listProductSkus(
ProductSkuConvert.INSTANCE.convert(queryReqDTO));
return ProductSkuConvert.INSTANCE.convertList03(productSkuBOs);
}

}
Loading

0 comments on commit 981b3d8

Please sign in to comment.