初始化商品分页接口
parent
5acf1ae3d4
commit
f3316d14c7
|
@ -5,6 +5,7 @@
|
||||||
"accessToken": "yudaoyuanma",
|
"accessToken": "yudaoyuanma",
|
||||||
|
|
||||||
"user-api-base-url": "http://127.0.0.1:18082/user-api/",
|
"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",
|
"user-access-token": "yunai",
|
||||||
|
|
||||||
"dubboTag": "${HOSTNAME}"
|
"dubboTag": "${HOSTNAME}"
|
||||||
|
|
|
@ -70,19 +70,6 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||||
return ProductSpuConvert.INSTANCE.convert2(spu, skus, attrAndValuePairList, category);
|
return ProductSpuConvert.INSTANCE.convert2(spu, skus, attrAndValuePairList, category);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ProductSpuDetailBO> getProductSpuDetailListForSync(Integer lastId, Integer limit) {
|
|
||||||
// TODO 芋艿,这里目前是一个一个进行计算,后续需要优化下
|
|
||||||
// 查询下一批商品编号集合
|
|
||||||
List<Integer> spuIds = productSpuMapper.selectIdListByIdGt(lastId, limit);
|
|
||||||
if (spuIds.isEmpty()) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
// 查询每个商品明细
|
|
||||||
List<ProductSpuDetailBO> spus = spuIds.stream().map(id -> getProductSpuDetail(id)).collect(Collectors.toList()); // TODO 芋艿,此处相当于是 N 个查询,后续要优化。
|
|
||||||
return spus;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateProductSpuSort(Integer adminId, Integer spuId, Integer sort) {
|
public Boolean updateProductSpuSort(Integer adminId, Integer spuId, Integer sort) {
|
||||||
// 校验 Spu 是否存在
|
// 校验 Spu 是否存在
|
||||||
|
|
|
@ -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<UsersProductSpuVO> spus;
|
|
||||||
@ApiModelProperty(value = "总数", required = true)
|
|
||||||
private Integer count;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,7 +1,15 @@
|
||||||
package cn.iocoder.mall.searchservice.rpc.product;
|
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 接口
|
* 商品搜索 RPC 接口
|
||||||
*/
|
*/
|
||||||
public interface SearchProductRpc {
|
public interface SearchProductRpc {
|
||||||
|
|
||||||
|
CommonResult<PageResult<SearchProductRespDTO>> pageSearchProduct(SearchProductPageReqDTO pageQueryReqDTO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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<SortingField> sorts;
|
||||||
|
|
||||||
|
}
|
|
@ -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<String> 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;
|
||||||
|
|
||||||
|
}
|
|
@ -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.category.dto.ProductCategoryRespDTO;
|
||||||
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
|
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
|
||||||
import cn.iocoder.mall.searchservice.dal.es.dataobject.ESProductDO;
|
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.SearchProductBO;
|
||||||
|
import cn.iocoder.mall.searchservice.service.product.bo.SearchProductPageQueryBO;
|
||||||
import cn.iocoder.mall.searchservice.service.product.bo.SearchProductSaveBO;
|
import cn.iocoder.mall.searchservice.service.product.bo.SearchProductSaveBO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
|
@ -39,4 +42,8 @@ public interface SearchProductConvert {
|
||||||
.setTotal(searchPage.getTotalElements());
|
.setTotal(searchPage.getTotalElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SearchProductPageQueryBO convert(SearchProductPageReqDTO bean);
|
||||||
|
|
||||||
|
PageResult<SearchProductRespDTO> convertPage(PageResult<SearchProductBO> pageResult);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cn.iocoder.mall.searchservice.manager.product;
|
||||||
|
|
||||||
import cn.iocoder.common.framework.util.CollectionUtils;
|
import cn.iocoder.common.framework.util.CollectionUtils;
|
||||||
import cn.iocoder.common.framework.vo.CommonResult;
|
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.ProductCategoryRpc;
|
||||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO;
|
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO;
|
||||||
import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc;
|
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.ProductSpuRpc;
|
||||||
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
|
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
|
||||||
import cn.iocoder.mall.searchservice.convert.product.SearchProductConvert;
|
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.SearchProductService;
|
||||||
|
import cn.iocoder.mall.searchservice.service.product.bo.SearchProductBO;
|
||||||
import cn.iocoder.mall.searchservice.service.product.bo.SearchProductSaveBO;
|
import cn.iocoder.mall.searchservice.service.product.bo.SearchProductSaveBO;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
|
@ -39,6 +43,11 @@ public class SearchProductManager {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SearchProductService searchProductService;
|
private SearchProductService searchProductService;
|
||||||
|
|
||||||
|
public PageResult<SearchProductRespDTO> pageSearchProduct(SearchProductPageReqDTO pageReqDTO) {
|
||||||
|
PageResult<SearchProductBO> pageResult = searchProductService.pageSearchProduct(SearchProductConvert.INSTANCE.convert(pageReqDTO));
|
||||||
|
return SearchProductConvert.INSTANCE.convertPage(pageResult);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重建所有商品的 ES 索引
|
* 重建所有商品的 ES 索引
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,7 +1,24 @@
|
||||||
package cn.iocoder.mall.searchservice.rpc.product;
|
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.apache.dubbo.config.annotation.DubboService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||||
|
|
||||||
@DubboService
|
@DubboService
|
||||||
public class SearchProductRpcImpl implements SearchProductRpc {
|
public class SearchProductRpcImpl implements SearchProductRpc {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SearchProductManager searchProductManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<PageResult<SearchProductRespDTO>> pageSearchProduct(SearchProductPageReqDTO pageQueryReqDTO) {
|
||||||
|
return success(searchProductManager.pageSearchProduct(pageQueryReqDTO));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class SearchProductService {
|
||||||
* @param pageQueryBO 分页查询条件
|
* @param pageQueryBO 分页查询条件
|
||||||
* @return 商品信息
|
* @return 商品信息
|
||||||
*/
|
*/
|
||||||
public PageResult<SearchProductBO> getSearchPage(SearchProductPageQueryBO pageQueryBO) {
|
public PageResult<SearchProductBO> pageSearchProduct(SearchProductPageQueryBO pageQueryBO) {
|
||||||
checkSortFieldInvalid(pageQueryBO.getSorts());
|
checkSortFieldInvalid(pageQueryBO.getSorts());
|
||||||
// 执行查询
|
// 执行查询
|
||||||
Page<ESProductDO> searchPage = productRepository.search(pageQueryBO.getCid(), pageQueryBO.getKeyword(),
|
Page<ESProductDO> searchPage = productRepository.search(pageQueryBO.getCid(), pageQueryBO.getKeyword(),
|
||||||
|
|
|
@ -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.PageParam;
|
||||||
import cn.iocoder.common.framework.vo.SortingField;
|
import cn.iocoder.common.framework.vo.SortingField;
|
||||||
|
import cn.iocoder.mall.searchservice.enums.product.SearchProductPageQuerySortFieldEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -11,6 +13,7 @@ import java.util.List;
|
||||||
* 商品检索分查询 BO
|
* 商品检索分查询 BO
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class SearchProductPageQueryBO extends PageParam {
|
public class SearchProductPageQueryBO extends PageParam {
|
||||||
|
|
||||||
|
@ -25,7 +28,7 @@ public class SearchProductPageQueryBO extends PageParam {
|
||||||
/**
|
/**
|
||||||
* 排序字段数组
|
* 排序字段数组
|
||||||
*
|
*
|
||||||
*
|
* 可支持排序的字段,见 {@link SearchProductPageQuerySortFieldEnum}
|
||||||
*/
|
*/
|
||||||
private List<SortingField> sorts;
|
private List<SortingField> sorts;
|
||||||
|
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
package cn.iocoder.mall.search.biz.api.user;
|
|
||||||
|
|
||||||
import cn.iocoder.common.framework.vo.CommonResult;
|
|
||||||
|
|
||||||
public interface ProductSearchRPC {
|
|
||||||
|
|
||||||
CommonResult<Integer> rebuild();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建商品的搜索索引
|
|
||||||
*
|
|
||||||
* @param id 商品编号
|
|
||||||
* @return 构建结果
|
|
||||||
*/
|
|
||||||
CommonResult<Boolean> save(Integer id);
|
|
||||||
|
|
||||||
// ProductPageBO getSearchPage(ProductSearchPageDTO searchPageDTO);
|
|
||||||
//
|
|
||||||
// ProductConditionBO getSearchCondition(ProductConditionDTO conditionDTO);
|
|
||||||
|
|
||||||
}
|
|
|
@ -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<ProductResponse> list;
|
|
||||||
/**
|
|
||||||
* 总量
|
|
||||||
*/
|
|
||||||
private Integer total;
|
|
||||||
|
|
||||||
}
|
|
|
@ -60,6 +60,12 @@
|
||||||
<artifactId>product-service-api</artifactId>
|
<artifactId>product-service-api</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<!-- 搜索服务 -->
|
||||||
|
<groupId>cn.iocoder.mall</groupId>
|
||||||
|
<artifactId>search-service-api</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<!-- 系统服务 -->
|
<!-- 系统服务 -->
|
||||||
<groupId>cn.iocoder.mall</groupId>
|
<groupId>cn.iocoder.mall</groupId>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
### /user-address/get-default 成功
|
### /user-address/get-default 成功
|
||||||
GET {{user-api-base-url}}/product-category/list?pid=0
|
GET {{shop-api-base-url}}/product-category/list?pid=0
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
|
@ -17,14 +17,10 @@ import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||||
|
|
||||||
/**
|
@Api(tags = "商品分类 API")
|
||||||
* 商品分类 Controller
|
|
||||||
*/
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/product-category")
|
@RequestMapping("/product-category")
|
||||||
@Api(tags = "商品分类")
|
|
||||||
@Validated
|
@Validated
|
||||||
// TODO 芋艿:稍后迁移到 shop-web-app 服务下
|
|
||||||
public class ProductCategoryController {
|
public class ProductCategoryController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
|
@ -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<PageResult<ProductSpuRespVO>> pageProductSpu(ProductSpuPageReqVO pageReqVO) {
|
||||||
|
return success(productSpuManager.pageProductSpu(pageReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1 +0,0 @@
|
||||||
package cn.iocoder.mall.shopweb.controller.product.vo;
|
|
|
@ -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<SortingField> sorts;
|
||||||
|
|
||||||
|
}
|
|
@ -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<String> 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;
|
||||||
|
|
||||||
|
}
|
|
@ -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<ProductSpuRespVO> convertPage(PageResult<SearchProductRespDTO> page);
|
||||||
|
|
||||||
|
}
|
|
@ -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<ProductSpuRespVO> pageProductSpu(ProductSpuPageReqVO pageReqVO) {
|
||||||
|
CommonResult<PageResult<SearchProductRespDTO>> pageResult =
|
||||||
|
searchProductRpc.pageSearchProduct(ProductSpuConvert.INSTANCE.convert(pageReqVO));
|
||||||
|
pageResult.checkError();
|
||||||
|
return ProductSpuConvert.INSTANCE.convertPage(pageResult.getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
# 服务器的配置项
|
# 服务器的配置项
|
||||||
server:
|
server:
|
||||||
port: 18083
|
port: 18084
|
||||||
servlet:
|
servlet:
|
||||||
context-path: /user-api/
|
context-path: /shop-api/
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
# Application 的配置项
|
# Application 的配置项
|
||||||
|
@ -25,8 +25,6 @@ dubbo:
|
||||||
consumer:
|
consumer:
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
validation: true # 开启 Consumer 的参数校验
|
validation: true # 开启 Consumer 的参数校验
|
||||||
UserSmsCodeRpc:
|
|
||||||
version: 1.0.0
|
|
||||||
UserRpc:
|
UserRpc:
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
OAuth2Rpc:
|
OAuth2Rpc:
|
||||||
|
@ -35,10 +33,10 @@ dubbo:
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
SystemExceptionLogRpc:
|
SystemExceptionLogRpc:
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
UserAddressRpc:
|
|
||||||
version: 1.0.0
|
|
||||||
ProductCategoryRpc:
|
ProductCategoryRpc:
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
SearchProductRpc:
|
||||||
|
version: 1.0.0
|
||||||
|
|
||||||
# Swagger 配置项
|
# Swagger 配置项
|
||||||
swagger:
|
swagger:
|
||||||
|
|
|
@ -37,8 +37,6 @@ dubbo:
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
UserAddressRpc:
|
UserAddressRpc:
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
ProductCategoryRpc:
|
|
||||||
version: 1.0.0
|
|
||||||
|
|
||||||
# Swagger 配置项
|
# Swagger 配置项
|
||||||
swagger:
|
swagger:
|
||||||
|
|
Loading…
Reference in New Issue