足迹分页相关问题处理
This commit is contained in:
parent
4f5f02f030
commit
57cf3b94e0
@ -5,6 +5,7 @@ import cn.lili.common.vo.PageVO;
|
|||||||
import cn.lili.common.vo.ResultMessage;
|
import cn.lili.common.vo.ResultMessage;
|
||||||
import cn.lili.modules.member.service.FootprintService;
|
import cn.lili.modules.member.service.FootprintService;
|
||||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
@ -34,7 +35,7 @@ public class FootprintController {
|
|||||||
|
|
||||||
@ApiOperation(value = "分页获取")
|
@ApiOperation(value = "分页获取")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResultMessage<List<EsGoodsIndex>> getByPage(PageVO page) {
|
public ResultMessage<IPage<EsGoodsIndex>> getByPage(PageVO page) {
|
||||||
return ResultUtil.data(footprintService.footPrintPage(page));
|
return ResultUtil.data(footprintService.footPrintPage(page));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,17 +18,6 @@ import java.util.List;
|
|||||||
* @since 2020-02-25 14:10:16
|
* @since 2020-02-25 14:10:16
|
||||||
*/
|
*/
|
||||||
public interface FootprintMapper extends BaseMapper<FootPrint> {
|
public interface FootprintMapper extends BaseMapper<FootPrint> {
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户足迹的SkuId分页
|
|
||||||
*
|
|
||||||
* @param page 分页
|
|
||||||
* @param queryWrapper 查询条件
|
|
||||||
* @return 用户足迹的SkuId分页
|
|
||||||
*/
|
|
||||||
@Select("select sku_id from li_foot_print ${ew.customSqlSegment} ")
|
|
||||||
List<String> footprintSkuIdList(IPage<String> page, @Param(Constants.WRAPPER) Wrapper<FootPrint> queryWrapper);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除超过100条后的记录
|
* 删除超过100条后的记录
|
||||||
*
|
*
|
||||||
|
@ -3,6 +3,7 @@ package cn.lili.modules.member.service;
|
|||||||
import cn.lili.common.vo.PageVO;
|
import cn.lili.common.vo.PageVO;
|
||||||
import cn.lili.modules.member.entity.dos.FootPrint;
|
import cn.lili.modules.member.entity.dos.FootPrint;
|
||||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -44,7 +45,7 @@ public interface FootprintService extends IService<FootPrint> {
|
|||||||
* @param pageVO 分页
|
* @param pageVO 分页
|
||||||
* @return 会员浏览历史列表
|
* @return 会员浏览历史列表
|
||||||
*/
|
*/
|
||||||
List<EsGoodsIndex> footPrintPage(PageVO pageVO);
|
IPage<EsGoodsIndex> footPrintPage(PageVO pageVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前会员的浏览记录数量
|
* 获取当前会员的浏览记录数量
|
||||||
|
@ -9,7 +9,9 @@ import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
|||||||
import cn.lili.modules.search.service.EsGoodsSearchService;
|
import cn.lili.modules.search.service.EsGoodsSearchService;
|
||||||
import cn.lili.mybatis.util.PageUtil;
|
import cn.lili.mybatis.util.PageUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -19,6 +21,7 @@ import java.util.Collections;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员浏览历史业务层实现
|
* 会员浏览历史业务层实现
|
||||||
@ -29,9 +32,7 @@ import java.util.Objects;
|
|||||||
@Service
|
@Service
|
||||||
public class FootprintServiceImpl extends ServiceImpl<FootprintMapper, FootPrint> implements FootprintService {
|
public class FootprintServiceImpl extends ServiceImpl<FootprintMapper, FootPrint> implements FootprintService {
|
||||||
|
|
||||||
/**
|
|
||||||
* es商品业务层
|
|
||||||
*/
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EsGoodsSearchService esGoodsSearchService;
|
private EsGoodsSearchService esGoodsSearchService;
|
||||||
|
|
||||||
@ -74,20 +75,35 @@ public class FootprintServiceImpl extends ServiceImpl<FootprintMapper, FootPrint
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<EsGoodsIndex> footPrintPage(PageVO pageVO) {
|
public IPage<EsGoodsIndex> footPrintPage(PageVO pageVO) {
|
||||||
|
|
||||||
LambdaQueryWrapper<FootPrint> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<FootPrint> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
lambdaQueryWrapper.eq(FootPrint::getMemberId, UserContext.getCurrentUser().getId());
|
lambdaQueryWrapper.eq(FootPrint::getMemberId, UserContext.getCurrentUser().getId());
|
||||||
lambdaQueryWrapper.eq(FootPrint::getDeleteFlag, false);
|
lambdaQueryWrapper.eq(FootPrint::getDeleteFlag, false);
|
||||||
lambdaQueryWrapper.orderByDesc(FootPrint::getUpdateTime);
|
lambdaQueryWrapper.orderByDesc(FootPrint::getCreateTime);
|
||||||
List<String> skuIdList = this.baseMapper.footprintSkuIdList(PageUtil.initPage(pageVO), lambdaQueryWrapper);
|
IPage<FootPrint> footPrintPages = this.page(PageUtil.initPage(pageVO), lambdaQueryWrapper);
|
||||||
if (!skuIdList.isEmpty()) {
|
|
||||||
List<EsGoodsIndex> list = esGoodsSearchService.getEsGoodsBySkuIds(skuIdList);
|
|
||||||
|
//定义结果
|
||||||
|
IPage<EsGoodsIndex> esGoodsIndexIPage = new Page<EsGoodsIndex>();
|
||||||
|
|
||||||
|
if (footPrintPages.getRecords() == null || footPrintPages.getRecords().isEmpty()) {
|
||||||
|
return esGoodsIndexIPage;
|
||||||
|
} else {
|
||||||
|
List<EsGoodsIndex> list = esGoodsSearchService.getEsGoodsBySkuIds(
|
||||||
|
footPrintPages.getRecords().stream().map(item -> {
|
||||||
|
return item.getSkuId();
|
||||||
|
}).collect(Collectors.toList()));
|
||||||
//去除为空的商品数据
|
//去除为空的商品数据
|
||||||
list.removeIf(Objects::isNull);
|
list.removeIf(Objects::isNull);
|
||||||
return list;
|
|
||||||
|
esGoodsIndexIPage.setPages(footPrintPages.getPages());
|
||||||
|
esGoodsIndexIPage.setRecords(list);
|
||||||
|
esGoodsIndexIPage.setTotal(footPrintPages.getTotal());
|
||||||
|
esGoodsIndexIPage.setSize(footPrintPages.getSize());
|
||||||
|
esGoodsIndexIPage.setCurrent(footPrintPages.getCurrent());
|
||||||
|
return esGoodsIndexIPage;
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user