Commit 686ce025 authored by 刘基明's avatar 刘基明

管理员

parent ec929dd6
......@@ -8,13 +8,13 @@ import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@ApiModel(value = "主题关联产品")
@ApiModel(value = "主题关联产品 RelTypeEnum")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TopicAttachement {
@ApiModelProperty(value = "RelTypeEnum类型,108:文本,88:产品 3:直播 6:短视频 303:新版课程-音频,304: 新版课程-视频,109:单图(长文) 110:多图(讨论)")
@ApiModelProperty(value = " 88:产品 300:课程包 323: 线下活动 未定:资管人")
private String type;
@ApiModelProperty(value = "对象详情")
......
......@@ -6,6 +6,7 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
@Data
@Builder
......@@ -47,4 +48,10 @@ public class TopicFollowQo {
@ApiModelProperty(value = "最近一条讨论发表时间-格式化")
public String lastThemeTime;
public boolean checkTopicName(String keyword) {
if (StringUtils.isBlank(keyword)) {
return true;
}
return this.topicTitle.contains(keyword);
}
}
......@@ -40,6 +40,12 @@ public class TopicPageDetailQo {
@ApiModelProperty(value = "是否有权限")
private boolean hasPermission;
@ApiModelProperty(value = "是否关注,非专属话题时有效")
private boolean hasFollow;
@ApiModelProperty(value = "管理员")
private String managers;
@ApiModelProperty(value = "关联产品")
private List<TopicAttachement> attachments;
}
......@@ -4,6 +4,7 @@ import com.tanpu.common.api.CommonResp;
import com.tanpu.common.auth.AuthLogin;
import com.tanpu.common.auth.UserHolder;
import com.tanpu.community.api.beans.qo.TopicFollowQo;
import com.tanpu.community.api.beans.qo.TopicPageDetailQo;
import com.tanpu.community.api.beans.qo.TopicRankQo;
import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.beans.req.topic.FollowTopicReq;
......@@ -38,9 +39,9 @@ public class TopicController {
@AuthLogin
@GetMapping(value = "/followList")
@ApiOperation("关注话题列表")
public CommonResp<List<TopicFollowQo>> getFollowList() {
public CommonResp<List<TopicFollowQo>> getFollowList(@RequestParam(required = false,value = "keyword") String keyword) {
return CommonResp.success(topicManager.getFollowTopicList());
return CommonResp.success(topicManager.getFollowTopicList(keyword));
}
......@@ -52,7 +53,7 @@ public class TopicController {
@GetMapping(value = "/detailPage")
@ApiOperation("话题详情页")
public CommonResp<TopicRankQo> getDetail(@RequestParam String topicId) {
public CommonResp<TopicPageDetailQo> getDetail(@RequestParam String topicId) {
return topicManager.getDetail(topicId);
}
......
......@@ -157,12 +157,14 @@ public class CommentManager {
commentQo.setBelongUserOrgName(userInfo.getBelongUserOrgName());
}
// 回复用户名
String replyUserId = commentQo.getReplyUserId();
UserInfoResp replyUser = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, authorId),
60, () -> this.getUserInfo(replyUserId), UserInfoResp.class);
if (replyUser != null) {
commentQo.setReplyUserName(replyUser.getNickName());
if (StringUtils.isNotBlank(commentQo.getReplyUserId())){
UserInfoResp replyUser = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, authorId),
60, () -> this.getUserInfo(commentQo.getReplyUserId()), UserInfoResp.class);
if (replyUser != null) {
commentQo.setReplyUserName(replyUser.getNickName());
}
}
commentQo.setHasLiked(false);
commentQo.setLikeCount(0);
}
......
......@@ -4,6 +4,7 @@ import com.tanpu.common.api.CommonResp;
import com.tanpu.common.auth.UserHolder;
import com.tanpu.common.constant.ErrorCodeConstant;
import com.tanpu.community.api.beans.qo.TopicFollowQo;
import com.tanpu.community.api.beans.qo.TopicPageDetailQo;
import com.tanpu.community.api.beans.qo.TopicRankQo;
import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.beans.req.topic.FollowTopicReq;
......@@ -60,13 +61,15 @@ public class TopicManager {
/**
* 关注话题(讨论区)列表
*
* @param keyword
*/
public List<TopicFollowQo> getFollowTopicList() {
public List<TopicFollowQo> getFollowTopicList(String keyword) {
String userId = userHolder.getUserId();
// 查库
List<TopicFollowQo> topicFollowQos = topicService.queryFollowTopic(userId);
List<TopicFollowQo> topicFollowQos = topicService.queryFollowTopic(keyword, userId);
// 先从缓存中获取浏览量
Map<String, TopicRankQo> topicMap = rankService.getRankTopicList(null).stream().collect(Collectors.toMap(TopicRankQo::getTopicId, o -> o, (a, b) -> a));
......@@ -80,7 +83,7 @@ public class TopicManager {
themeService.queryCommentForTopic(topicFollowQos, userId);
// 排序
topicFollowQos.stream().sorted(Comparator.comparing(TopicFollowQo::getSpecialPermission, Comparator.reverseOrder()).
topicFollowQos.stream().filter(o -> o.checkTopicName(keyword)).sorted(Comparator.comparing(TopicFollowQo::getSpecialPermission, Comparator.reverseOrder()).
thenComparing(TopicFollowQo::getLastThemeTime, Comparator.nullsFirst(String::compareTo).reversed()))
.collect(Collectors.toList());
......@@ -93,7 +96,7 @@ public class TopicManager {
* @param topicId
* @return
*/
public CommonResp<TopicRankQo> getDetail(String topicId) {
public CommonResp<TopicPageDetailQo> getDetail(String topicId) {
TopicEntity topicEntity = topicService.queryOnlineTopicById(topicId);
......@@ -107,7 +110,20 @@ public class TopicManager {
return CommonResp.error(ErrorCodeConstant.TOPIC_PERMISSION_ABORT.getCode(), topicService.getPermissionToast(topicId));
}
return CommonResp.success(rankService.getTopicDetail(topicId));
// DATA Transform
TopicRankQo topicDetail = rankService.getTopicDetail(topicId);
TopicPageDetailQo result = new TopicPageDetailQo();
BeanUtils.copyProperties(topicDetail, result);
// 查询管理员
result.setManagers(topicService.queryManagers(result.getTopicId()));
// 查询关联产品
topicService.queryAttachments(result);
// 是否关注
result.setHasFollow(topicService.checkFollow(result.getTopicId(), userHolder.getUserId()));
return CommonResp.success(result);
}
......@@ -122,6 +138,10 @@ public class TopicManager {
// 检验话题权限是否专属
TopicEntity topicEntity = topicService.queryOnlineTopicById(req.getTopicId());
if (topicEntity == null) {
return CommonResp.error(ErrorCodeConstant.TOPIC_NOT_FOUND.getCode(), "抱歉!该话题已下线。");
}
if (TopicSpecialPermissionEnum.TRUE.getCode().equals(topicEntity.getSpecialPermission())) {
return CommonResp.error(ErrorCodeConstant.ILLEGAL_ARGEMENT.getCode(), "专属话题不支持关注");
}
......
......@@ -2,7 +2,9 @@ package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.common.uuid.UuidGenHelper;
import com.tanpu.community.api.beans.qo.TopicAttachement;
import com.tanpu.community.api.beans.qo.TopicFollowQo;
import com.tanpu.community.api.beans.qo.TopicPageDetailQo;
import com.tanpu.community.api.beans.qo.TopicRankQo;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.StatusEnum;
......@@ -20,6 +22,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
......@@ -79,10 +82,10 @@ public class TopicService {
return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>().in(TopicEntity::getTopicId, topicIds));
}
public List<TopicFollowQo> queryFollowTopic(String userId) {
public List<TopicFollowQo> queryFollowTopic(String keyword, String userId) {
// 用户的关注列表(包括专属)
List<String> followTopicIds = topicFollowRelMapper.selectTopicIdByUserId(userId);
if (CollectionUtils.isEmpty(followTopicIds)){
if (CollectionUtils.isEmpty(followTopicIds)) {
return Collections.emptyList();
}
......@@ -114,7 +117,7 @@ public class TopicService {
public void deleteFollowTopic(String topicId, String userId) {
TopicFollowRelEntity searchResult = topicFollowRelMapper.queryOneByTopicIdAndUserId(topicId, userId);
if (searchResult != null){
if (searchResult != null) {
searchResult.setUnfollowTime(LocalDateTime.now());
searchResult.setDeleteTag(DeleteTagEnum.DELETED.getCode());
topicFollowRelMapper.updateById(searchResult);
......@@ -122,7 +125,7 @@ public class TopicService {
}
public void batchCheckPermission(List<TopicRankQo> content, String userId) {
if (StringUtils.isBlank(userId)){
if (StringUtils.isBlank(userId)) {
return;
}
}
......@@ -156,4 +159,25 @@ public class TopicService {
return "暂无权限参与此话题~您可联系官方客服 021- 了解详情";
// return "该话题仅限" + permission + "可参与哦~";
}
public String queryManagers(String topicId) {
return "小王、小李、小刘";
}
public void queryAttachments(TopicPageDetailQo topic) {
TopicAttachement a1 = TopicAttachement.builder().type("88").detail(null).build();
TopicAttachement a2 = TopicAttachement.builder().type("300").detail(null).build();
TopicAttachement a3 = TopicAttachement.builder().type("323").detail(null).build();
topic.setAttachments(Arrays.asList(a1, a2, a3));
}
public boolean checkFollow(String topicId, String userId) {
if (StringUtils.isBlank(userId)) {
return false;
}
TopicFollowRelEntity topicFollowRelEntity = topicFollowRelMapper.queryOneByTopicIdAndUserId(topicId, userId);
return topicFollowRelEntity != null;
}
}
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