小程序积分商品列表 #30
@ -0,0 +1,57 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.controller.app.pointmall;
|
||||||
|
|
||||||
|
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.framework.security.core.annotations.PreAuthenticated;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.pointmall.vo.PointMallPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.pointmall.vo.PointMallRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.pointmall.PointMallDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.service.pointmall.PointMallService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
@Tag(name = "用户 APP - 积分商城")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/promotion/point-mall")
|
||||||
|
@Validated
|
||||||
|
public class AppPointMallController {
|
||||||
|
@Resource
|
||||||
|
private PointMallService pointMallService;
|
||||||
|
@Resource
|
||||||
|
private ProductSpuApi productSpuApi;
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "积分商品分页")
|
||||||
|
@PreAuthenticated
|
||||||
|
public CommonResult<List<ProductSpuRespDTO>> getPointMallPage(@Valid PointMallPageReqVO pageReqVO) {
|
||||||
|
PageResult<PointMallDO> pageResult = pointMallService.getPointMallPage(pageReqVO);
|
||||||
|
ArrayList<Long> list = new ArrayList<>();
|
||||||
|
HashMap<Long, Integer> map = new HashMap<>();
|
||||||
|
for (PointMallDO mallDO : pageResult.getList()) {
|
||||||
|
list.add(mallDO.getSpuId());
|
||||||
|
map.put(mallDO.getSpuId(),mallDO.getExchangePointNum());
|
||||||
|
}
|
||||||
|
List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(list);
|
||||||
|
for (ProductSpuRespDTO productSpuRespDTO : spuList) {
|
||||||
|
productSpuRespDTO.setPointCount(map.get(productSpuRespDTO.getId()));
|
||||||
|
}
|
||||||
|
return success(spuList);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user