获取指定用户的个人主页作品
This commit is contained in:
@@ -430,7 +430,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
// 查询用户的作品集
|
||||
if (query.getGetMyPortfolio() == 1) {
|
||||
qw.lambda().eq(Portfolio::getAccountId, userHolder.getId());
|
||||
} else if (!Objects.isNull(query.getAccountId())) {
|
||||
} else if (!Objects.isNull(query.getAccountId()) && !query.getAccountId().equals(0L)) {
|
||||
qw.lambda().eq(Portfolio::getAccountId, query.getAccountId());
|
||||
}
|
||||
|
||||
@@ -444,6 +444,10 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
}
|
||||
}
|
||||
|
||||
// 按更新时间排序
|
||||
qw.lambda().orderByDesc(Portfolio::getUpdateDate);
|
||||
IPage<Portfolio> page;
|
||||
if (Objects.isNull(query.getAccountId()) && query.getGetMyPortfolio() != 1 && query.getGetLikePortfolio() != 1) {
|
||||
List<Portfolio> topThree = new ArrayList<>();
|
||||
List<Long> excludeIds = new ArrayList<>(); // 存放需要排除的 ID 列表
|
||||
|
||||
@@ -477,18 +481,23 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
qw.lambda().notIn(Portfolio::getId, excludeIds);
|
||||
}
|
||||
|
||||
// 按更新时间排序
|
||||
qw.lambda().orderByDesc(Portfolio::getUpdateDate);
|
||||
|
||||
// 执行分页查询
|
||||
IPage<Portfolio> page = portfolioMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
|
||||
page = portfolioMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
|
||||
|
||||
// 如果前三点赞和浏览不为空,将它们添加到分页查询的结果最前面
|
||||
if (!topThree.isEmpty() && (query.getGetMyPortfolio() != 1 && query.getGetLikePortfolio() != 1)) {
|
||||
if (!topThree.isEmpty()) {
|
||||
List<Portfolio> records = page.getRecords();
|
||||
if (!CollectionUtils.isEmpty(records)) {
|
||||
records.addAll(0, topThree); // 添加到查询结果的开头
|
||||
}else {
|
||||
records = topThree;
|
||||
}
|
||||
page.setRecords(records);
|
||||
}
|
||||
}else {
|
||||
// 执行分页查询
|
||||
page = portfolioMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
|
||||
}
|
||||
|
||||
// 将 Portfolio 转换为 PortfolioVO 并进行相关处理
|
||||
IPage<PortfolioVO> convert = page.convert((Function<Portfolio, PortfolioVO>) portfolio -> {
|
||||
|
||||
Reference in New Issue
Block a user