Commit df7fa9e4 authored by 张辰's avatar 张辰

pageable

parent 4e912b47
package com.tanpu.community.api.beans.req.theme;
import com.tanpu.community.api.beans.req.page.Pageable;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -21,13 +22,7 @@ public class ThemeListReq {
@ApiModelProperty(value = "当前浏览的最后一个themeId,可以为空")
public String lastId="";
@NotNull(message = "pageNumber不能为空")
@ApiModelProperty(value = "页面起始")
public Integer pageNumber;
@NotNull(message = "PageSize不能为空")
@ApiModelProperty(value = "页面大小")
public Integer pageSize;
public Pageable page;
public List<String> excludeIds;
}
......@@ -184,8 +184,8 @@ public class ThemeManager {
*/
// 查询主题列表:推荐/关注/热门/最新
public ThemeListResp queryThemes(ThemeListReq req, String userId) {
Integer pageStart = (req.pageNumber - 1) * req.pageSize;
Integer realSize = req.pageSize * 2;
Integer pageStart = (req.page.pageNumber - 1) * req.page.pageSize;
Integer realSize = req.page.pageSize * 2;
List<ThemeEntity> themes = new ArrayList<>();
if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) {
......@@ -199,7 +199,7 @@ public class ThemeManager {
} else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) {
//根据关注列表查询
List<String> fansList = followRelService.queryFansByFollowerId(userId);
themes = themeService.queryByUserIds(fansList, req.getLastId(), req.getPageSize());
themes = themeService.queryByUserIds(fansList, req.getLastId(), req.page.getPageSize());
} else if (ThemeListTypeEnum.TOPIC_HOT.getCode().equals(req.getType())) {
//根据话题查询热门
if (StringUtils.isEmpty(req.getTopicId())) {
......@@ -216,13 +216,13 @@ public class ThemeManager {
throw new BizException("TopicId为空");
}
themes = themeService.queryNewestByTopic(req.topicId, req.pageNumber, realSize);
themes = themeService.queryNewestByTopic(req.topicId, req.page.pageNumber, realSize);
}
// filter用户自己的
themes = themes.stream().filter(t -> {
return !userId.equals(t.getAuthorId()) && !req.excludeIds.contains(t.getThemeId());
}).collect(Collectors.toList()).subList(0, req.pageSize);
}).collect(Collectors.toList()).subList(0, req.page.pageSize);
ThemeListResp resp = new ThemeListResp();
resp.excludeIds = req.excludeIds;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment