完成商品 spu 分页的迁移
This commit is contained in:
parent
9a9407641c
commit
be4b34c884
@ -0,0 +1,7 @@
|
||||
### /product-spu/page 成功(全部)
|
||||
GET {{baseUrl}}/product-spu/page?pageNo=1&pageSize=10
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer {{accessToken}}
|
||||
|
||||
###
|
||||
|
@ -23,7 +23,7 @@ import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
* 商品 SPU Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/product_spu")
|
||||
@RequestMapping("/product-spu")
|
||||
@Api(tags = "商品 SPU")
|
||||
@Validated
|
||||
public class ProductSpuController {
|
||||
|
@ -6,6 +6,7 @@ import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("商品 SPU创建 Request VO")
|
||||
@Data
|
||||
@ -25,10 +26,10 @@ public class ProductSpuCreateReqVO {
|
||||
private Integer cid;
|
||||
@ApiModelProperty(value = "商品主图地址", required = true)
|
||||
@NotEmpty(message = "商品主图地址不能为空")
|
||||
private String picUrls;
|
||||
private List<String> picUrls;
|
||||
@ApiModelProperty(value = "是否上架商品", required = true)
|
||||
@NotNull(message = "是否上架商品不能为空")
|
||||
private Integer visible;
|
||||
private Boolean visible;
|
||||
@ApiModelProperty(value = "排序字段", required = true)
|
||||
@NotNull(message = "排序字段不能为空")
|
||||
private Integer sort;
|
||||
|
@ -19,9 +19,9 @@ public class ProductSpuRespVO {
|
||||
@ApiModelProperty(value = "分类编号", required = true)
|
||||
private Integer cid;
|
||||
@ApiModelProperty(value = "商品主图地址", required = true)
|
||||
private String picUrls;
|
||||
private List<String> picUrls;
|
||||
@ApiModelProperty(value = "是否上架商品", required = true)
|
||||
private Integer visible;
|
||||
private Boolean visible;
|
||||
@ApiModelProperty(value = "排序字段", required = true)
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "价格", required = true)
|
||||
|
@ -6,6 +6,7 @@ import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("商品 SPU更新 Request VO")
|
||||
@Data
|
||||
@ -28,10 +29,10 @@ public class ProductSpuUpdateReqVO {
|
||||
private Integer cid;
|
||||
@ApiModelProperty(value = "商品主图地址", required = true)
|
||||
@NotEmpty(message = "商品主图地址不能为空")
|
||||
private String picUrls;
|
||||
private List<String> picUrls;
|
||||
@ApiModelProperty(value = "是否上架商品", required = true)
|
||||
@NotNull(message = "是否上架商品不能为空")
|
||||
private Integer visible;
|
||||
private Boolean visible;
|
||||
@ApiModelProperty(value = "排序字段", required = true)
|
||||
@NotNull(message = "排序字段不能为空")
|
||||
private Integer sort;
|
||||
|
@ -1,36 +0,0 @@
|
||||
<?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>order</artifactId>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>order-rpc-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- Mall 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>order-biz-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 工具类相关 -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
</project>
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* 提供 order 服务的 RPC 接口的定义,提供内部调用
|
||||
*/
|
||||
package cn.iocoder.mall.order.rpc;
|
@ -1,42 +0,0 @@
|
||||
<?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>order</artifactId>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>order-rpc</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- Mall 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>order-rpc-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>order-biz</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- RPC 相关 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-dubbo</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Registry 和 Config 相关 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
</project>
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* 提供 order 服务的 RPC 接口的实现,提供内部调用
|
||||
*/
|
||||
package cn.iocoder.mall.order.rpc;
|
@ -1,14 +0,0 @@
|
||||
spring:
|
||||
# Spring Cloud 配置项
|
||||
cloud:
|
||||
nacos:
|
||||
# Spring Cloud Nacos Discovery 配置项
|
||||
discovery:
|
||||
server-addr: s1.iocoder.cn:8848 # Nacos 服务器地址
|
||||
namespace: local # Nacos 命名空间
|
||||
|
||||
# Dubbo 配置项
|
||||
dubbo:
|
||||
# Dubbo 注册中心
|
||||
registry:
|
||||
address: spring-cloud://s1.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
|
@ -1,14 +0,0 @@
|
||||
spring:
|
||||
# Spring Cloud 配置项
|
||||
cloud:
|
||||
nacos:
|
||||
# Spring Cloud Nacos Discovery 配置项
|
||||
discovery:
|
||||
server-addr: s1.iocoder.cn:8848 # Nacos 服务器地址
|
||||
namespace: test # Nacos 命名空间
|
||||
|
||||
# Dubbo 配置项
|
||||
dubbo:
|
||||
# Dubbo 注册中心
|
||||
registry:
|
||||
address: spring-cloud://s1.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
|
@ -1,40 +0,0 @@
|
||||
# Dubbo 配置项
|
||||
dubbo:
|
||||
# Spring Cloud Alibaba Dubbo 专属配置
|
||||
cloud:
|
||||
subscribed-services: '' # 设置订阅的应用列表,默认为 * 订阅所有应用
|
||||
# Dubbo 提供者的协议
|
||||
protocol:
|
||||
name: dubbo
|
||||
port: -1
|
||||
# Dubbo 提供服务的扫描基础包
|
||||
scan:
|
||||
base-packages: cn.iocoder.mall.order.rpc.rpc
|
||||
# Dubbo 服务提供者的配置
|
||||
provider:
|
||||
filter: -exception
|
||||
SystemLogRPC:
|
||||
version: 1.0.0
|
||||
OAuth2RPC:
|
||||
version: 1.0.0
|
||||
AuthorizationRPC:
|
||||
version: 1.0.0
|
||||
AdminRPC:
|
||||
version: 1.0.0
|
||||
UserRPC:
|
||||
version: 1.0.0
|
||||
UserAddressRPC:
|
||||
version: 1.0.0
|
||||
|
||||
# Dubbo 服务消费者的配置
|
||||
consumer:
|
||||
SystemLogRPC: # 用于 AccessLogInterceptor 等拦截器,记录 HTTP API 请求的访问日志
|
||||
version: 1.0.0
|
||||
OAuth2RPC: # 用于 AccountAuthInterceptor 拦截器,执行认证
|
||||
version: 1.0.0
|
||||
AuthorizationRPC: # 用于 AccountAuthInterceptor 拦截器,执行鉴权(权限验证)
|
||||
version: 1.0.0
|
||||
AdminRPC:
|
||||
version: 1.0.0
|
||||
UserRPC:
|
||||
version: 1.0.0
|
@ -5,6 +5,7 @@ import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -12,7 +13,7 @@ import java.util.List;
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductSpuCreateReqDTO {
|
||||
public class ProductSpuCreateReqDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* SPU 名字
|
||||
@ -43,7 +44,7 @@ public class ProductSpuCreateReqDTO {
|
||||
* 是否上架商品
|
||||
*/
|
||||
@NotNull(message = "是否上架商品不能为空")
|
||||
private Integer visible;
|
||||
private Boolean visible;
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
|
@ -3,6 +3,7 @@ package cn.iocoder.mall.productservice.rpc.spu.dto;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ -11,7 +12,7 @@ import java.util.List;
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductSpuRespDTO {
|
||||
public class ProductSpuRespDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 商品 SPU 编号
|
||||
@ -40,7 +41,7 @@ public class ProductSpuRespDTO {
|
||||
/**
|
||||
* 是否上架商品
|
||||
*/
|
||||
private Integer visible;
|
||||
private Boolean visible;
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
|
@ -5,6 +5,7 @@ import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -12,7 +13,7 @@ import java.util.List;
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductSpuUpdateReqDTO {
|
||||
public class ProductSpuUpdateReqDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 商品 SPU 编号
|
||||
@ -48,7 +49,7 @@ public class ProductSpuUpdateReqDTO {
|
||||
* 是否上架商品
|
||||
*/
|
||||
@NotNull(message = "是否上架商品不能为空")
|
||||
private Integer visible;
|
||||
private Boolean visible;
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.mall.productservice.convert.spu;
|
||||
|
||||
import cn.iocoder.common.framework.util.StringUtils;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.productservice.dal.mysql.dataobject.spu.ProductSpuDO;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuCreateReqDTO;
|
||||
@ -12,6 +13,8 @@ import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuPageBO;
|
||||
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuUpdateBO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Named;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
@ -21,14 +24,18 @@ public interface ProductSpuConvert {
|
||||
|
||||
ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class);
|
||||
|
||||
@Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "translatePicUrlsFromStringList")
|
||||
ProductSpuDO convert(ProductSpuCreateBO bean);
|
||||
|
||||
@Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "translatePicUrlsFromString")
|
||||
ProductSpuBO convert(ProductSpuDO bean);
|
||||
|
||||
@Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "translatePicUrlsFromStringList")
|
||||
ProductSpuDO convert(ProductSpuUpdateBO bean);
|
||||
|
||||
List<ProductSpuBO> convertList(List<ProductSpuDO> list);
|
||||
|
||||
@Mapping(source = "records", target = "list")
|
||||
PageResult<ProductSpuBO> convertPage(IPage<ProductSpuDO> page);
|
||||
|
||||
ProductSpuCreateBO convert(ProductSpuCreateReqDTO bean);
|
||||
@ -43,4 +50,14 @@ public interface ProductSpuConvert {
|
||||
|
||||
PageResult<ProductSpuRespDTO> convertPage(PageResult<ProductSpuBO> page);
|
||||
|
||||
@Named("translatePicUrlsFromString")
|
||||
default List<String> translatePicUrlsFromString(String picUrls) {
|
||||
return StringUtils.split(picUrls, ",");
|
||||
}
|
||||
|
||||
@Named("translatePicUrlsFromStringList")
|
||||
default String translatePicUrlsFromString(List<String> picUrls) {
|
||||
return StringUtils.join(picUrls, ",");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.mall.productservice.dal.mysql.dataobject.spu;
|
||||
|
||||
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
@ -8,6 +9,7 @@ import lombok.experimental.Accessors;
|
||||
/**
|
||||
* 商品 SKU
|
||||
*/
|
||||
@TableName("product_sku")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.mall.productservice.dal.mysql.dataobject.spu;
|
||||
|
||||
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
@ -10,6 +11,7 @@ import lombok.experimental.Accessors;
|
||||
*
|
||||
* TODO 芋艿,后面增加商品普通参数。例如说,正面材料,背面材料,屏幕尺寸。
|
||||
*/
|
||||
@TableName("product_spu")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
|
@ -40,7 +40,7 @@ public class ProductSpuBO {
|
||||
/**
|
||||
* 是否上架商品
|
||||
*/
|
||||
private Integer visible;
|
||||
private Boolean visible;
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
|
@ -43,7 +43,7 @@ public class ProductSpuCreateBO {
|
||||
* 是否上架商品
|
||||
*/
|
||||
@NotNull(message = "是否上架商品不能为空")
|
||||
private Integer visible;
|
||||
private Boolean visible;
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
|
@ -48,7 +48,7 @@ public class ProductSpuUpdateBO {
|
||||
* 是否上架商品
|
||||
*/
|
||||
@NotNull(message = "是否上架商品不能为空")
|
||||
private Integer visible;
|
||||
private Boolean visible;
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user