|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ylx.base.BaseServiceImpl;
|
|
import com.ylx.base.BaseServiceImpl;
|
|
|
import com.ylx.collect.domain.Collect;
|
|
import com.ylx.collect.domain.Collect;
|
|
|
import com.ylx.collect.domain.dto.CollectOperateDTO;
|
|
import com.ylx.collect.domain.dto.CollectOperateDTO;
|
|
|
|
|
+import com.ylx.collect.domain.dto.CollectSearchDTO;
|
|
|
import com.ylx.collect.domain.vo.CollectPageVO;
|
|
import com.ylx.collect.domain.vo.CollectPageVO;
|
|
|
import com.ylx.collect.mapper.CollectMapper;
|
|
import com.ylx.collect.mapper.CollectMapper;
|
|
|
import com.ylx.collect.service.CollectService;
|
|
import com.ylx.collect.service.CollectService;
|
|
@@ -16,6 +17,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -85,39 +87,17 @@ public class CollectServiceImpl extends BaseServiceImpl<CollectMapper, Collect>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Page<CollectPageVO> page(CollectOperateDTO dto) {
|
|
|
|
|
|
|
+ public Page<CollectPageVO> page(CollectSearchDTO dto) {
|
|
|
|
|
+
|
|
|
// 1. 获取当前用户,确保只能查自己的收藏
|
|
// 1. 获取当前用户,确保只能查自己的收藏
|
|
|
Long userId = getCurrentUserId();
|
|
Long userId = getCurrentUserId();
|
|
|
|
|
+ dto.setUserId(userId);
|
|
|
|
|
|
|
|
// 2. 构建分页对象
|
|
// 2. 构建分页对象
|
|
|
- Page<Collect> pageParam = new Page<>(dto.getCurrent(), dto.getSize());
|
|
|
|
|
|
|
+ Page<CollectPageVO> page = new Page<>(dto.getCurrent(), dto.getSize());
|
|
|
|
|
+ page = this.baseMapper.selectMyCollectPage(page, dto);
|
|
|
|
|
|
|
|
- // 3. 构建查询条件
|
|
|
|
|
- LambdaQueryWrapper<Collect> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- wrapper.eq(Collect::getUserId, userId)
|
|
|
|
|
- .eq(Collect::getIsDelete, NOT_DELETE)
|
|
|
|
|
- .orderByDesc(Collect::getCreateTime); // 按时间倒序
|
|
|
|
|
-
|
|
|
|
|
- // 4. 执行查询
|
|
|
|
|
- Page<Collect> resultPage = this.page(pageParam, wrapper);
|
|
|
|
|
-
|
|
|
|
|
- Page<CollectPageVO> voPage = new Page<>();
|
|
|
|
|
- // 1. 复制分页元数据(总条数、当前页码等)
|
|
|
|
|
- voPage.setCurrent(resultPage.getCurrent());
|
|
|
|
|
- voPage.setSize(resultPage.getSize());
|
|
|
|
|
- voPage.setTotal(resultPage.getTotal());
|
|
|
|
|
- voPage.setPages(resultPage.getPages());
|
|
|
|
|
-
|
|
|
|
|
- // 2. 转换列表数据
|
|
|
|
|
- List<CollectPageVO> voList = resultPage.getRecords().stream().map(collect -> {
|
|
|
|
|
- CollectPageVO vo = new CollectPageVO();
|
|
|
|
|
- // 属性拷贝
|
|
|
|
|
- BeanUtil.copyProperties(collect, vo);
|
|
|
|
|
- return vo;
|
|
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
|
-
|
|
|
|
|
- voPage.setRecords(voList);
|
|
|
|
|
- return voPage;
|
|
|
|
|
|
|
+ return page;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|