Commit d453301455bed0c1bf7e6b31d3366a67668a1be9
1 parent
652428a7
product:完善 App 商品分页接口
Showing
15 changed files
with
132 additions
and
115 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java
| @@ -19,7 +19,7 @@ public class ProductSpuPageReqVO extends PageParam { | @@ -19,7 +19,7 @@ public class ProductSpuPageReqVO extends PageParam { | ||
| 19 | @ApiModelProperty(value = "商品编码", example = "yudaoyuanma") | 19 | @ApiModelProperty(value = "商品编码", example = "yudaoyuanma") |
| 20 | private String code; | 20 | private String code; |
| 21 | 21 | ||
| 22 | - @ApiModelProperty(value = "分类id", example = "1") | 22 | + @ApiModelProperty(value = "分类编号", example = "1") |
| 23 | private Long categoryId; | 23 | private Long categoryId; |
| 24 | 24 | ||
| 25 | @ApiModelProperty(value = "商品品牌编号", example = "1") | 25 | @ApiModelProperty(value = "商品品牌编号", example = "1") |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java
| @@ -3,9 +3,9 @@ package cn.iocoder.yudao.module.product.controller.app.spu; | @@ -3,9 +3,9 @@ package cn.iocoder.yudao.module.product.controller.app.spu; | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; | ||
| 6 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuDetailRespVO; | 7 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuDetailRespVO; |
| 7 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; | ||
| 8 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; | 8 | +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageItemRespVO; |
| 9 | import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; | 9 | import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; |
| 10 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; | 10 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; |
| 11 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | 11 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| @@ -47,9 +47,10 @@ public class AppProductSpuController { | @@ -47,9 +47,10 @@ public class AppProductSpuController { | ||
| 47 | private ProductPropertyValueService productPropertyValueService; | 47 | private ProductPropertyValueService productPropertyValueService; |
| 48 | 48 | ||
| 49 | @GetMapping("/page") | 49 | @GetMapping("/page") |
| 50 | - @ApiOperation("获得商品spu分页") | ||
| 51 | - public CommonResult<PageResult<AppSpuPageRespVO>> getSpuPage(@Valid AppSpuPageReqVO pageVO) { | ||
| 52 | - return success(productSpuService.getSpuPage(pageVO)); | 50 | + @ApiOperation("获得商品 SPU 分页") |
| 51 | + public CommonResult<PageResult<AppSpuPageItemRespVO>> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) { | ||
| 52 | + PageResult<ProductSpuDO> pageResult = productSpuService.getSpuPage(pageVO, ProductSpuStatusEnum.ENABLE.getStatus()); | ||
| 53 | + return success(ProductSpuConvert.INSTANCE.convertPage02(pageResult)); | ||
| 53 | } | 54 | } |
| 54 | 55 | ||
| 55 | @GetMapping("/get-detail") | 56 | @GetMapping("/get-detail") |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.product.controller.app.spu.vo; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.util.StrUtil; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 5 | +import com.fasterxml.jackson.annotation.JsonIgnore; | ||
| 6 | +import io.swagger.annotations.ApiModel; | ||
| 7 | +import io.swagger.annotations.ApiModelProperty; | ||
| 8 | +import lombok.Data; | ||
| 9 | +import lombok.EqualsAndHashCode; | ||
| 10 | +import lombok.ToString; | ||
| 11 | + | ||
| 12 | +import javax.validation.constraints.AssertTrue; | ||
| 13 | + | ||
| 14 | +@ApiModel("用户 App - 商品 SPU 分页 Request VO") | ||
| 15 | +@Data | ||
| 16 | +@EqualsAndHashCode(callSuper = true) | ||
| 17 | +@ToString(callSuper = true) | ||
| 18 | +public class AppProductSpuPageReqVO extends PageParam { | ||
| 19 | + | ||
| 20 | + public static final String SORT_FIELD_PRICE = "price"; | ||
| 21 | + public static final String SORT_FIELD_SALES_COUNT = "salesCount"; | ||
| 22 | + | ||
| 23 | + @ApiModelProperty(value = "分类编号", example = "1") | ||
| 24 | + private Long categoryId; | ||
| 25 | + | ||
| 26 | + @ApiModelProperty(value = "关键字", example = "好看") | ||
| 27 | + private String keyword; | ||
| 28 | + | ||
| 29 | + @ApiModelProperty(value = "排序字段", example = "price", notes = "参见 AppSpuPageReqVO.SORT_FIELD_XXX 常量") | ||
| 30 | + private String sortField; | ||
| 31 | + | ||
| 32 | + @ApiModelProperty(value = "排序方式", example = "true", notes = "true - 升序;false - 降序") | ||
| 33 | + private Boolean sortAsc; | ||
| 34 | + | ||
| 35 | + @AssertTrue(message = "排序字段不合法") | ||
| 36 | + @JsonIgnore | ||
| 37 | + public boolean isSortFieldValid() { | ||
| 38 | + if (StrUtil.isEmpty(sortField)) { | ||
| 39 | + return true; | ||
| 40 | + } | ||
| 41 | + return StrUtil.equalsAny(sortField, SORT_FIELD_PRICE, SORT_FIELD_SALES_COUNT); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | +} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageItemRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.product.controller.app.spu.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +import javax.validation.constraints.NotEmpty; | ||
| 8 | +import javax.validation.constraints.NotNull; | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +@ApiModel("用户 App - 商品 SPU 分页项 Response VO") | ||
| 12 | +@Data | ||
| 13 | +public class AppSpuPageItemRespVO { | ||
| 14 | + | ||
| 15 | + @ApiModelProperty(value = "商品 SPU 编号", required = true, example = "1") | ||
| 16 | + private Long id; | ||
| 17 | + | ||
| 18 | + @ApiModelProperty(value = "商品名称", required = true, example = "芋道") | ||
| 19 | + @NotEmpty(message = "商品名称不能为空") | ||
| 20 | + private String name; | ||
| 21 | + | ||
| 22 | + @ApiModelProperty(value = "分类编号", required = true) | ||
| 23 | + @NotNull(message = "分类编号不能为空") | ||
| 24 | + private Long categoryId; | ||
| 25 | + | ||
| 26 | + @ApiModelProperty(value = "商品图片的数组", required = true) | ||
| 27 | + private List<String> picUrls; | ||
| 28 | + | ||
| 29 | + @ApiModelProperty(value = " 最小价格,单位使用:分", required = true, example = "1024") | ||
| 30 | + private Integer minPrice; | ||
| 31 | + | ||
| 32 | + @ApiModelProperty(value = "最大价格,单位使用:分", required = true, example = "1024") | ||
| 33 | + private Integer maxPrice; | ||
| 34 | + | ||
| 35 | + // ========== 统计相关字段 ========= | ||
| 36 | + | ||
| 37 | + @ApiModelProperty(value = "商品销量", example = "1024") | ||
| 38 | + private Integer salesCount; | ||
| 39 | + | ||
| 40 | +} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.product.controller.app.spu.vo; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | -import io.swagger.annotations.ApiModel; | ||
| 5 | -import io.swagger.annotations.ApiModelProperty; | ||
| 6 | -import lombok.Data; | ||
| 7 | -import lombok.EqualsAndHashCode; | ||
| 8 | -import lombok.ToString; | ||
| 9 | - | ||
| 10 | -@ApiModel("App - 商品spu分页 Request VO") | ||
| 11 | -@Data | ||
| 12 | -@EqualsAndHashCode(callSuper = true) | ||
| 13 | -@ToString(callSuper = true) | ||
| 14 | -public class AppSpuPageReqVO extends PageParam { | ||
| 15 | - | ||
| 16 | - @ApiModelProperty(value = "分类id") | ||
| 17 | - private Long categoryId; | ||
| 18 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.product.controller.app.spu.vo; | ||
| 2 | - | ||
| 3 | -import io.swagger.annotations.ApiModel; | ||
| 4 | -import io.swagger.annotations.ApiModelProperty; | ||
| 5 | -import lombok.Data; | ||
| 6 | - | ||
| 7 | -import javax.validation.constraints.NotNull; | ||
| 8 | -import java.util.List; | ||
| 9 | - | ||
| 10 | -@ApiModel("App - 商品spu分页 Request VO") | ||
| 11 | -@Data | ||
| 12 | -public class AppSpuPageRespVO { | ||
| 13 | - | ||
| 14 | - @ApiModelProperty(value = "主键", required = true, example = "1") | ||
| 15 | - private Long id; | ||
| 16 | - | ||
| 17 | - @ApiModelProperty(value = "商品名称") | ||
| 18 | - private String name; | ||
| 19 | - | ||
| 20 | - @ApiModelProperty(value = "卖点", required = true) | ||
| 21 | - @NotNull(message = "卖点不能为空") | ||
| 22 | - private String sellPoint; | ||
| 23 | - | ||
| 24 | - @ApiModelProperty(value = "描述", required = true) | ||
| 25 | - @NotNull(message = "描述不能为空") | ||
| 26 | - private String description; | ||
| 27 | - | ||
| 28 | - @ApiModelProperty(value = "分类id", required = true) | ||
| 29 | - @NotNull(message = "分类id不能为空") | ||
| 30 | - private Long categoryId; | ||
| 31 | - | ||
| 32 | - @ApiModelProperty(value = "商品主图地址,* 数组,以逗号分隔,最多上传15张", required = true) | ||
| 33 | - @NotNull(message = "商品主图地址,* 数组,以逗号分隔,最多上传15张不能为空") | ||
| 34 | - private List<String> picUrls; | ||
| 35 | - | ||
| 36 | - @ApiModelProperty(value = "排序字段", required = true) | ||
| 37 | - @NotNull(message = "排序字段不能为空") | ||
| 38 | - private Integer sort; | ||
| 39 | - | ||
| 40 | - @ApiModelProperty(value = "点赞初始人数") | ||
| 41 | - private Integer likeCount; | ||
| 42 | - | ||
| 43 | - @ApiModelProperty(value = "价格 单位使用:分") | ||
| 44 | - private Integer price; | ||
| 45 | - | ||
| 46 | - @ApiModelProperty(value = "库存数量") | ||
| 47 | - private Integer quantity; | ||
| 48 | - | ||
| 49 | - @ApiModelProperty(value = "上下架状态: 0 上架(开启) 1 下架(禁用)") | ||
| 50 | - private Integer status; | ||
| 51 | - | ||
| 52 | -} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java
| @@ -5,9 +5,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | @@ -5,9 +5,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; | 5 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 6 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; | 6 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 7 | import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO; | 7 | import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO; |
| 8 | +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; | ||
| 8 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuDetailRespVO; | 9 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuDetailRespVO; |
| 9 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; | ||
| 10 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; | 10 | +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageItemRespVO; |
| 11 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | 11 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 12 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | 12 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 13 | import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; | 13 | import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; |
| @@ -22,7 +22,7 @@ import static cn.hutool.core.util.ObjectUtil.defaultIfNull; | @@ -22,7 +22,7 @@ import static cn.hutool.core.util.ObjectUtil.defaultIfNull; | ||
| 22 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | 22 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | - * 商品spu Convert | 25 | + * 商品 SPU Convert |
| 26 | * | 26 | * |
| 27 | * @author 芋道源码 | 27 | * @author 芋道源码 |
| 28 | */ | 28 | */ |
| @@ -39,10 +39,7 @@ public interface ProductSpuConvert { | @@ -39,10 +39,7 @@ public interface ProductSpuConvert { | ||
| 39 | 39 | ||
| 40 | PageResult<ProductSpuRespVO> convertPage(PageResult<ProductSpuDO> page); | 40 | PageResult<ProductSpuRespVO> convertPage(PageResult<ProductSpuDO> page); |
| 41 | 41 | ||
| 42 | - ProductSpuPageReqVO convert(AppSpuPageReqVO bean); | ||
| 43 | - | ||
| 44 | - // TODO 芋艿:修改下 | ||
| 45 | - AppSpuPageRespVO convertAppResp(ProductSpuDO list); | 42 | + ProductSpuPageReqVO convert(AppProductSpuPageReqVO bean); |
| 46 | 43 | ||
| 47 | List<ProductSpuRespDTO> convertList2(List<ProductSpuDO> list); | 44 | List<ProductSpuRespDTO> convertList2(List<ProductSpuDO> list); |
| 48 | 45 | ||
| @@ -77,4 +74,6 @@ public interface ProductSpuConvert { | @@ -77,4 +74,6 @@ public interface ProductSpuConvert { | ||
| 77 | List<AppSpuDetailRespVO.Sku> convertList03(List<ProductSkuDO> skus); | 74 | List<AppSpuDetailRespVO.Sku> convertList03(List<ProductSkuDO> skus); |
| 78 | AppProductPropertyValueDetailRespVO convert03(ProductPropertyValueDetailRespBO propertyValue); | 75 | AppProductPropertyValueDetailRespVO convert03(ProductPropertyValueDetailRespBO propertyValue); |
| 79 | 76 | ||
| 77 | + PageResult<AppSpuPageItemRespVO> convertPage02(PageResult<ProductSpuDO> page); | ||
| 78 | + | ||
| 80 | } | 79 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java
| @@ -4,10 +4,12 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | @@ -4,10 +4,12 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; | 6 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; |
| 7 | +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; | ||
| 7 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | 8 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 8 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 9 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 9 | import org.apache.ibatis.annotations.Mapper; | 10 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 11 | ||
| 12 | +import java.util.Objects; | ||
| 11 | import java.util.Set; | 13 | import java.util.Set; |
| 12 | 14 | ||
| 13 | /** | 15 | /** |
| @@ -44,6 +46,19 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> { | @@ -44,6 +46,19 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> { | ||
| 44 | .orderByDesc(ProductSpuDO::getSort)); | 46 | .orderByDesc(ProductSpuDO::getSort)); |
| 45 | } | 47 | } |
| 46 | 48 | ||
| 49 | + default PageResult<ProductSpuDO> selectPage(AppProductSpuPageReqVO pageReqVO, Integer status) { | ||
| 50 | + LambdaQueryWrapperX<ProductSpuDO> query = new LambdaQueryWrapperX<ProductSpuDO>() | ||
| 51 | + .eqIfPresent(ProductSpuDO::getCategoryId, pageReqVO.getCategoryId()) | ||
| 52 | + .eqIfPresent(ProductSpuDO::getStatus, status); | ||
| 53 | + // 排序逻辑 | ||
| 54 | + if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_PRICE)) { | ||
| 55 | + query.orderBy(true, pageReqVO.getSortAsc(), ProductSpuDO::getMaxPrice); | ||
| 56 | + } else if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_SALES_COUNT)) { | ||
| 57 | + query.orderBy(true, pageReqVO.getSortAsc(), ProductSpuDO::getSalesCount); | ||
| 58 | + } | ||
| 59 | + return selectPage(pageReqVO, query); | ||
| 60 | + } | ||
| 61 | + | ||
| 47 | /** | 62 | /** |
| 48 | * 更新商品 SPU 库存 | 63 | * 更新商品 SPU 库存 |
| 49 | * | 64 | * |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java
| @@ -2,8 +2,7 @@ package cn.iocoder.yudao.module.product.service.spu; | @@ -2,8 +2,7 @@ package cn.iocoder.yudao.module.product.service.spu; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; | 4 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 5 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; | ||
| 6 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; | 5 | +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; |
| 7 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | 6 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 8 | 7 | ||
| 9 | import javax.validation.Valid; | 8 | import javax.validation.Valid; |
| @@ -95,9 +94,10 @@ public interface ProductSpuService { | @@ -95,9 +94,10 @@ public interface ProductSpuService { | ||
| 95 | * 获得商品 SPU 分页 | 94 | * 获得商品 SPU 分页 |
| 96 | * | 95 | * |
| 97 | * @param pageReqVO 分页查询 | 96 | * @param pageReqVO 分页查询 |
| 98 | - * @return 商品spu分页 | 97 | + * @param status 状态 |
| 98 | + * @return 商品 SPU 分页 | ||
| 99 | */ | 99 | */ |
| 100 | - PageResult<AppSpuPageRespVO> getSpuPage(AppSpuPageReqVO pageReqVO); | 100 | + PageResult<ProductSpuDO> getSpuPage(AppProductSpuPageReqVO pageReqVO, Integer status); |
| 101 | 101 | ||
| 102 | /** | 102 | /** |
| 103 | * 更新商品 SPU 库存(增量) | 103 | * 更新商品 SPU 库存(增量) |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
| @@ -9,8 +9,7 @@ import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; | @@ -9,8 +9,7 @@ import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; | ||
| 9 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; | 9 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 10 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; | 10 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; |
| 11 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; | 11 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 12 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; | ||
| 13 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; | 12 | +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; |
| 14 | import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; | 13 | import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; |
| 15 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; | 14 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; |
| 16 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; | 15 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; |
| @@ -195,6 +194,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -195,6 +194,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 195 | return productSpuMapper.selectList(); | 194 | return productSpuMapper.selectList(); |
| 196 | } | 195 | } |
| 197 | 196 | ||
| 197 | + // TODO 芋艿:改成 DO 返回 | ||
| 198 | @Override | 198 | @Override |
| 199 | public PageResult<ProductSpuRespVO> getSpuPage(ProductSpuPageReqVO pageReqVO) { | 199 | public PageResult<ProductSpuRespVO> getSpuPage(ProductSpuPageReqVO pageReqVO) { |
| 200 | // 库存告警的 SPU 编号的集合 | 200 | // 库存告警的 SPU 编号的集合 |
| @@ -210,18 +210,8 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -210,18 +210,8 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | @Override | 212 | @Override |
| 213 | - public PageResult<AppSpuPageRespVO> getSpuPage(AppSpuPageReqVO pageReqVO) { | ||
| 214 | - // TODO 芋艿:貌似实现不太合理 | ||
| 215 | - PageResult<ProductSpuDO> productSpuDOPageResult = productSpuMapper.selectPage(ProductSpuConvert.INSTANCE.convert(pageReqVO)); | ||
| 216 | - PageResult<AppSpuPageRespVO> pageResult = new PageResult<>(); | ||
| 217 | - // TODO @芋艿 这里用convert如何解决 | ||
| 218 | - List<AppSpuPageRespVO> collect = productSpuDOPageResult.getList() | ||
| 219 | - .stream() | ||
| 220 | - .map(ProductSpuConvert.INSTANCE::convertAppResp) | ||
| 221 | - .collect(Collectors.toList()); | ||
| 222 | - pageResult.setList(collect); | ||
| 223 | - pageResult.setTotal(productSpuDOPageResult.getTotal()); | ||
| 224 | - return pageResult; | 213 | + public PageResult<ProductSpuDO> getSpuPage(AppProductSpuPageReqVO pageReqVO, Integer status) { |
| 214 | + return productSpuMapper.selectPage(pageReqVO, status); | ||
| 225 | } | 215 | } |
| 226 | 216 | ||
| 227 | @Override | 217 | @Override |
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java
| @@ -12,8 +12,8 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.Pro | @@ -12,8 +12,8 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.Pro | ||
| 12 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; | 12 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; |
| 13 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; | 13 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 14 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; | 14 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 15 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; | ||
| 16 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; | 15 | +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; |
| 16 | +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageItemRespVO; | ||
| 17 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; | 17 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; |
| 18 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | 18 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 19 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | 19 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| @@ -339,15 +339,15 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { | @@ -339,15 +339,15 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { | ||
| 339 | productSpuMapper.insert(createReqVO); | 339 | productSpuMapper.insert(createReqVO); |
| 340 | 340 | ||
| 341 | // 调用 | 341 | // 调用 |
| 342 | - AppSpuPageReqVO appSpuPageReqVO = new AppSpuPageReqVO(); | 342 | + AppProductSpuPageReqVO appSpuPageReqVO = new AppProductSpuPageReqVO(); |
| 343 | appSpuPageReqVO.setCategoryId(2L); | 343 | appSpuPageReqVO.setCategoryId(2L); |
| 344 | 344 | ||
| 345 | - PageResult<AppSpuPageRespVO> spuPage = productSpuService.getSpuPage(appSpuPageReqVO); | 345 | + PageResult<AppSpuPageItemRespVO> spuPage = productSpuService.getSpuPage(appSpuPageReqVO); |
| 346 | 346 | ||
| 347 | PageResult<ProductSpuDO> result = productSpuMapper.selectPage( | 347 | PageResult<ProductSpuDO> result = productSpuMapper.selectPage( |
| 348 | ProductSpuConvert.INSTANCE.convert(appSpuPageReqVO)); | 348 | ProductSpuConvert.INSTANCE.convert(appSpuPageReqVO)); |
| 349 | 349 | ||
| 350 | - List<AppSpuPageRespVO> collect = result.getList() | 350 | + List<AppSpuPageItemRespVO> collect = result.getList() |
| 351 | .stream() | 351 | .stream() |
| 352 | .map(ProductSpuConvert.INSTANCE::convertAppResp) | 352 | .map(ProductSpuConvert.INSTANCE::convertAppResp) |
| 353 | .collect(Collectors.toList()); | 353 | .collect(Collectors.toList()); |
yudao-ui-app/api/product.js
| @@ -5,4 +5,4 @@ const { http } = uni.$u | @@ -5,4 +5,4 @@ const { http } = uni.$u | ||
| 5 | export const productSpuPage = params => http.get('product/spu/page', { params }) | 5 | export const productSpuPage = params => http.get('product/spu/page', { params }) |
| 6 | 6 | ||
| 7 | // 查询商品 | 7 | // 查询商品 |
| 8 | -export const productSpu = params => http.get('product/spu/', { params }) | 8 | +export const productSpu = id => http.get('product/spu/get-detail?id=' + id, { }) |
yudao-ui-app/pages/category/product-list.vue
| @@ -15,11 +15,11 @@ | @@ -15,11 +15,11 @@ | ||
| 15 | <image :src="item.picUrls[0]" mode='widthFix' /> | 15 | <image :src="item.picUrls[0]" mode='widthFix' /> |
| 16 | </view> | 16 | </view> |
| 17 | <view class="product-button"> | 17 | <view class="product-button"> |
| 18 | - <view class="product-text">【{{ item.sellPoint }}】{{ item.name }}</view> | 18 | + <view class="product-text">{{ item.name }}</view> |
| 19 | <view class="product-price-button"> | 19 | <view class="product-price-button"> |
| 20 | <text class="product-price">¥ | 20 | <text class="product-price">¥ |
| 21 | - <text class="price-size">{{ towNumber(item.price) }}</text></text> | ||
| 22 | - <text class="product-like-ccount">销量 {{ item.likeCount }}</text> | 21 | + <text class="price-size">{{ towNumber(item.minPrice) }}</text></text> |
| 22 | + <text class="product-like-count">销量 {{ item.salesCount }}</text> | ||
| 23 | </view> | 23 | </view> |
| 24 | </view> | 24 | </view> |
| 25 | </view> | 25 | </view> |
| @@ -144,7 +144,7 @@ | @@ -144,7 +144,7 @@ | ||
| 144 | } | 144 | } |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | - .product-like-ccount { | 147 | + .product-like-count { |
| 148 | font-size: 16rpx; | 148 | font-size: 16rpx; |
| 149 | margin-left: 10rpx; | 149 | margin-left: 10rpx; |
| 150 | } | 150 | } |
yudao-ui-app/pages/product/product.vue
| @@ -305,9 +305,7 @@ export default { | @@ -305,9 +305,7 @@ export default { | ||
| 305 | }, | 305 | }, |
| 306 | methods: { | 306 | methods: { |
| 307 | loadProductData() { | 307 | loadProductData() { |
| 308 | - let param = {} | ||
| 309 | - param.spuId = this.product.id | ||
| 310 | - productSpu(param).then(res => { | 308 | + productSpu(this.product.id).then(res => { |
| 311 | this.product.images = res.data.picUrls; | 309 | this.product.images = res.data.picUrls; |
| 312 | this.product.sku = res.data.skus; | 310 | this.product.sku = res.data.skus; |
| 313 | this.product.desc = res.data.description.replace(/<[^>]*>/g,''); | 311 | this.product.desc = res.data.description.replace(/<[^>]*>/g,''); |