diff --git a/http-client.env.json b/http-client.env.json index 40249acc8..725ec1ce1 100644 --- a/http-client.env.json +++ b/http-client.env.json @@ -5,6 +5,7 @@ "accessToken": "yudaoyuanma", "user-api-base-url": "http://127.0.0.1:18082/user-api/", + "shop-api-base-url": "http://127.0.0.1:18084/shop-api/", "user-access-token": "yunai", "dubboTag": "${HOSTNAME}" 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 1edcc931f..75282a57a 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 @@ -70,19 +70,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { return ProductSpuConvert.INSTANCE.convert2(spu, skus, attrAndValuePairList, category); } - @Override - public List getProductSpuDetailListForSync(Integer lastId, Integer limit) { - // TODO 芋艿,这里目前是一个一个进行计算,后续需要优化下 - // 查询下一批商品编号集合 - List spuIds = productSpuMapper.selectIdListByIdGt(lastId, limit); - if (spuIds.isEmpty()) { - return Collections.emptyList(); - } - // 查询每个商品明细 - List spus = spuIds.stream().map(id -> getProductSpuDetail(id)).collect(Collectors.toList()); // TODO 芋艿,此处相当于是 N 个查询,后续要优化。 - return spus; - } - @Override public Boolean updateProductSpuSort(Integer adminId, Integer spuId, Integer sort) { // 校验 Spu 是否存在 diff --git a/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuPageVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuPageVO.java deleted file mode 100644 index f2adb5f76..000000000 --- a/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductSpuPageVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.mall.product.application.vo.users; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.List; - -@ApiModel("商品 SPU 分页 VO") -@Data -@Accessors(chain = true) -public class UsersProductSpuPageVO { - - @ApiModelProperty(value = "spu 数组", required = true) - private List spus; - @ApiModelProperty(value = "总数", required = true) - private Integer count; - -} diff --git a/search-service-project/search-service-api/src/main/java/cn/iocoder/mall/searchservice/rpc/product/SearchProductRpc.java b/search-service-project/search-service-api/src/main/java/cn/iocoder/mall/searchservice/rpc/product/SearchProductRpc.java index 478927989..264b6b529 100644 --- a/search-service-project/search-service-api/src/main/java/cn/iocoder/mall/searchservice/rpc/product/SearchProductRpc.java +++ b/search-service-project/search-service-api/src/main/java/cn/iocoder/mall/searchservice/rpc/product/SearchProductRpc.java @@ -1,7 +1,15 @@ package cn.iocoder.mall.searchservice.rpc.product; +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.searchservice.rpc.product.dto.SearchProductPageReqDTO; +import cn.iocoder.mall.searchservice.rpc.product.dto.SearchProductRespDTO; + /** * 商品搜索 RPC 接口 */ public interface SearchProductRpc { + + CommonResult> pageSearchProduct(SearchProductPageReqDTO pageQueryReqDTO); + } diff --git a/search-service-project/search-service-api/src/main/java/cn/iocoder/mall/searchservice/rpc/product/dto/SearchProductPageReqDTO.java b/search-service-project/search-service-api/src/main/java/cn/iocoder/mall/searchservice/rpc/product/dto/SearchProductPageReqDTO.java new file mode 100644 index 000000000..fb961e30e --- /dev/null +++ b/search-service-project/search-service-api/src/main/java/cn/iocoder/mall/searchservice/rpc/product/dto/SearchProductPageReqDTO.java @@ -0,0 +1,35 @@ +package cn.iocoder.mall.searchservice.rpc.product.dto; + +import cn.iocoder.common.framework.vo.PageParam; +import cn.iocoder.common.framework.vo.SortingField; +import cn.iocoder.mall.searchservice.enums.product.SearchProductPageQuerySortFieldEnum; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * 商品检索分页查询 Request DTO + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +public class SearchProductPageReqDTO extends PageParam { + + /** + * 分类编号 + */ + private Integer cid; + /** + * 关键字 + */ + private String keyword; + /** + * 排序字段数组 + * + * 可支持排序的字段,见 {@link SearchProductPageQuerySortFieldEnum} + */ + private List sorts; + +} diff --git a/search-service-project/search-service-api/src/main/java/cn/iocoder/mall/searchservice/rpc/product/dto/SearchProductRespDTO.java b/search-service-project/search-service-api/src/main/java/cn/iocoder/mall/searchservice/rpc/product/dto/SearchProductRespDTO.java new file mode 100644 index 000000000..8a27e29ce --- /dev/null +++ b/search-service-project/search-service-api/src/main/java/cn/iocoder/mall/searchservice/rpc/product/dto/SearchProductRespDTO.java @@ -0,0 +1,85 @@ +package cn.iocoder.mall.searchservice.rpc.product.dto; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * 搜索商品 Response DTO + */ +@Data +@Accessors(chain = true) +public class SearchProductRespDTO { + + private Integer id; + + // ========== 基本信息 ========= + /** + * SPU 名字 + */ + private String name; + /** + * 卖点 + */ + private String sellPoint; + /** + * 描述 + */ + private String description; + /** + * 分类编号 + */ + private Integer cid; + /** + * 分类名 + */ + private String categoryName; + /** + * 商品主图地数组 + */ + private List picUrls; + + // ========== 其他信息 ========= + /** + * 是否上架商品(是否可见)。 + * + * true 为已上架 + * false 为已下架 + */ + private Boolean visible; + /** + * 排序字段 + */ + private Integer sort; + + // ========== Sku 相关字段 ========= + /** + * 原价格,单位:分 + */ + private Integer originalPrice; + /** + * 购买价格,单位:分。 + */ + private Integer buyPrice; + /** + * 库存数量 + */ + private Integer quantity; + + // ========== 促销活动相关字段 ========= + // 目前只促销单体商品促销,目前仅限制折扣。 + /** + * 促销活动编号 + */ + private Integer promotionActivityId; + /** + * 促销活动标题 + */ + private String promotionActivityTitle; + /** + * 促销活动类型 + */ + private Integer promotionActivityType; + +} diff --git a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/convert/product/SearchProductConvert.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/convert/product/SearchProductConvert.java index 52a9461ca..e1f011284 100644 --- a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/convert/product/SearchProductConvert.java +++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/convert/product/SearchProductConvert.java @@ -4,7 +4,10 @@ import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO; import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO; import cn.iocoder.mall.searchservice.dal.es.dataobject.ESProductDO; +import cn.iocoder.mall.searchservice.rpc.product.dto.SearchProductPageReqDTO; +import cn.iocoder.mall.searchservice.rpc.product.dto.SearchProductRespDTO; import cn.iocoder.mall.searchservice.service.product.bo.SearchProductBO; +import cn.iocoder.mall.searchservice.service.product.bo.SearchProductPageQueryBO; import cn.iocoder.mall.searchservice.service.product.bo.SearchProductSaveBO; import org.mapstruct.Mapper; import org.mapstruct.Mapping; @@ -39,4 +42,8 @@ public interface SearchProductConvert { .setTotal(searchPage.getTotalElements()); } + SearchProductPageQueryBO convert(SearchProductPageReqDTO bean); + + PageResult convertPage(PageResult pageResult); + } diff --git a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/SearchProductManager.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/SearchProductManager.java index 7ef0f62e4..4ea1c1456 100644 --- a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/SearchProductManager.java +++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/SearchProductManager.java @@ -2,6 +2,7 @@ package cn.iocoder.mall.searchservice.manager.product; import cn.iocoder.common.framework.util.CollectionUtils; import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.mall.productservice.rpc.category.ProductCategoryRpc; import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO; import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc; @@ -10,7 +11,10 @@ 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 cn.iocoder.mall.searchservice.convert.product.SearchProductConvert; +import cn.iocoder.mall.searchservice.rpc.product.dto.SearchProductPageReqDTO; +import cn.iocoder.mall.searchservice.rpc.product.dto.SearchProductRespDTO; import cn.iocoder.mall.searchservice.service.product.SearchProductService; +import cn.iocoder.mall.searchservice.service.product.bo.SearchProductBO; import cn.iocoder.mall.searchservice.service.product.bo.SearchProductSaveBO; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.config.annotation.DubboReference; @@ -39,6 +43,11 @@ public class SearchProductManager { @Autowired private SearchProductService searchProductService; + public PageResult pageSearchProduct(SearchProductPageReqDTO pageReqDTO) { + PageResult pageResult = searchProductService.pageSearchProduct(SearchProductConvert.INSTANCE.convert(pageReqDTO)); + return SearchProductConvert.INSTANCE.convertPage(pageResult); + } + /** * 重建所有商品的 ES 索引 * diff --git a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/rpc/product/SearchProductRpcImpl.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/rpc/product/SearchProductRpcImpl.java index 6339764ba..13936e3f5 100644 --- a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/rpc/product/SearchProductRpcImpl.java +++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/rpc/product/SearchProductRpcImpl.java @@ -1,7 +1,24 @@ package cn.iocoder.mall.searchservice.rpc.product; +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.searchservice.manager.product.SearchProductManager; +import cn.iocoder.mall.searchservice.rpc.product.dto.SearchProductPageReqDTO; +import cn.iocoder.mall.searchservice.rpc.product.dto.SearchProductRespDTO; import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.beans.factory.annotation.Autowired; + +import static cn.iocoder.common.framework.vo.CommonResult.success; @DubboService public class SearchProductRpcImpl implements SearchProductRpc { + + @Autowired + private SearchProductManager searchProductManager; + + @Override + public CommonResult> pageSearchProduct(SearchProductPageReqDTO pageQueryReqDTO) { + return success(searchProductManager.pageSearchProduct(pageQueryReqDTO)); + } + } diff --git a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/service/product/SearchProductService.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/service/product/SearchProductService.java index 8c9f71968..4f4100a2f 100644 --- a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/service/product/SearchProductService.java +++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/service/product/SearchProductService.java @@ -42,7 +42,7 @@ public class SearchProductService { * @param pageQueryBO 分页查询条件 * @return 商品信息 */ - public PageResult getSearchPage(SearchProductPageQueryBO pageQueryBO) { + public PageResult pageSearchProduct(SearchProductPageQueryBO pageQueryBO) { checkSortFieldInvalid(pageQueryBO.getSorts()); // 执行查询 Page searchPage = productRepository.search(pageQueryBO.getCid(), pageQueryBO.getKeyword(), diff --git a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/service/product/bo/SearchProductPageQueryBO.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/service/product/bo/SearchProductPageQueryBO.java index c0d2dccb3..f7a79c4f2 100644 --- a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/service/product/bo/SearchProductPageQueryBO.java +++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/service/product/bo/SearchProductPageQueryBO.java @@ -2,7 +2,9 @@ package cn.iocoder.mall.searchservice.service.product.bo; import cn.iocoder.common.framework.vo.PageParam; import cn.iocoder.common.framework.vo.SortingField; +import cn.iocoder.mall.searchservice.enums.product.SearchProductPageQuerySortFieldEnum; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import java.util.List; @@ -11,6 +13,7 @@ import java.util.List; * 商品检索分查询 BO */ @Data +@EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class SearchProductPageQueryBO extends PageParam { @@ -25,7 +28,7 @@ public class SearchProductPageQueryBO extends PageParam { /** * 排序字段数组 * - * + * 可支持排序的字段,见 {@link SearchProductPageQuerySortFieldEnum} */ private List sorts; diff --git a/search/search-rpc-api/src/main/java/cn/iocoder/mall/search/biz/api/user/ProductSearchRPC.java b/search/search-rpc-api/src/main/java/cn/iocoder/mall/search/biz/api/user/ProductSearchRPC.java deleted file mode 100644 index 57a7e83aa..000000000 --- a/search/search-rpc-api/src/main/java/cn/iocoder/mall/search/biz/api/user/ProductSearchRPC.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.mall.search.biz.api.user; - -import cn.iocoder.common.framework.vo.CommonResult; - -public interface ProductSearchRPC { - - CommonResult rebuild(); - - /** - * 构建商品的搜索索引 - * - * @param id 商品编号 - * @return 构建结果 - */ - CommonResult save(Integer id); - -// ProductPageBO getSearchPage(ProductSearchPageDTO searchPageDTO); -// -// ProductConditionBO getSearchCondition(ProductConditionDTO conditionDTO); - -} diff --git a/search/search-rpc-api/src/main/java/cn/iocoder/mall/search/biz/response/user/ProductPageResponse.java b/search/search-rpc-api/src/main/java/cn/iocoder/mall/search/biz/response/user/ProductPageResponse.java deleted file mode 100644 index 56db936ad..000000000 --- a/search/search-rpc-api/src/main/java/cn/iocoder/mall/search/biz/response/user/ProductPageResponse.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.mall.search.biz.response.user; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.List; - -@Data -@Accessors(chain = true) -public class ProductPageResponse implements Serializable { - - /** - * 管理员数组 - */ - private List list; - /** - * 总量 - */ - private Integer total; - -} diff --git a/shop-web-app/pom.xml b/shop-web-app/pom.xml index 455d22fe6..162fe4da9 100644 --- a/shop-web-app/pom.xml +++ b/shop-web-app/pom.xml @@ -60,6 +60,12 @@ product-service-api 1.0-SNAPSHOT + + + cn.iocoder.mall + search-service-api + 1.0-SNAPSHOT + cn.iocoder.mall diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductCategoryController.http b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductCategoryController.http index efdc57c9b..16623f3ee 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductCategoryController.http +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductCategoryController.http @@ -1,4 +1,4 @@ ### /user-address/get-default 成功 -GET {{user-api-base-url}}/product-category/list?pid=0 +GET {{shop-api-base-url}}/product-category/list?pid=0 ### diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductCategoryController.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductCategoryController.java index 910709116..6927ccd51 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductCategoryController.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductCategoryController.java @@ -17,14 +17,10 @@ import java.util.List; import static cn.iocoder.common.framework.vo.CommonResult.success; -/** -* 商品分类 Controller -*/ +@Api(tags = "商品分类 API") @RestController @RequestMapping("/product-category") -@Api(tags = "商品分类") @Validated -// TODO 芋艿:稍后迁移到 shop-web-app 服务下 public class ProductCategoryController { @Autowired diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSpuController.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSpuController.java new file mode 100644 index 000000000..cb68107b4 --- /dev/null +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSpuController.java @@ -0,0 +1,33 @@ +package cn.iocoder.mall.shopweb.controller.product; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.shopweb.controller.product.vo.product.ProductSpuPageReqVO; +import cn.iocoder.mall.shopweb.controller.product.vo.product.ProductSpuRespVO; +import cn.iocoder.mall.shopweb.manager.product.ProductSpuManager; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static cn.iocoder.common.framework.vo.CommonResult.success; + +@Api(tags = "商品 SPU API") +@RestController +@RequestMapping("/product-spu") +@Validated +public class ProductSpuController { + + @Autowired + private ProductSpuManager productSpuManager; + + @GetMapping("/page") + @ApiOperation("获得商品 SPU 的分页") + public CommonResult> pageProductSpu(ProductSpuPageReqVO pageReqVO) { + return success(productSpuManager.pageProductSpu(pageReqVO)); + } + +} diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/vo/package-info.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/vo/package-info.java deleted file mode 100644 index 47e88023c..000000000 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/vo/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.mall.shopweb.controller.product.vo; diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/vo/product/ProductSpuPageReqVO.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/vo/product/ProductSpuPageReqVO.java new file mode 100644 index 000000000..32dd0520f --- /dev/null +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/vo/product/ProductSpuPageReqVO.java @@ -0,0 +1,24 @@ +package cn.iocoder.mall.shopweb.controller.product.vo.product; + +import cn.iocoder.common.framework.vo.PageParam; +import cn.iocoder.common.framework.vo.SortingField; + +import java.util.List; + +public class ProductSpuPageReqVO extends PageParam { + + /** + * 分类编号 + */ + private Integer cid; + /** + * 关键字 + */ + private String keyword; + + /** + * 排序字段数组 + */ + private List sorts; + +} diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/vo/product/ProductSpuRespVO.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/vo/product/ProductSpuRespVO.java new file mode 100644 index 000000000..617711d97 --- /dev/null +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/vo/product/ProductSpuRespVO.java @@ -0,0 +1,84 @@ +package cn.iocoder.mall.shopweb.controller.product.vo.product; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.List; + +@ApiModel("商品 SPU Response VO") +@Data +@Accessors(chain = true) +public class ProductSpuRespVO { + + private Integer id; + + // ========== 基本信息 ========= + /** + * SPU 名字 + */ + private String name; + /** + * 卖点 + */ + private String sellPoint; + /** + * 描述 + */ + private String description; + /** + * 分类编号 + */ + private Integer cid; + /** + * 分类名 + */ + private String categoryName; + /** + * 商品主图地数组 + */ + private List picUrls; + + // ========== 其他信息 ========= + /** + * 是否上架商品(是否可见)。 + * + * true 为已上架 + * false 为已下架 + */ + private Boolean visible; + /** + * 排序字段 + */ + private Integer sort; + + // ========== Sku 相关字段 ========= + /** + * 原价格,单位:分 + */ + private Integer originalPrice; + /** + * 购买价格,单位:分。 + */ + private Integer buyPrice; + /** + * 库存数量 + */ + private Integer quantity; + + // ========== 促销活动相关字段 ========= + // 目前只促销单体商品促销,目前仅限制折扣。 + /** + * 促销活动编号 + */ + private Integer promotionActivityId; + /** + * 促销活动标题 + */ + private String promotionActivityTitle; + /** + * 促销活动类型 + */ + private Integer promotionActivityType; + +} diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/convert/product/ProductSpuConvert.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/convert/product/ProductSpuConvert.java new file mode 100644 index 000000000..b0fcbf757 --- /dev/null +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/convert/product/ProductSpuConvert.java @@ -0,0 +1,20 @@ +package cn.iocoder.mall.shopweb.convert.product; + +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.searchservice.rpc.product.dto.SearchProductPageReqDTO; +import cn.iocoder.mall.searchservice.rpc.product.dto.SearchProductRespDTO; +import cn.iocoder.mall.shopweb.controller.product.vo.product.ProductSpuPageReqVO; +import cn.iocoder.mall.shopweb.controller.product.vo.product.ProductSpuRespVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface ProductSpuConvert { + + ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class); + + SearchProductPageReqDTO convert(ProductSpuPageReqVO bean); + + PageResult convertPage(PageResult page); + +} diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/manager/product/ProductSpuManager.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/manager/product/ProductSpuManager.java new file mode 100644 index 000000000..46807e46c --- /dev/null +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/manager/product/ProductSpuManager.java @@ -0,0 +1,31 @@ +package cn.iocoder.mall.shopweb.manager.product; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.searchservice.rpc.product.SearchProductRpc; +import cn.iocoder.mall.searchservice.rpc.product.dto.SearchProductRespDTO; +import cn.iocoder.mall.shopweb.controller.product.vo.product.ProductSpuPageReqVO; +import cn.iocoder.mall.shopweb.controller.product.vo.product.ProductSpuRespVO; +import cn.iocoder.mall.shopweb.convert.product.ProductSpuConvert; +import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +/** + * Product SPU Manager + */ +@Service +@Validated +public class ProductSpuManager { + + @DubboReference(version = "${dubbo.consumer.SearchProductRpc.version}") + private SearchProductRpc searchProductRpc; + + public PageResult pageProductSpu(ProductSpuPageReqVO pageReqVO) { + CommonResult> pageResult = + searchProductRpc.pageSearchProduct(ProductSpuConvert.INSTANCE.convert(pageReqVO)); + pageResult.checkError(); + return ProductSpuConvert.INSTANCE.convertPage(pageResult.getData()); + } + +} diff --git a/shop-web-app/src/main/resources/application.yml b/shop-web-app/src/main/resources/application.yml index e521912ed..ad9aadc12 100644 --- a/shop-web-app/src/main/resources/application.yml +++ b/shop-web-app/src/main/resources/application.yml @@ -1,8 +1,8 @@ # 服务器的配置项 server: - port: 18083 + port: 18084 servlet: - context-path: /user-api/ + context-path: /shop-api/ spring: # Application 的配置项 @@ -25,8 +25,6 @@ dubbo: consumer: timeout: 10000 validation: true # 开启 Consumer 的参数校验 - UserSmsCodeRpc: - version: 1.0.0 UserRpc: version: 1.0.0 OAuth2Rpc: @@ -35,10 +33,10 @@ dubbo: version: 1.0.0 SystemExceptionLogRpc: version: 1.0.0 - UserAddressRpc: - version: 1.0.0 ProductCategoryRpc: version: 1.0.0 + SearchProductRpc: + version: 1.0.0 # Swagger 配置项 swagger: diff --git a/user-web-app/src/main/resources/application.yml b/user-web-app/src/main/resources/application.yml index d47e5b3f5..aba33d1f5 100644 --- a/user-web-app/src/main/resources/application.yml +++ b/user-web-app/src/main/resources/application.yml @@ -37,8 +37,6 @@ dubbo: version: 1.0.0 UserAddressRpc: version: 1.0.0 - ProductCategoryRpc: - version: 1.0.0 # Swagger 配置项 swagger: