Commit e76f61b4 authored by 刘基明's avatar 刘基明

话题下线返回message

parent a08ee369
...@@ -40,7 +40,7 @@ public class TopicController { ...@@ -40,7 +40,7 @@ public class TopicController {
@ApiOperation("话题详情页顶部") @ApiOperation("话题详情页顶部")
@ResponseBody @ResponseBody
public CommonResp<TopicRankQo> getDetail(@RequestParam String topicId){ public CommonResp<TopicRankQo> getDetail(@RequestParam String topicId){
return CommonResp.success(topicManager.getDetail(topicId)); return topicManager.getDetail(topicId);
} }
......
...@@ -255,7 +255,8 @@ public class ThemeManager { ...@@ -255,7 +255,8 @@ public class ThemeManager {
/** /**
* 推荐:由最热,最新和python推荐三个部分组成,比例为6,3,1 * 查询主题列表:推荐/关注/热门/最新
*
*/ */
// 查询主题列表:推荐/关注/热门/最新 // 查询主题列表:推荐/关注/热门/最新
public ThemeListResp queryList(ThemeListReq req, String userId) { public ThemeListResp queryList(ThemeListReq req, String userId) {
...@@ -272,15 +273,17 @@ public class ThemeManager { ...@@ -272,15 +273,17 @@ public class ThemeManager {
Integer pageSize = req.page.pageSize; Integer pageSize = req.page.pageSize;
List<ThemeEntity> themes = new ArrayList<>(); List<ThemeEntity> themes = new ArrayList<>();
// 推荐:由最新,最热和python推荐三个部分组成,默认比例为6,3,1,可在配置文件中配置
if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) { if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) {
// 推荐
// 需要筛掉用户访问过详情的 & 最近出现在列表页过的. // 需要筛掉用户访问过详情的 & 最近出现在列表页过的.
List<String> visitedIds = visitLogService.queryUserRecentVisited(userId); List<String> visitedIds = visitLogService.queryUserRecentVisited(userId);
List<String> excludes = ListUtils.union(excludeIds, visitedIds); List<String> excludes = ListUtils.union(excludeIds, visitedIds);
List<String> recmdIds = recommendService.getRecommendThemes(pageStart, pageSize, userId, excludes); List<String> recmdIds = recommendService.getRecommendThemes(pageStart, pageSize, userId, excludes);
themes = themeService.queryByThemeIds(recmdIds); themes = themeService.queryByThemeIds(recmdIds);
//排序并去重
themes = RankUtils.sortThemeEntityByIds(themes, recmdIds).stream().limit(pageSize).collect(Collectors.toList()); themes = RankUtils.sortThemeEntityByIds(themes, recmdIds).stream().limit(pageSize).collect(Collectors.toList());
......
package com.tanpu.community.manager; package com.tanpu.community.manager;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.constant.ErrorCodeConstant; import com.tanpu.common.constant.ErrorCodeConstant;
import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.beans.qo.TopicRankQo; import com.tanpu.community.api.beans.qo.TopicRankQo;
import com.tanpu.community.api.beans.req.page.Page; import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.beans.req.topic.TopicSearchReq; import com.tanpu.community.api.beans.req.topic.TopicSearchReq;
...@@ -39,12 +39,12 @@ public class TopicManager { ...@@ -39,12 +39,12 @@ public class TopicManager {
} }
// 话题详情页 // 话题详情页
public TopicRankQo getDetail(String topicId) { public CommonResp<TopicRankQo> getDetail(String topicId) {
TopicEntity topicEntity = topicService.queryById(topicId); TopicEntity topicEntity = topicService.queryById(topicId);
if (topicEntity==null){ if (topicEntity==null){
throw new BizException(ErrorCodeConstant.TOPIC_NOT_FOUND); return CommonResp.error(ErrorCodeConstant.TOPIC_NOT_FOUND.getCode(), "抱歉!该话题已下线。");
} }
return rankService.getTopicDetail(topicId); return CommonResp.success(rankService.getTopicDetail(topicId));
} }
......
...@@ -11,7 +11,7 @@ public class RankUtils { ...@@ -11,7 +11,7 @@ public class RankUtils {
/** /**
* 根据id排序主题对象 * 根据id排序主题对象(同时去重)
* @param list 主题 * @param list 主题
* @param ids 主题Id,list中可重复 * @param ids 主题Id,list中可重复
* @return * @return
......
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