From d453301455bed0c1bf7e6b31d3366a67668a1be9 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 15 Dec 2022 19:48:21 +0800 Subject: [PATCH] =?UTF-8?q?product=EF=BC=9A=E5=AE=8C=E5=96=84=20App=20?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=86=E9=A1=B5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/spu/vo/ProductSpuPageReqVO.java | 2 +- .../app/spu/AppProductSpuController.http | 2 +- .../app/spu/AppProductSpuController.java | 11 ++-- .../app/spu/vo/AppProductSpuPageReqVO.java | 44 ++++++++++++++++ .../app/spu/vo/AppSpuPageItemRespVO.java | 40 ++++++++++++++ .../app/spu/vo/AppSpuPageReqVO.java | 18 ------- .../app/spu/vo/AppSpuPageRespVO.java | 52 ------------------- .../convert/spu/ProductSpuConvert.java | 13 +++-- .../dal/mysql/spu/ProductSpuMapper.java | 15 ++++++ .../service/spu/ProductSpuService.java | 8 +-- .../service/spu/ProductSpuServiceImpl.java | 18 ++----- .../spu/ProductSpuServiceImplTest.java | 10 ++-- yudao-ui-app/api/product.js | 2 +- yudao-ui-app/pages/category/product-list.vue | 8 +-- yudao-ui-app/pages/product/product.vue | 4 +- 15 files changed, 132 insertions(+), 115 deletions(-) create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageItemRespVO.java delete mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageReqVO.java delete mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageRespVO.java diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java index 8d1bbee5f..3d74dc80c 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java +++ b/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 { @ApiModelProperty(value = "商品编码", example = "yudaoyuanma") private String code; - @ApiModelProperty(value = "分类id", example = "1") + @ApiModelProperty(value = "分类编号", example = "1") private Long categoryId; @ApiModelProperty(value = "商品品牌编号", example = "1") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http index 90bf0a4df..04df7bfec 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http @@ -1,5 +1,5 @@ ### 获得订单交易的分页 TODO -GET {{appApi}}/trade/order/page?pageNo=1&pageSize=10 +GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10 Authorization: Bearer {{appToken}} tenant-id: {{appTenentId}} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java index 5e64f3583..517140b49 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java +++ b/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; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuDetailRespVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageItemRespVO; import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; @@ -47,9 +47,10 @@ public class AppProductSpuController { private ProductPropertyValueService productPropertyValueService; @GetMapping("/page") - @ApiOperation("获得商品spu分页") - public CommonResult> getSpuPage(@Valid AppSpuPageReqVO pageVO) { - return success(productSpuService.getSpuPage(pageVO)); + @ApiOperation("获得商品 SPU 分页") + public CommonResult> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) { + PageResult pageResult = productSpuService.getSpuPage(pageVO, ProductSpuStatusEnum.ENABLE.getStatus()); + return success(ProductSpuConvert.INSTANCE.convertPage02(pageResult)); } @GetMapping("/get-detail") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java new file mode 100644 index 000000000..f19a7c21a --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java @@ -0,0 +1,44 @@ +package cn.iocoder.yudao.module.product.controller.app.spu.vo; + +import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import javax.validation.constraints.AssertTrue; + +@ApiModel("用户 App - 商品 SPU 分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class AppProductSpuPageReqVO extends PageParam { + + public static final String SORT_FIELD_PRICE = "price"; + public static final String SORT_FIELD_SALES_COUNT = "salesCount"; + + @ApiModelProperty(value = "分类编号", example = "1") + private Long categoryId; + + @ApiModelProperty(value = "关键字", example = "好看") + private String keyword; + + @ApiModelProperty(value = "排序字段", example = "price", notes = "参见 AppSpuPageReqVO.SORT_FIELD_XXX 常量") + private String sortField; + + @ApiModelProperty(value = "排序方式", example = "true", notes = "true - 升序;false - 降序") + private Boolean sortAsc; + + @AssertTrue(message = "排序字段不合法") + @JsonIgnore + public boolean isSortFieldValid() { + if (StrUtil.isEmpty(sortField)) { + return true; + } + return StrUtil.equalsAny(sortField, SORT_FIELD_PRICE, SORT_FIELD_SALES_COUNT); + } + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageItemRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageItemRespVO.java new file mode 100644 index 000000000..0b58555f8 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageItemRespVO.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.product.controller.app.spu.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +@ApiModel("用户 App - 商品 SPU 分页项 Response VO") +@Data +public class AppSpuPageItemRespVO { + + @ApiModelProperty(value = "商品 SPU 编号", required = true, example = "1") + private Long id; + + @ApiModelProperty(value = "商品名称", required = true, example = "芋道") + @NotEmpty(message = "商品名称不能为空") + private String name; + + @ApiModelProperty(value = "分类编号", required = true) + @NotNull(message = "分类编号不能为空") + private Long categoryId; + + @ApiModelProperty(value = "商品图片的数组", required = true) + private List picUrls; + + @ApiModelProperty(value = " 最小价格,单位使用:分", required = true, example = "1024") + private Integer minPrice; + + @ApiModelProperty(value = "最大价格,单位使用:分", required = true, example = "1024") + private Integer maxPrice; + + // ========== 统计相关字段 ========= + + @ApiModelProperty(value = "商品销量", example = "1024") + private Integer salesCount; + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageReqVO.java deleted file mode 100644 index 38ed4975e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@ApiModel("App - 商品spu分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppSpuPageReqVO extends PageParam { - - @ApiModelProperty(value = "分类id") - private Long categoryId; -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageRespVO.java deleted file mode 100644 index c0a0f0eb8..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuPageRespVO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@ApiModel("App - 商品spu分页 Request VO") -@Data -public class AppSpuPageRespVO { - - @ApiModelProperty(value = "主键", required = true, example = "1") - private Long id; - - @ApiModelProperty(value = "商品名称") - private String name; - - @ApiModelProperty(value = "卖点", required = true) - @NotNull(message = "卖点不能为空") - private String sellPoint; - - @ApiModelProperty(value = "描述", required = true) - @NotNull(message = "描述不能为空") - private String description; - - @ApiModelProperty(value = "分类id", required = true) - @NotNull(message = "分类id不能为空") - private Long categoryId; - - @ApiModelProperty(value = "商品主图地址,* 数组,以逗号分隔,最多上传15张", required = true) - @NotNull(message = "商品主图地址,* 数组,以逗号分隔,最多上传15张不能为空") - private List picUrls; - - @ApiModelProperty(value = "排序字段", required = true) - @NotNull(message = "排序字段不能为空") - private Integer sort; - - @ApiModelProperty(value = "点赞初始人数") - private Integer likeCount; - - @ApiModelProperty(value = "价格 单位使用:分") - private Integer price; - - @ApiModelProperty(value = "库存数量") - private Integer quantity; - - @ApiModelProperty(value = "上下架状态: 0 上架(开启) 1 下架(禁用)") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java index b84008314..9ed0c9b2c 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java +++ b/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; import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuDetailRespVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageItemRespVO; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; @@ -22,7 +22,7 @@ import static cn.hutool.core.util.ObjectUtil.defaultIfNull; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; /** - * 商品spu Convert + * 商品 SPU Convert * * @author 芋道源码 */ @@ -39,10 +39,7 @@ public interface ProductSpuConvert { PageResult convertPage(PageResult page); - ProductSpuPageReqVO convert(AppSpuPageReqVO bean); - - // TODO 芋艿:修改下 - AppSpuPageRespVO convertAppResp(ProductSpuDO list); + ProductSpuPageReqVO convert(AppProductSpuPageReqVO bean); List convertList2(List list); @@ -77,4 +74,6 @@ public interface ProductSpuConvert { List convertList03(List skus); AppProductPropertyValueDetailRespVO convert03(ProductPropertyValueDetailRespBO propertyValue); + PageResult convertPage02(PageResult page); + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java index a271b5051..57a3125d8 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java +++ b/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; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import org.apache.ibatis.annotations.Mapper; +import java.util.Objects; import java.util.Set; /** @@ -44,6 +46,19 @@ public interface ProductSpuMapper extends BaseMapperX { .orderByDesc(ProductSpuDO::getSort)); } + default PageResult selectPage(AppProductSpuPageReqVO pageReqVO, Integer status) { + LambdaQueryWrapperX query = new LambdaQueryWrapperX() + .eqIfPresent(ProductSpuDO::getCategoryId, pageReqVO.getCategoryId()) + .eqIfPresent(ProductSpuDO::getStatus, status); + // 排序逻辑 + if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_PRICE)) { + query.orderBy(true, pageReqVO.getSortAsc(), ProductSpuDO::getMaxPrice); + } else if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_SALES_COUNT)) { + query.orderBy(true, pageReqVO.getSortAsc(), ProductSpuDO::getSalesCount); + } + return selectPage(pageReqVO, query); + } + /** * 更新商品 SPU 库存 * diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java index a9a784795..d8034bd1b 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java +++ b/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; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import javax.validation.Valid; @@ -95,9 +94,10 @@ public interface ProductSpuService { * 获得商品 SPU 分页 * * @param pageReqVO 分页查询 - * @return 商品spu分页 + * @param status 状态 + * @return 商品 SPU 分页 */ - PageResult getSpuPage(AppSpuPageReqVO pageReqVO); + PageResult getSpuPage(AppProductSpuPageReqVO pageReqVO, Integer status); /** * 更新商品 SPU 库存(增量) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java index 2a25d96d6..6cbcbb584 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ b/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; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; @@ -195,6 +194,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { return productSpuMapper.selectList(); } + // TODO 芋艿:改成 DO 返回 @Override public PageResult getSpuPage(ProductSpuPageReqVO pageReqVO) { // 库存告警的 SPU 编号的集合 @@ -210,18 +210,8 @@ public class ProductSpuServiceImpl implements ProductSpuService { } @Override - public PageResult getSpuPage(AppSpuPageReqVO pageReqVO) { - // TODO 芋艿:貌似实现不太合理 - PageResult productSpuDOPageResult = productSpuMapper.selectPage(ProductSpuConvert.INSTANCE.convert(pageReqVO)); - PageResult pageResult = new PageResult<>(); - // TODO @芋艿 这里用convert如何解决 - List collect = productSpuDOPageResult.getList() - .stream() - .map(ProductSpuConvert.INSTANCE::convertAppResp) - .collect(Collectors.toList()); - pageResult.setList(collect); - pageResult.setTotal(productSpuDOPageResult.getTotal()); - return pageResult; + public PageResult getSpuPage(AppProductSpuPageReqVO pageReqVO, Integer status) { + return productSpuMapper.selectPage(pageReqVO, status); } @Override diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java index 7c0e6858b..64261d629 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java +++ b/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 import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageItemRespVO; import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; @@ -339,15 +339,15 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { productSpuMapper.insert(createReqVO); // 调用 - AppSpuPageReqVO appSpuPageReqVO = new AppSpuPageReqVO(); + AppProductSpuPageReqVO appSpuPageReqVO = new AppProductSpuPageReqVO(); appSpuPageReqVO.setCategoryId(2L); - PageResult spuPage = productSpuService.getSpuPage(appSpuPageReqVO); + PageResult spuPage = productSpuService.getSpuPage(appSpuPageReqVO); PageResult result = productSpuMapper.selectPage( ProductSpuConvert.INSTANCE.convert(appSpuPageReqVO)); - List collect = result.getList() + List collect = result.getList() .stream() .map(ProductSpuConvert.INSTANCE::convertAppResp) .collect(Collectors.toList()); diff --git a/yudao-ui-app/api/product.js b/yudao-ui-app/api/product.js index 5338d5d10..824aede9d 100644 --- a/yudao-ui-app/api/product.js +++ b/yudao-ui-app/api/product.js @@ -5,4 +5,4 @@ const { http } = uni.$u export const productSpuPage = params => http.get('product/spu/page', { params }) // 查询商品 -export const productSpu = params => http.get('product/spu/', { params }) +export const productSpu = id => http.get('product/spu/get-detail?id=' + id, { }) diff --git a/yudao-ui-app/pages/category/product-list.vue b/yudao-ui-app/pages/category/product-list.vue index d75867fc5..c78cb4f70 100644 --- a/yudao-ui-app/pages/category/product-list.vue +++ b/yudao-ui-app/pages/category/product-list.vue @@ -15,11 +15,11 @@ - 【{{ item.sellPoint }}】{{ item.name }} + {{ item.name }} ¥ - {{ towNumber(item.price) }} - 销量 {{ item.likeCount }} + {{ towNumber(item.minPrice) }} + 销量 {{ item.salesCount }} @@ -144,7 +144,7 @@ } } - .product-like-ccount { + .product-like-count { font-size: 16rpx; margin-left: 10rpx; } diff --git a/yudao-ui-app/pages/product/product.vue b/yudao-ui-app/pages/product/product.vue index 6fbbb8708..fa0a1fa63 100644 --- a/yudao-ui-app/pages/product/product.vue +++ b/yudao-ui-app/pages/product/product.vue @@ -305,9 +305,7 @@ export default { }, methods: { loadProductData() { - let param = {} - param.spuId = this.product.id - productSpu(param).then(res => { + productSpu(this.product.id).then(res => { this.product.images = res.data.picUrls; this.product.sku = res.data.skus; this.product.desc = res.data.description.replace(/<[^>]*>/g,'');