Compare commits
No commits in common. "28ce47356844ead90ba49674125eda58c324d2db" and "505aa43c3615617998550f32231801ebd5971562" have entirely different histories.
28ce473568
...
505aa43c36
@ -1,16 +1,12 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.history;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.app.history.vo.AppProductBrowseHistoryRespVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
import cn.iocoder.yudao.module.product.service.history.ProductBrowseHistoryService;
|
||||
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@ -22,11 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
@Tag(name = "管理后台 - 商品浏览记录")
|
||||
@RestController
|
||||
@ -36,35 +28,13 @@ public class ProductBrowseHistoryController {
|
||||
|
||||
@Resource
|
||||
private ProductBrowseHistoryService browseHistoryService;
|
||||
@Resource
|
||||
private ProductSpuService productSpuService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得商品浏览记录分页")
|
||||
@PreAuthorize("@ss.hasPermission('product:browse-history:query')")
|
||||
public CommonResult<PageResult<ProductBrowseHistoryRespVO>> getBrowseHistoryPage(@Valid ProductBrowseHistoryPageReqVO pageReqVO) {
|
||||
PageResult<ProductBrowseHistoryDO> pageResult = browseHistoryService.getBrowseHistoryPage(pageReqVO);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return success(PageResult.empty());
|
||||
}
|
||||
// 创建空结果列表
|
||||
List<ProductBrowseHistoryRespVO> resultList = new ArrayList<>();
|
||||
// 得到商品 spu 信息
|
||||
Set<Long> spuIds = convertSet(pageResult.getList(), ProductBrowseHistoryDO::getSpuId);
|
||||
// 得到集合
|
||||
Map<Long, ProductSpuDO> spuMap = convertMap(productSpuService.getSpuList(spuIds), ProductSpuDO::getId);
|
||||
|
||||
for (ProductBrowseHistoryRespVO productBrowseHistoryRespVO : BeanUtils.toBean(pageResult.getList(), ProductBrowseHistoryRespVO.class)) {
|
||||
ProductSpuDO productSpuDO = spuMap.get(productBrowseHistoryRespVO.getSpuId());
|
||||
productBrowseHistoryRespVO.setPicUrl(productSpuDO.getPicUrl());
|
||||
productBrowseHistoryRespVO.setPrice(productSpuDO.getPrice());
|
||||
productBrowseHistoryRespVO.setSpuName(productSpuDO.getName());
|
||||
productBrowseHistoryRespVO.setIntroduction(productSpuDO.getIntroduction());
|
||||
resultList.add(productBrowseHistoryRespVO);
|
||||
}
|
||||
PageResult<ProductBrowseHistoryRespVO> result = new PageResult<>();
|
||||
result.setTotal(pageResult.getTotal());
|
||||
result.setList(resultList);
|
||||
return success(result);
|
||||
return success(BeanUtils.toBean(pageResult, ProductBrowseHistoryRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -31,18 +31,4 @@ public class ProductBrowseHistoryRespVO {
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
// ========== 商品相关字段 ==========
|
||||
|
||||
@Schema(description = "商品 SPU 名称", example = "赵六")
|
||||
private String spuName;
|
||||
|
||||
@Schema(description = "商品封面图", example = "https://domain/pic.png")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "商品单价", example = "100")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "介绍", example = "100")
|
||||
private String introduction;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user