!735 商城装修

Merge pull request !735 from 疯狂的世界/feature/mall_product
This commit is contained in:
芋道源码 2023-11-18 11:25:05 +00:00 committed by Gitee
commit a440b354ba
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 25 additions and 14 deletions

View File

@ -12,19 +12,7 @@ import java.util.List;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class ProductSpuDetailRespVO extends ProductSpuBaseVO { public class ProductSpuDetailRespVO extends ProductSpuRespVO {
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1212")
private Long id;
@Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000")
private Integer salesCount;
@Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20000")
private Integer browseCount;
@Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status;
// ========== SKU 相关字段 ========= // ========== SKU 相关字段 =========

View File

@ -13,7 +13,7 @@ import java.time.LocalDateTime;
@ToString(callSuper = true) @ToString(callSuper = true)
public class ProductSpuRespVO extends ProductSpuBaseVO { public class ProductSpuRespVO extends ProductSpuBaseVO {
@Schema(description = "spuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111")
private Long id; private Long id;
@Schema(description = "商品价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") @Schema(description = "商品价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999")

View File

@ -30,6 +30,7 @@ import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -75,6 +76,25 @@ public class AppProductSpuController {
return success(voList); return success(voList);
} }
@GetMapping("/list-by-ids")
@Operation(summary = "获得商品 SPU 列表")
@Parameters({
@Parameter(name = "ids", description = "编号列表", required = true)
})
public CommonResult<List<AppProductSpuPageRespVO>> getSpuList(@RequestParam("ids") Set<Long> ids) {
List<ProductSpuDO> list = productSpuService.getSpuList(ids);
if (CollUtil.isEmpty(list)) {
return success(Collections.emptyList());
}
// 拼接返回
List<AppProductSpuPageRespVO> voList = ProductSpuConvert.INSTANCE.convertListForGetSpuList(list);
// 处理 vip 价格
MemberLevelRespDTO memberLevel = getMemberLevel();
voList.forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel)));
return success(voList);
}
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得商品 SPU 分页") @Operation(summary = "获得商品 SPU 分页")
public CommonResult<PageResult<AppProductSpuPageRespVO>> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) { public CommonResult<PageResult<AppProductSpuPageRespVO>> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) {

View File

@ -15,6 +15,9 @@ public class AppProductSpuPageRespVO {
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
private String name; private String name;
@Schema(description = "商品简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖简介")
private String introduction;
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED)
private Long categoryId; private Long categoryId;