Search in sources :

Example 1 with ColumnVO

use of com.wayn.common.core.domain.vo.ColumnVO in project waynboot-mall by wayn111.

the class ColumnController method list.

@GetMapping("/list")
public R list(Column column) {
    Page<Column> page = getPage();
    IPage<Column> columnIPage = iColumnService.listPage(page, column);
    List<ColumnVO> columnVOS = columnIPage.getRecords().stream().map(item -> {
        ColumnVO columnVO = new ColumnVO();
        try {
            BeanUtils.copyProperties(columnVO, item);
        } catch (IllegalAccessException | InvocationTargetException e) {
            log.error(e.getMessage(), e);
        }
        Integer count = iColumnGoodsRelationService.getGoodsNum(item.getId());
        columnVO.setGoodsNum(count);
        return columnVO;
    }).collect(Collectors.toList());
    return R.success().add("page", formatPage(columnIPage, columnVOS));
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Validated(org.springframework.validation.annotation.Validated) BeanUtils(org.apache.commons.beanutils.BeanUtils) Date(java.util.Date) R(com.wayn.common.util.R) Autowired(org.springframework.beans.factory.annotation.Autowired) IColumnService(com.wayn.common.core.service.shop.IColumnService) Collectors(java.util.stream.Collectors) Column(com.wayn.common.core.domain.shop.Column) Goods(com.wayn.common.core.domain.shop.Goods) CollectionUtils(org.apache.commons.collections4.CollectionUtils) InvocationTargetException(java.lang.reflect.InvocationTargetException) BaseController(com.wayn.common.base.controller.BaseController) ColumnVO(com.wayn.common.core.domain.vo.ColumnVO) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) ColumnGoodsRelation(com.wayn.common.core.domain.shop.ColumnGoodsRelation) IColumnGoodsRelationService(com.wayn.common.core.service.shop.IColumnGoodsRelationService) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) IGoodsService(com.wayn.common.core.service.shop.IGoodsService) IPage(com.baomidou.mybatisplus.core.metadata.IPage) Column(com.wayn.common.core.domain.shop.Column) ColumnVO(com.wayn.common.core.domain.vo.ColumnVO)

Aggregations

QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 IPage (com.baomidou.mybatisplus.core.metadata.IPage)1 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1 BaseController (com.wayn.common.base.controller.BaseController)1 Column (com.wayn.common.core.domain.shop.Column)1 ColumnGoodsRelation (com.wayn.common.core.domain.shop.ColumnGoodsRelation)1 Goods (com.wayn.common.core.domain.shop.Goods)1 ColumnVO (com.wayn.common.core.domain.vo.ColumnVO)1 IColumnGoodsRelationService (com.wayn.common.core.service.shop.IColumnGoodsRelationService)1 IColumnService (com.wayn.common.core.service.shop.IColumnService)1 IGoodsService (com.wayn.common.core.service.shop.IGoodsService)1 R (com.wayn.common.util.R)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Date (java.util.Date)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Slf4j (lombok.extern.slf4j.Slf4j)1 BeanUtils (org.apache.commons.beanutils.BeanUtils)1 CollectionUtils (org.apache.commons.collections4.CollectionUtils)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1