Commit bfc7e982 authored by 张辰's avatar 张辰

Merge branch 'dev' of http://47.100.44.39:10001/tp-backend/tanpu-community into dev

# Conflicts:
#	community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
#	community-service/src/main/java/com/tanpu/community/service/HomePageService.java
parents 9a58c57f 4d4a16b8
package com.tanpu.community.api.beans.qo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 话题列表页
*/
@Data
@ApiModel("话题列表对象")
public class TopicTitileQo {
@ApiModelProperty("话题ID")
private String topicId;
@ApiModelProperty("话题名称")
private String topicTitle;
@ApiModelProperty("讨论数")
private String discussionCount;
@ApiModelProperty("浏览量")
private String viewCount;
}
package com.tanpu.community.api.beans.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
@Data
@ApiModel(value="TopicDTO对象", description="话题")
public class TopicDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "话题名称")
private String topicTitle;
@ApiModelProperty(value = "是否置顶")
private Integer isTop;
@ApiModelProperty(value = "是否隐藏")
private Integer isConceal;
private LocalDateTime createTime;
private LocalDateTime updateTime;
private Integer deleteTag;
@ApiModelProperty(value = "帖子量")
private Integer themeCount;
@ApiModelProperty(value = "浏览量")
private Integer viewCount;
@ApiModelProperty(value = "点赞量")
private Integer likeCount;
@ApiModelProperty(value = "总用户数")
private Integer UserCount;
@ApiModelProperty
@Override
public String toString() {
return "TopicEntity{" +
"id=" + id +
", topicTitle=" + topicTitle +
", isTop=" + isTop +
", isConceal=" + isConceal +
", createTime=" + createTime +
", updateTime=" + updateTime +
", deleteTag=" + deleteTag +
"}";
}
}
package com.tanpu.community.api.enums;
/**
* @program: wealthgrow-new
* @description: 基金公司类型枚举
* @author: zejia zj wu
* @create: 2021-07-22 11:24
**/
public enum FundCompanyTypeEnum {
PUBLIC(0,"公募"),
PRIVATE(1,"私募");
private Integer code;
private String type;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
FundCompanyTypeEnum(Integer code, String type) {
this.code = code;
this.type = type;
}
}
package com.tanpu.community.api.enums;
public enum PersonalCenterTypeEnum {
GENERAL(1,"普通主页"),
CHIEF(2,"首席投顾主页"),
ORG(3,"机构主页");
private Integer code;
private String type;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
PersonalCenterTypeEnum(Integer code, String type) {
this.code = code;
this.type = type;
}
}
package com.tanpu.community.api.enums;
/**
* @program: wealthgrow-new
* @description: 圈子关注状态枚举
* @author: zejia zj wu
* @create: 2021-07-22 11:15
**/
public enum ShowFollowStatusEnum {
NOT_FOLLOWED(0,"未关注"),
FOLLOWED(1,"已关注");
private Integer code;
private String type;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
ShowFollowStatusEnum(Integer code, String type) {
this.code = code;
this.type = type;
}
}
package com.tanpu.community.api.enums;
import com.tanpu.common.api.CommonResp;
import javax.validation.constraints.NotNull;
/**
* @program: wealthgrow-new
* @description: 用户权限等级
* @author: zejia zj wu
* @create: 2021-07-22 10:59
**/
public enum UserLevelEnum {
USER_TOURIST(0, "游客", "游客"),
USER_REGISTERED(1, "注册会员", "注册会员"),
/**
* 如果当前登录用户是投资人且要求权限大于投资人 返回 actionCode T1
* 弹框提示
* 该功能只对{levelGrade}开放哦
* 如需更改认证信息,可前往“我的”进行重新认证
* 点击「知道了」关闭弹框
*/
USER_INVESTOR(10, "投资人", "普通会员", "D2"),
/**
* tamp理顾问卷 D2
*/
USER_FINANCIAL_PRACTITIONER(20, "探普理顾", "投资顾问", "D2"),
/**
* tamp专家理顾问卷 D3
*/
USER_FINANCIAL_ADVISOR(30, "探普专家理顾", "专家投顾", "D3"),
/**
* 发生基金交易 (系统自动判断) T0 (提示文案: 该功能只对完成交易的探普理财师开放)
*/
USER_SENIOR_FINANCIAL_ADVISER(40, "交易理财师", "专家投顾", "T0"),
/**
* 探普签约理财师
*/
USER_CHIEF_FINANCIAL_ADVISER(50, "首席投顾", "首席投顾", "T0"),
/**
* 白名单用户
*/
USER_WHITE_LIST(999, "白名单用户", "特定用户", "T0"),
;
private int code;
private String name;
private String label;
private String actionCode;
UserLevelEnum(int code, String name, String label) {
this.code = code;
this.name = name;
this.label = label;
}
UserLevelEnum(int code, String name, String label, String functionCode) {
this.code = code;
this.name = name;
this.label = label;
this.actionCode = functionCode;
}
public int getCode() {
return code;
}
public String getName() {
return name;
}
public String getLabel() {
return label;
}
public String getActionCode() {
return actionCode;
}
}
package com.tanpu.community.api.enums;
public enum UserTypeEnum {
USER_GENERAL(1,"普通个人"),
USER_ORG(2,"机构账号"),
USER_ORG_PERSONNEL(3,"机构人员");
private Integer code;
private String type;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
UserTypeEnum(Integer code, String type) {
this.code = code;
this.type = type;
}
}
package com.tanpu.community.dao.entity.community;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
/**
* <p>
* 个人主页
* </p>
*
* @author xudong
* @since 2021-07-22
*/
@TableName("home_page")
@ApiModel(value="HomePageEntity对象", description="个人主页")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class HomePageEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "头像url")
private String headImg;
@ApiModelProperty(value = "昵称")
private String nickName;
@ApiModelProperty(value = "个人简介")
private String introduction;
@ApiModelProperty(value = "性别")
private Integer sex;
@ApiModelProperty(value = "地址")
private String location;
private LocalDateTime createTime;
private LocalDateTime updateTime;
private Integer deleteTag;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getHeadImg() {
return headImg;
}
public void setHeadImg(String headImg) {
this.headImg = headImg;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getIntroduction() {
return introduction;
}
public void setIntroduction(String introduction) {
this.introduction = introduction;
}
public Integer getSex() {
return sex;
}
public void setSex(Integer sex) {
this.sex = sex;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public LocalDateTime getCreateTime() {
return createTime;
}
public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime;
}
public LocalDateTime getUpdateTime() {
return updateTime;
}
public void setUpdateTime(LocalDateTime updateTime) {
this.updateTime = updateTime;
}
public Integer getDeleteTag() {
return deleteTag;
}
public void setDeleteTag(Integer deleteTag) {
this.deleteTag = deleteTag;
}
@Override
public String toString() {
return "HomePageEntity{" +
"id=" + id +
", userId=" + userId +
", headImg=" + headImg +
", nickName=" + nickName +
", introduction=" + introduction +
", sex=" + sex +
", location=" + location +
", createTime=" + createTime +
", updateTime=" + updateTime +
", deleteTag=" + deleteTag +
"}";
}
}
package com.tanpu.community.dao.mapper.community;
import com.tanpu.community.dao.entity.community.HomePageEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 个人主页 Mapper 接口
* </p>
*
* @author xudong
* @since 2021-07-22
*/
public interface HomePageMapper extends BaseMapper<HomePageEntity> {
}
......@@ -49,6 +49,7 @@ public class CommentManager {
private RedisCache redisCache;
// 评论(对主题)
// 发表评论(对主题)
public void comment(CreateCommentReq req, String userId) {
CommentEntity commentEntity = CommentEntity.builder()
.themeId(req.getThemeId())
......@@ -62,7 +63,7 @@ public class CommentManager {
commentService.insertComment(commentEntity);
}
//查询
//查询评论
public List<CommentQo> queryComments(String themeId, String userId) {
List<CommentEntity> commentEntities = commentService.selectByThemeIdAndParentId(themeId, null);
List<CommentQo> commentQos = ConvertUtil.commentEntity2Qos(commentEntities);
......@@ -70,7 +71,7 @@ public class CommentManager {
Set<String> likeCommentList = collectionService.getListByUser(userId, CollectionTypeEnum.LIKE_COMMENT);
for (CommentQo commentQo : commentQos) {
//用户信息
//查询用户信息
String authorId = commentQo.getAuthorId();
CommonResp<UserInfoNew> userInfoNewCommonResp = redisCache.getObject(StringUtils.joinWith(CACGE_FEIGN_USER_INFO, authorId),
60 * 10, () -> feignClientForFatools.queryUsersListNew(authorId), CommonResp.class);
......@@ -93,10 +94,6 @@ public class CommentManager {
Integer countByTypeAndId = collectionService.getCountByTypeAndId(commentId, CollectionTypeEnum.LIKE_COMMENT);
commentQo.setLikeCount(countByTypeAndId);
//二级评论,本期不上线
// List<CommentEntity> CommentLv2Entities = commentService.selectByThemeIdAndParentId(themeId, commentId);
// List<CommentLv2Qo> commentLv2Qos = ConvertUtil.commentLv2Entity2Qos(CommentLv2Entities);
// commentQo.setCommentLv2Qos(commentLv2Qos);
}
//排序:点赞降序+时间降序
return commentQos.stream().sorted(Comparator.comparing(CommentQo::getLikeCount, Comparator.reverseOrder()).
......@@ -118,8 +115,8 @@ public class CommentManager {
public void report(ReportCommentReq req, String userId) {
//更改举报状态
commentService.updateReportStatus(req.getCommentId());
//写入举报日志
//写入举报记录表
CommentEntity commentEntity = commentService.queryByCommentId(req.getCommentId());
reportLogService.insert(ReportTypeEnum.COMMENT, userId,req.getCommentId(),commentEntity.getAuthorId(),req.getReason());
reportLogService.insert(ReportTypeEnum.COMMENT, userId, req.getCommentId(), commentEntity.getAuthorId(), req.getReason());
}
}
......@@ -38,14 +38,14 @@ public class FileManager {
String originalName = file.getOriginalFilename();
if (data.length == 0 || StringUtils.isEmpty(originalName)){
if (data.length == 0 || StringUtils.isEmpty(originalName)) {
throw new BizException("上传文件为空");
}
FileRecordEntity fileRecordEntity = ossFileService.uploadFile(data, originalName);
return ConvertUtil.fileRecordEntity2Resp(fileRecordEntity);
}
public Map<String,String> getFileUrlByIds(List<String> fileIds){
public Map<String, String> getFileUrlByIds(List<String> fileIds) {
return ossFileService.queryByIds(fileIds).stream()
.collect(Collectors.toMap(FileRecordEntity::getFileId, FileRecordEntity::getUrl));
}
......
......@@ -11,8 +11,7 @@ import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.beans.resp.Customer;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNew;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoOrg;
import com.tanpu.community.api.enums.OperationTypeEnum;
import com.tanpu.community.api.enums.QueryFollowTypeEnum;
import com.tanpu.community.api.enums.*;
import com.tanpu.community.dao.entity.community.FollowRelEntity;
import com.tanpu.community.dao.entity.fund.CompanyInfo;
import com.tanpu.community.dao.entity.fund.FundInfo;
......@@ -76,10 +75,10 @@ public class HomePageManager {
if (StringUtils.isNotBlank(userId) && !StringUtils.equals(userIdMyself, userId)) { //查询别人的个人主页
// 关注 按钮的显示逻辑
FollowRelEntity followRelEntity = followRelService.queryRecord(userId, userIdMyself);
if (ObjectUtils.allNotNull(followRelEntity) && BizStatus.DeleteTag.tag_init == followRelEntity.getDeleteTag()){
userInfoNew.setShowFollowStatus(1); // 已关注
if (ObjectUtils.allNotNull(followRelEntity) && BizStatus.DeleteTag.tag_init == followRelEntity.getDeleteTag()) {
userInfoNew.setShowFollowStatus(ShowFollowStatusEnum.FOLLOWED.getCode()); // 已关注
} else {
userInfoNew.setShowFollowStatus(0); // 未关注
userInfoNew.setShowFollowStatus(ShowFollowStatusEnum.NOT_FOLLOWED.getCode()); // 未关注
}
if (userInfoNew.getWorkshopStatus() == 2) userInfoNew.setWorkshopStatus(1); //别人的主页不需要展示 工作室
} else {
......@@ -90,9 +89,9 @@ public class HomePageManager {
getFansNUmAndFollowNum(userInfoNew);
// 主页类型 显示逻辑
if (50 == userInfoNew.getLevelGrade()){
if (UserLevelEnum.USER_CHIEF_FINANCIAL_ADVISER.getCode() == userInfoNew.getLevelGrade()) {
// 首席投顾
userInfoNew.setPersonalCenterType(2);
userInfoNew.setPersonalCenterType(PersonalCenterTypeEnum.CHIEF.getCode());
// 成功案例客户
// 默认显示该投顾管理的客户里,总资产最高的客户
if (StringUtils.isBlank(userInfoNew.getUserInfoNewChief().getClientId())) {
......@@ -103,11 +102,12 @@ public class HomePageManager {
} else {
userInfoNew.getUserInfoNewChief().setClientId(null);
}
}
} else if (2 == userInfoNew.getUserType()){
} else if (UserTypeEnum.USER_ORG.getCode() == userInfoNew.getUserType()) {
// 机构账号
userInfoNew.setPersonalCenterType(3);
if (0 == userInfoNew.getUserInfoNewOrg().getBelongOrgType() && StringUtils.isNotBlank(userInfoNew.getUserInfoNewOrg().getBelongOrgId())){ // 公募
userInfoNew.setPersonalCenterType(PersonalCenterTypeEnum.ORG.getCode());
if (FundCompanyTypeEnum.PUBLIC.getCode() == userInfoNew.getUserInfoNewOrg().getBelongOrgType() && StringUtils.isNotBlank(userInfoNew.getUserInfoNewOrg().getBelongOrgId())) { // 公募
//设置 基金数
MfAdvisorscalerank mfAdvisorscalerank = mfAdvisorscalerankMapper.selectOne(new LambdaQueryWrapper<MfAdvisorscalerank>()
.eq(MfAdvisorscalerank::getInvestadvisorcode, userInfoNew.getUserInfoNewOrg().getBelongOrgId())
......@@ -119,7 +119,7 @@ public class HomePageManager {
.last("limit 1"));
userInfoNew.setFounded(ObjectUtils.anyNotNull(mfInvestadvisoroutline) ? mfInvestadvisoroutline.getEstablishmentdate().getTime() : null);
}
if(1 == userInfoNew.getUserInfoNewOrg().getBelongOrgType() && StringUtils.isNotBlank(userInfoNew.getUserInfoNewOrg().getBelongOrgId())){ // 私募
if (FundCompanyTypeEnum.PRIVATE.getCode() == userInfoNew.getUserInfoNewOrg().getBelongOrgType() && StringUtils.isNotBlank(userInfoNew.getUserInfoNewOrg().getBelongOrgId())) { // 私募
//设置 基金数
Integer integer = fundInfoMapper.selectCount(new LambdaQueryWrapper<FundInfo>().eq(FundInfo::getTrustId, userInfoNew.getUserInfoNewOrg().getBelongOrgId()));
userInfoNew.setFundNumber(integer);
......@@ -133,7 +133,7 @@ public class HomePageManager {
}
//设置团队成员
CommonResp<List<UserInfoOrg>> usetInfoByOrgUserId = feignClientForFatools.getUsetInfoByOrgUserId(userId);
if (usetInfoByOrgUserId.isSuccess()){
if (usetInfoByOrgUserId.isSuccess()) {
List<UserInfoOrg> userInfoOrgs = usetInfoByOrgUserId.getData();
// 设置关注列表
List<String> collect = userInfoOrgs.stream().map(UserInfoOrg::getUserId).collect(Collectors.toList());
......@@ -143,14 +143,15 @@ public class HomePageManager {
.eq(FollowRelEntity::getDeleteTag, BizStatus.DeleteTag.tag_init));
Map<String, FollowRelEntity> collect1 = followRelEntities.stream().collect(Collectors.toMap(FollowRelEntity::getFollowUserId, Function.identity()));
userInfoOrgs.forEach(userInfoOrg -> {
if (collect1.containsKey(userInfoOrg.getUserId())) userInfoOrg.setIsFollower(1);
if (collect1.containsKey(userInfoOrg.getUserId()))
userInfoOrg.setIsFollower(ShowFollowStatusEnum.FOLLOWED.getCode());//1已关注
});
userInfoNew.setUserInfoOrgList(userInfoOrgs);
}
} else {
//普通主页
userInfoNew.setPersonalCenterType(1);
userInfoNew.setPersonalCenterType(PersonalCenterTypeEnum.GENERAL.getCode());
//设置课程数(学习数)
CommonResp<Integer> integerCommonResp = feignClientForCourse.getStudyCourseCount(userId);
if (integerCommonResp.isSuccess()) userInfoNew.setCourseNumber(integerCommonResp.getData());
......@@ -166,6 +167,7 @@ public class HomePageManager {
userInfoNew.setFollowNumber(followNumber);
userInfoNew.setFansNumber(fansNumber);
}
public List<Customer> queryUserCustomerList(String userId) {
CommonResp<List<Customer>> ifaCustomerList = feignClientForDiagnose.getIfaCustomerList(userId);
if (ifaCustomerList.isSuccess()) return ifaCustomerList.getData();
......@@ -209,5 +211,4 @@ public class HomePageManager {
}
}
......@@ -17,6 +17,7 @@ import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.service.*;
import com.tanpu.community.service.base.ESService;
import com.tanpu.community.util.ConvertUtil;
import com.tanpu.community.util.RankUtils;
import com.tanpu.community.util.TencentcloudUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
......@@ -107,9 +108,6 @@ public class ThemeManager {
*/
@Transactional
public CreateThemeResp publishTheme(CreateThemeReq req, String userId) {
//直播类型做转播检查
List<ThemeContentReq> contents = req.getContent();
liveRelayCheck(userId, contents);
//保存主题表
ThemeEntity themeEntity = new ThemeEntity();
......@@ -147,23 +145,38 @@ public class ThemeManager {
return CreateThemeResp.builder().themeId(themeEntity.getThemeId()).build();
}
//转发主题
public CreateThemeResp forward(ForwardThemeReq req, String userId) {
ThemeEntity targetTheme = themeService.queryByThemeId(req.getFormerThemeId());
ThemeEntity themeEntity = ThemeEntity.builder()
.content(JsonUtil.toJson(req.getContent()))
.topicId(req.getTopicId())
.formerThemeId(req.getFormerThemeId())
.authorId(userId)
.themeType(ThemeTypeEnum.FORWARD.getCode())
.build();
if (StringUtils.isEmpty(req.getEditThemeId()) || req.getEditThemeId() == req.getFormerThemeId()) {
//新建
themeService.insertTheme(themeEntity);
} else {
//修改
themeService.update(themeEntity, req.getEditThemeId());
themeEntity.setThemeId(req.getEditThemeId());
/**
* 返回主题列表
*
* @param req
* @param userId
* @return
*/
}
return CreateThemeResp.builder().themeId(themeEntity.getThemeId()).build();
}
//查询主题列表:推荐/关注/热门/最新
public List<ThemeQo> queryThemes(ThemeListReq req, String userId) {
List<ThemeEntity> themeEntities = new ArrayList<>();
if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) {
//推荐
// themeEntities = themeService.selectExcludeUser(userId, req.getLastId(), req.getPageSize());
List<String> recommendThemeIds = rankService.getHotAndNewThemes(100, 100);
themeEntities = themeService.queryByThemeIdsExcludeUser(recommendThemeIds, userId, req.getLastId(), req.getPageSize());
List<String> recommendThemeIds = rankService.getHotAndNewThemes(100, 100,userId);
themeEntities = themeService.queryByThemeIdsExcludeUser(recommendThemeIds, null, req.getLastId(), req.getPageSize());
themeEntities = RankUtils.sortThemeEntityByIds(themeEntities, recommendThemeIds);
} else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) {
//根据关注列表查询
List<String> fansList = followRelService.queryFansByFollowerId(userId);
......@@ -172,8 +185,9 @@ public class ThemeManager {
} else if (ThemeListTypeEnum.TOPIC_HOT.getCode().equals(req.getType())) {
//根据话题查询热门
if (StringUtils.isEmpty(req.getTopicId())) throw new BizException("TopicId为空");
List<ThemeAnalysDO> rankThemeList = rankService.getRankThemeList(req.getTopicId());
themeEntities = themeService.queryByTopic(req.getTopicId(), req.getLastId(), req.getPageSize());
List<String> rankThemeIds = rankService.getRankThemeListByTopic(req.getTopicId());
themeEntities = themeService.queryByThemeIdsExcludeUser(rankThemeIds, null, req.getLastId(), req.getPageSize());
themeEntities = RankUtils.sortThemeEntityByIds(themeEntities,rankThemeIds);
} else if (ThemeListTypeEnum.TOPIC_LATEST.getCode().equals(req.getType())) {
//根据话题查询最新
if (StringUtils.isEmpty(req.getTopicId())) throw new BizException("TopicId为空");
......@@ -190,20 +204,8 @@ public class ThemeManager {
}
/**
* 举报主题
* @param req
* @param userId
*/
public void report(ReportThemeReq req, String userId) {
//更改举报状态
themeService.updateReportStatus(req.getThemeId());
//写入举报日志
ThemeEntity themeEntity = themeService.queryByThemeId(req.getThemeId());
reportLogService.insert(ReportTypeEnum.THEME, userId,req.getThemeId(),themeEntity.getAuthorId(),req.getReason());
}
// 返回用户发布、回复、收藏的主题列表
// 返回用户发布、回复、点赞、收藏的主题列表
public List<ThemeQo> queryThemesByUser(QueryRecordThemeReq req, String userId) {
List<ThemeEntity> themeEntities = Collections.emptyList();
......@@ -228,51 +230,6 @@ public class ThemeManager {
return themeQos;
}
private List<ThemeQo> getCommentThemeQos(QueryRecordThemeReq req, String userId) {
List<ThemeQo> commentThemeList = new ArrayList<>();
List<ThemeEntity> themeEntities;
//评论列表
List<CommentEntity> commentEntities = commentService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
//当前用户信息
UserInfoEntity userInfoEntity = userInfoService.queryUserById(req.getUserId());
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(replyThemeIds)) {
return commentThemeList;
}
themeEntities = themeService.queryByThemeIds(new ArrayList<>(replyThemeIds));
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
//组装附件
batchFeignCallService.getAttachDetailByBatch(themeQos);
//主题列表
Map<String, ThemeQo> themeMap = themeQos.stream()
.collect(Collectors.toMap(ThemeQo::getThemeId, o -> o));
//主题+评论封装转发对象
for (CommentEntity commentEntity : commentEntities) {
String themeId = commentEntity.getThemeId();
//评论内容包装到ThemeContentQo里
ThemeContentQo commentContent = ThemeContentQo.builder()
.type(RelTypeEnum.TEXT.type)
.value(commentEntity.getContent())
.build();
//原主题包装到FormerThemeQo中
ThemeQo themeQo = themeMap.get(themeId);
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo commentThemeQo = ThemeQo.builder()
.authorId(userInfoEntity.getId())
.nickName(userInfoEntity.getUiUsernameMp())
.userImg(userInfoEntity.getUiHeadimgMp())
.content(Arrays.asList(commentContent))
.formerTheme(f)
.commentId(commentEntity.getCommentId())
.themeType(ThemeTypeEnum.RES_COMMENT.getCode())
.build();
commentThemeList.add(commentThemeQo);
}
return null;
}
//查询正文
public ThemeQo getDetail(String themeId, String userId) {
......@@ -305,27 +262,23 @@ public class ThemeManager {
}
}
//转发
public CreateThemeResp forward(ForwardThemeReq req, String userId) {
ThemeEntity targetTheme = themeService.queryByThemeId(req.getFormerThemeId());
ThemeEntity themeEntity = ThemeEntity.builder()
.content(JsonUtil.toJson(req.getContent()))
.topicId(req.getTopicId())
.formerThemeId(req.getFormerThemeId())
.authorId(userId)
.themeType(ThemeTypeEnum.FORWARD.getCode())
.build();
//举报主题
public void report(ReportThemeReq req, String userId) {
//更改举报状态
themeService.updateReportStatus(req.getThemeId());
//写入举报记录表
ThemeEntity themeEntity = themeService.queryByThemeId(req.getThemeId());
reportLogService.insert(ReportTypeEnum.THEME, userId, req.getThemeId(), themeEntity.getAuthorId(), req.getReason());
}
if (StringUtils.isEmpty(req.getEditThemeId()) || req.getEditThemeId() == req.getFormerThemeId()) {
//新建
themeService.insertTheme(themeEntity);
} else {
//修改
themeService.update(themeEntity, req.getEditThemeId());
themeEntity.setThemeId(req.getEditThemeId());
}
return CreateThemeResp.builder().themeId(themeEntity.getThemeId()).build();
//关注用户是否有更新
public Integer getFollowUpdateCount(String userId) {
LocalDateTime lastViewTime = visitSummaryService.queryLatestViewFollow(userId);
List<String> fansList = followRelService.queryFansByFollowerId(userId);
return themeService.queryCountFromLastTime(fansList, lastViewTime);
}
// 屏蔽(用户)
......@@ -351,6 +304,8 @@ public class ThemeManager {
}
//主题Entity转QO
private List<ThemeQo> convertEntityToQo(List<ThemeEntity> themeEntities, String userId) {
//Entity转Qo
......@@ -373,7 +328,6 @@ public class ThemeManager {
buildFormerTheme(themeQo);
//是否关注作者
String authorId = themeQo.getAuthorId();
Set<String> fansSet = new HashSet<>(followRelService.queryFansByFollowerId(userId));
......@@ -420,14 +374,10 @@ public class ThemeManager {
}
public Integer getFollowUpdateCount(String userId) {
LocalDateTime lastViewTime = visitSummaryService.queryLatestViewFollow(userId);
List<String> fansList = followRelService.queryFansByFollowerId(userId);
return themeService.queryCountFromLastTime(fansList, lastViewTime);
}
/**
* 腾讯云-内容检测
*
* @param content
*/
private void checkContent(String content) {
......@@ -443,12 +393,13 @@ public class ThemeManager {
throw new BizException("内容校验失败,请检查内容后重新发送");
}
}
return ;
return;
}
/**
* 直播类型做转播检查
*
* @param userId
* @param contents
*/
......@@ -467,4 +418,56 @@ public class ThemeManager {
}
/**
* 查询用户评论过的主题,并封装成转发主题结构
*
* @param req
* @param userId 当前用户
* @return
*/
private List<ThemeQo> getCommentThemeQos(QueryRecordThemeReq req, String userId) {
List<ThemeQo> commentThemeList = new ArrayList<>();
List<ThemeEntity> themeEntities;
//评论列表
List<CommentEntity> commentEntities = commentService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
//当前用户信息
UserInfoEntity userInfoEntity = userInfoService.queryUserById(req.getUserId());
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(replyThemeIds)) {
return commentThemeList;
}
themeEntities = themeService.queryByThemeIds(new ArrayList<>(replyThemeIds));
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
//组装附件
batchFeignCallService.getAttachDetailByBatch(themeQos);
//主题列表
Map<String, ThemeQo> themeMap = themeQos.stream()
.collect(Collectors.toMap(ThemeQo::getThemeId, o -> o));
//主题+评论封装转发对象
for (CommentEntity commentEntity : commentEntities) {
String themeId = commentEntity.getThemeId();
//评论内容包装到ThemeContentQo里
ThemeContentQo commentContent = ThemeContentQo.builder()
.type(RelTypeEnum.TEXT.type)
.value(commentEntity.getContent())
.build();
//原主题包装到FormerThemeQo中
ThemeQo themeQo = themeMap.get(themeId);
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo commentThemeQo = ThemeQo.builder()
.authorId(userInfoEntity.getId())
.nickName(userInfoEntity.getUiUsernameMp())
.userImg(userInfoEntity.getUiHeadimgMp())
.content(Arrays.asList(commentContent))
.formerTheme(f)
.commentId(commentEntity.getCommentId())
.themeType(ThemeTypeEnum.RES_COMMENT.getCode())
.build();
commentThemeList.add(commentThemeQo);
}
return commentThemeList;
}
}
......@@ -43,7 +43,7 @@ public class TopicManager {
//新增话题
public void insertTopic(String topicTitle, String userId) {
if (topicService.queryByTitile(topicTitle) == null) {
throw new BizException("话题名称已存在:"+topicTitle);
throw new BizException("话题名称已存在:" + topicTitle);
}
topicService.addTopic(topicTitle, userId);
......@@ -66,7 +66,6 @@ public class TopicManager {
}
public void refreshRedisCache() {
List<TopicEntity> topicEntities = topicService.queryAll();
for (TopicEntity topic : topicEntities) {
......
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.dao.entity.community.HomePageEntity;
import com.tanpu.community.dao.mapper.community.HomePageMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class HomePageService {
@Resource
private HomePageMapper homePageMapper;
public HomePageEntity selectByUserId(String userId) {
return homePageMapper.selectOne(new LambdaQueryWrapper<HomePageEntity>()
.eq(HomePageEntity::getUserId, userId)
.eq(HomePageEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode()));
}
public List<HomePageEntity> selectListByUserIds(List<String> userIds) {
if (CollectionUtils.isEmpty(userIds)) {
return Collections.emptyList();
}
return homePageMapper.selectList(new LambdaQueryWrapper<HomePageEntity>()
.eq(HomePageEntity::getDeleteTag,DeleteTagEnum.NOT_DELETED.getCode())
.in(HomePageEntity::getUserId, userIds));
}
public void update(HomePageEntity entity) {
homePageMapper.updateById(entity);
}
public void insert(HomePageEntity entity) {
homePageMapper.insert(entity);
}
}
......@@ -38,7 +38,7 @@ public class RankService {
* 计算主题热度排行
*/
public void rankThemes() {
List<ThemeEntity> themeEntities = themeService.queryAll();
List<ThemeEntity> themeEntities = themeService.queryRecent14days();
List<ThemeAnalysDO> themeAnalysDOS = ConvertUtil.themeEntityToAnalysDOs(themeEntities);
for (ThemeAnalysDO theme : themeAnalysDOS) {
String themeId = theme.getThemeId();
......@@ -101,8 +101,11 @@ public class RankService {
* @param newCount
* @return
*/
public List<String> getHotAndNewThemes(Integer hotCount, Integer newCount) {
Set<String> hotThemeIds = this.rankThemeList.stream().limit(hotCount).map(ThemeAnalysDO::getThemeId).collect(Collectors.toSet());
public List<String> getHotAndNewThemes(Integer hotCount, Integer newCount,String userId) {
Set<String> hotThemeIds = this.rankThemeList.stream().limit(hotCount)
.filter(o->!userId.equals(o.getAuthorId()))
.map(ThemeAnalysDO::getThemeId)
.collect(Collectors.toSet());
Set<String> newThemeIds = themeService.selectExcludeUser(null, null, newCount)
.stream().map(ThemeEntity::getThemeId).collect(Collectors.toSet());
hotThemeIds.addAll(newThemeIds);
......@@ -118,13 +121,13 @@ public class RankService {
if (this.rankTopicList.size()==0){
rankTopics();
}
List<TopicRankQo> matchTopic = this.rankTopicList.stream().filter(o -> o.getTopicId().equals(topicId)).limit(1).collect(Collectors.toList());
List<TopicRankQo> matchTopic = this.rankTopicList.stream().filter(o -> topicId.equals(o.getTopicId())).limit(1).collect(Collectors.toList());
matchTopic.add(new TopicRankQo());
return matchTopic.get(0);
}
public List<ThemeAnalysDO> getRankThemeList() {
public List<ThemeAnalysDO> getRankThemeListByTopic() {
if (this.rankThemeList.size()==0){
rankThemes();
}
......@@ -145,10 +148,12 @@ public class RankService {
return rankTopicListTop4;
}
public List<ThemeAnalysDO> getRankThemeList(String topicId) {
public List<String> getRankThemeListByTopic(String topicId) {
if (this.rankThemeList.size()==0){
this.rankThemes();
}
return rankThemeList.stream().filter(o->o.getTopicId().equals(topicId)).collect(Collectors.toList());
return rankThemeList.stream().filter(o->topicId.equals(o.getTopicId()))
.map(ThemeAnalysDO::getThemeId)
.collect(Collectors.toList());
}
}
......@@ -10,6 +10,7 @@ import com.tanpu.community.api.enums.ReportStatusEnum;
import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.mapper.community.ThemeMapper;
import com.tanpu.community.util.TimeUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -49,14 +50,11 @@ public class ThemeService {
themeMapper.update(themeEntity, new LambdaUpdateWrapper<ThemeEntity>().eq(ThemeEntity::getThemeId, themeId));
}
/**
* 根据主题Id查询列表
*
* @return
*/
public List<ThemeEntity> queryAll() {
//14天内所有主题
public List<ThemeEntity> queryRecent14days() {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
.gt(ThemeEntity::getCreateTime, TimeUtils.getDaysBefore(14));
return themeMapper.selectList(queryWrapper);
}
......
......@@ -2,20 +2,17 @@ package com.tanpu.community.util;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.resp.FileUploadResp;
import com.tanpu.community.api.beans.vo.ImagesDTO;
import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg;
import com.tanpu.community.api.beans.vo.TopicDTO;
import com.tanpu.community.api.beans.qo.*;
import com.tanpu.community.api.beans.req.theme.CreateThemeReq;
import com.tanpu.community.api.beans.req.theme.ThemeContentReq;
import com.tanpu.community.api.beans.resp.FileUploadResp;
import com.tanpu.community.api.beans.vo.ImagesDTO;
import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNew;
import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.RelTypeEnum;
import com.tanpu.community.api.enums.TopicStatusEnum;
import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.dao.entity.user.UserInfoEntity;
import org.elasticsearch.common.recycler.Recycler;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;
......@@ -29,18 +26,15 @@ import java.util.stream.Collectors;
public class ConvertUtil {
/**
* THEME
*/
public static ThemeQo themeEntityToQo(ThemeEntity themeEntity) {
if (themeEntity == null) {
return null;
}
ThemeQo themeQO = new ThemeQo();
BeanUtils.copyProperties(themeEntity, themeQO);
themeQO.setUpdateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getUpdateTime()));
themeQO.setCreateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getCreateTime()));
themeQO.setUpToNowTime(TimeUtil.calUpToNowTime(themeEntity.getCreateTime()));
themeQO.setUpdateTime(TimeUtils.getTimestampOfDateTime(themeEntity.getUpdateTime()));
themeQO.setCreateTime(TimeUtils.getTimestampOfDateTime(themeEntity.getCreateTime()));
themeQO.setUpToNowTime(TimeUtils.calUpToNowTime(themeEntity.getCreateTime()));
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() {
});
themeQO.setContent(themeContentQos);
......@@ -53,7 +47,7 @@ public class ConvertUtil {
}
ThemeAnalysDO themeAnalysDO = new ThemeAnalysDO();
BeanUtils.copyProperties(themeEntity, themeAnalysDO);
themeAnalysDO.setMinuteTillNow(TimeUtil.calMinuteTillNow(themeEntity.getCreateTime()));
themeAnalysDO.setMinuteTillNow(TimeUtils.calMinuteTillNow(themeEntity.getCreateTime()));
return themeAnalysDO;
}
......@@ -93,20 +87,11 @@ public class ConvertUtil {
}
/**
* TOPIC
*/
public static TopicDTO topicEntityToDTO(TopicEntity topicEntity) {
TopicDTO topicDTO = new TopicDTO();
BeanUtils.copyProperties(topicEntity, topicDTO);
return topicDTO;
}
public static TopicRankQo topicEntityToHotQo(TopicEntity topicEntity) {
TopicRankQo topicRankQo = new TopicRankQo();
BeanUtils.copyProperties(topicEntity, topicRankQo);
//2小时内发帖,添加新话题标签
if(TimeUtil.calMinuteTillNow(topicEntity.getCreateTime())<120){
if(TimeUtils.calMinuteTillNow(topicEntity.getCreateTime())<120){
topicRankQo.setType(TopicStatusEnum.NEWEST.getCode());
}
return topicRankQo;
......@@ -119,16 +104,11 @@ public class ConvertUtil {
return topicEntities.stream().map(ConvertUtil::topicEntityToHotQo).collect(Collectors.toList());
}
public static TopicTitileQo topicToBriefInfoDTO(TopicEntity topicEntity) {
TopicTitileQo topicTitileQo = new TopicTitileQo();
BeanUtils.copyProperties(topicEntity, topicTitileQo);
return topicTitileQo;
}
public static CommentQo commentEntity2Qo(CommentEntity entity) {
CommentQo qo = new CommentQo();
BeanUtils.copyProperties(entity, qo);
qo.setUpdateTime(TimeUtil.getTimestampOfDateTime(entity.getUpdateTime()));
qo.setUpdateTime(TimeUtils.getTimestampOfDateTime(entity.getUpdateTime()));
return qo;
}
......@@ -136,40 +116,6 @@ public class ConvertUtil {
return entities.stream().map(ConvertUtil::commentEntity2Qo).collect(Collectors.toList());
}
public static CommentLv2Qo commentLv2Entity2Qo(CommentEntity entity) {
CommentLv2Qo qo = new CommentLv2Qo();
BeanUtils.copyProperties(entity, qo);
return qo;
}
public static List<CommentLv2Qo> commentLv2Entity2Qos(List<CommentEntity> entities) {
return entities.stream().map(ConvertUtil::commentLv2Entity2Qo).collect(Collectors.toList());
}
public static List<TopicDTO> topicEntitiesToDTOs(List<TopicEntity> topicEntities) {
return topicEntities.stream().map(ConvertUtil::topicEntityToDTO).collect(Collectors.toList());
}
public static List<TopicTitileQo> topicEntitiesToBriefDTOs(List<TopicEntity> topicEntities) {
return topicEntities.stream().map(ConvertUtil::topicToBriefInfoDTO).collect(Collectors.toList());
}
public static DeleteTagEnum deleteTagShift(DeleteTagEnum deleteTagEnum) {
if (deleteTagEnum.getCode().equals(DeleteTagEnum.NOT_DELETED.getCode())) {
return DeleteTagEnum.DELETED;
} else {
return DeleteTagEnum.NOT_DELETED;
}
}
public static Integer deleteTagShift(Integer deleteTag) {
if (deleteTag.equals(DeleteTagEnum.NOT_DELETED.getCode())) {
return DeleteTagEnum.DELETED.getCode();
} else {
return DeleteTagEnum.NOT_DELETED.getCode();
}
}
/**
* VISIT_SUMMARY
......@@ -236,16 +182,6 @@ public class ConvertUtil {
return list;
}
public static FollowQo userInfoEntity2FollowQo(UserInfoEntity entity) {
if (entity == null) {
return null;
}
return FollowQo.builder().userId(entity.getId())
.nickName(entity.getUiUsernameMp())
.headImg(entity.getUiHeadimgMp())
.introduction(entity.getUiIntroductionMp())
.build();
}
public static FollowQo userInfoNew2FollowQo(UserInfoNew entity) {
if (entity == null) {
......
package com.tanpu.community.util;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
public class RankUtils {
public static List<ThemeEntity> sortThemeEntityByIds(List<ThemeEntity> list, List<String> ids){
int count=0;
HashMap<String, Integer> indexMap = new HashMap<>();
for (String id : ids) {
indexMap.put(id,count++);
}
List<ThemeEntity> collect = list.stream().filter(o -> indexMap.containsKey(o.getThemeId()))
.sorted(Comparator.comparingInt(o -> indexMap.get(o.getThemeId())))
.collect(Collectors.toList());
return collect;
}
}
package com.tanpu.community.util;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
public class TimeUtil {
public class TimeUtils {
public static long getTimestampOfDateTime(LocalDateTime localDateTime) {
ZoneId zone = ZoneId.systemDefault();
Instant instant = localDateTime.atZone(zone).toInstant();
......@@ -41,4 +43,16 @@ public class TimeUtil {
return between.toMinutes();
}
//计算n天前的时间
public static LocalDateTime getDaysBefore(Integer number){
Calendar calendar = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
calendar.add(Calendar.DATE, number);
String three_days_after = sdf.format(calendar.getTime());
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime ldt = LocalDateTime.parse(three_days_after,df);
return ldt;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tanpu.community.dao.mapper.community.HomePageMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.tanpu.community.dao.entity.community.HomePageEntity">
<id column="id" property="id" />
<result column="user_id" property="userId" />
<result column="head_img" property="headImg" />
<result column="nick_name" property="nickName" />
<result column="introduction" property="introduction" />
<result column="sex" property="sex" />
<result column="location" property="location" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="delete_tag" property="deleteTag" />
</resultMap>
</mapper>
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