初始化商品分页接口
This commit is contained in:
@@ -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
|
||||
|
||||
###
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user