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 { ...@@ -49,6 +49,7 @@ public class CommentManager {
private RedisCache redisCache; private RedisCache redisCache;
// 评论(对主题) // 评论(对主题)
// 发表评论(对主题)
public void comment(CreateCommentReq req, String userId) { public void comment(CreateCommentReq req, String userId) {
CommentEntity commentEntity = CommentEntity.builder() CommentEntity commentEntity = CommentEntity.builder()
.themeId(req.getThemeId()) .themeId(req.getThemeId())
...@@ -62,7 +63,7 @@ public class CommentManager { ...@@ -62,7 +63,7 @@ public class CommentManager {
commentService.insertComment(commentEntity); commentService.insertComment(commentEntity);
} }
//查询 //查询评论
public List<CommentQo> queryComments(String themeId, String userId) { public List<CommentQo> queryComments(String themeId, String userId) {
List<CommentEntity> commentEntities = commentService.selectByThemeIdAndParentId(themeId, null); List<CommentEntity> commentEntities = commentService.selectByThemeIdAndParentId(themeId, null);
List<CommentQo> commentQos = ConvertUtil.commentEntity2Qos(commentEntities); List<CommentQo> commentQos = ConvertUtil.commentEntity2Qos(commentEntities);
...@@ -70,7 +71,7 @@ public class CommentManager { ...@@ -70,7 +71,7 @@ public class CommentManager {
Set<String> likeCommentList = collectionService.getListByUser(userId, CollectionTypeEnum.LIKE_COMMENT); Set<String> likeCommentList = collectionService.getListByUser(userId, CollectionTypeEnum.LIKE_COMMENT);
for (CommentQo commentQo : commentQos) { for (CommentQo commentQo : commentQos) {
//用户信息 //查询用户信息
String authorId = commentQo.getAuthorId(); String authorId = commentQo.getAuthorId();
CommonResp<UserInfoNew> userInfoNewCommonResp = redisCache.getObject(StringUtils.joinWith(CACGE_FEIGN_USER_INFO, authorId), CommonResp<UserInfoNew> userInfoNewCommonResp = redisCache.getObject(StringUtils.joinWith(CACGE_FEIGN_USER_INFO, authorId),
60 * 10, () -> feignClientForFatools.queryUsersListNew(authorId), CommonResp.class); 60 * 10, () -> feignClientForFatools.queryUsersListNew(authorId), CommonResp.class);
...@@ -93,10 +94,6 @@ public class CommentManager { ...@@ -93,10 +94,6 @@ public class CommentManager {
Integer countByTypeAndId = collectionService.getCountByTypeAndId(commentId, CollectionTypeEnum.LIKE_COMMENT); Integer countByTypeAndId = collectionService.getCountByTypeAndId(commentId, CollectionTypeEnum.LIKE_COMMENT);
commentQo.setLikeCount(countByTypeAndId); 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()). return commentQos.stream().sorted(Comparator.comparing(CommentQo::getLikeCount, Comparator.reverseOrder()).
...@@ -118,8 +115,8 @@ public class CommentManager { ...@@ -118,8 +115,8 @@ public class CommentManager {
public void report(ReportCommentReq req, String userId) { public void report(ReportCommentReq req, String userId) {
//更改举报状态 //更改举报状态
commentService.updateReportStatus(req.getCommentId()); commentService.updateReportStatus(req.getCommentId());
//写入举报日志 //写入举报记录表
CommentEntity commentEntity = commentService.queryByCommentId(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 { ...@@ -38,14 +38,14 @@ public class FileManager {
String originalName = file.getOriginalFilename(); String originalName = file.getOriginalFilename();
if (data.length == 0 || StringUtils.isEmpty(originalName)){ if (data.length == 0 || StringUtils.isEmpty(originalName)) {
throw new BizException("上传文件为空"); throw new BizException("上传文件为空");
} }
FileRecordEntity fileRecordEntity = ossFileService.uploadFile(data, originalName); FileRecordEntity fileRecordEntity = ossFileService.uploadFile(data, originalName);
return ConvertUtil.fileRecordEntity2Resp(fileRecordEntity); 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() return ossFileService.queryByIds(fileIds).stream()
.collect(Collectors.toMap(FileRecordEntity::getFileId, FileRecordEntity::getUrl)); .collect(Collectors.toMap(FileRecordEntity::getFileId, FileRecordEntity::getUrl));
} }
......
...@@ -11,8 +11,7 @@ import com.tanpu.community.api.beans.req.page.Page; ...@@ -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.resp.Customer;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNew; 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.beans.vo.feign.fatools.UserInfoOrg;
import com.tanpu.community.api.enums.OperationTypeEnum; import com.tanpu.community.api.enums.*;
import com.tanpu.community.api.enums.QueryFollowTypeEnum;
import com.tanpu.community.dao.entity.community.FollowRelEntity; import com.tanpu.community.dao.entity.community.FollowRelEntity;
import com.tanpu.community.dao.entity.fund.CompanyInfo; import com.tanpu.community.dao.entity.fund.CompanyInfo;
import com.tanpu.community.dao.entity.fund.FundInfo; import com.tanpu.community.dao.entity.fund.FundInfo;
...@@ -70,16 +69,16 @@ public class HomePageManager { ...@@ -70,16 +69,16 @@ public class HomePageManager {
//查询 个人中心 相关信息 //查询 个人中心 相关信息
public UserInfoNew queryUsersListNew(String userIdMyself, String userId) { public UserInfoNew queryUsersListNew(String userIdMyself, String userId) {
CommonResp<UserInfoNew> queryUsersListNew = feignClientForFatools.queryUsersListNew(StringUtils.isNotBlank(userId) ? userId : userIdMyself); CommonResp<UserInfoNew> queryUsersListNew = feignClientForFatools.queryUsersListNew(StringUtils.isNotBlank(userId) ? userId : userIdMyself);
if (queryUsersListNew.isNotSuccess()) new BizException("内部接口调用失败"); if (queryUsersListNew.isNotSuccess()) new BizException("内部接口调用失败");
UserInfoNew userInfoNew = queryUsersListNew.getData(); UserInfoNew userInfoNew = queryUsersListNew.getData();
if (StringUtils.isNotBlank(userId) && !StringUtils.equals(userIdMyself, userId)) { //查询别人的个人主页 if (StringUtils.isNotBlank(userId) && !StringUtils.equals(userIdMyself, userId)) { //查询别人的个人主页
// 关注 按钮的显示逻辑 // 关注 按钮的显示逻辑
FollowRelEntity followRelEntity = followRelService.queryRecord(userId, userIdMyself); FollowRelEntity followRelEntity = followRelService.queryRecord(userId, userIdMyself);
if (ObjectUtils.allNotNull(followRelEntity) && BizStatus.DeleteTag.tag_init == followRelEntity.getDeleteTag()){ if (ObjectUtils.allNotNull(followRelEntity) && BizStatus.DeleteTag.tag_init == followRelEntity.getDeleteTag()) {
userInfoNew.setShowFollowStatus(1); // 已关注 userInfoNew.setShowFollowStatus(ShowFollowStatusEnum.FOLLOWED.getCode()); // 已关注
} else { } else {
userInfoNew.setShowFollowStatus(0); // 未关注 userInfoNew.setShowFollowStatus(ShowFollowStatusEnum.NOT_FOLLOWED.getCode()); // 未关注
} }
if (userInfoNew.getWorkshopStatus() == 2) userInfoNew.setWorkshopStatus(1); //别人的主页不需要展示 工作室 if (userInfoNew.getWorkshopStatus() == 2) userInfoNew.setWorkshopStatus(1); //别人的主页不需要展示 工作室
} else { } else {
...@@ -90,9 +89,9 @@ public class HomePageManager { ...@@ -90,9 +89,9 @@ public class HomePageManager {
getFansNUmAndFollowNum(userInfoNew); 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())) { if (StringUtils.isBlank(userInfoNew.getUserInfoNewChief().getClientId())) {
...@@ -103,11 +102,12 @@ public class HomePageManager { ...@@ -103,11 +102,12 @@ public class HomePageManager {
} else { } else {
userInfoNew.getUserInfoNewChief().setClientId(null); userInfoNew.getUserInfoNewChief().setClientId(null);
} }
} }
} else if (2 == userInfoNew.getUserType()){ } else if (UserTypeEnum.USER_ORG.getCode() == userInfoNew.getUserType()) {
// 机构账号 // 机构账号
userInfoNew.setPersonalCenterType(3); userInfoNew.setPersonalCenterType(PersonalCenterTypeEnum.ORG.getCode());
if (0 == userInfoNew.getUserInfoNewOrg().getBelongOrgType() && StringUtils.isNotBlank(userInfoNew.getUserInfoNewOrg().getBelongOrgId())){ // 公募 if (FundCompanyTypeEnum.PUBLIC.getCode() == userInfoNew.getUserInfoNewOrg().getBelongOrgType() && StringUtils.isNotBlank(userInfoNew.getUserInfoNewOrg().getBelongOrgId())) { // 公募
//设置 基金数 //设置 基金数
MfAdvisorscalerank mfAdvisorscalerank = mfAdvisorscalerankMapper.selectOne(new LambdaQueryWrapper<MfAdvisorscalerank>() MfAdvisorscalerank mfAdvisorscalerank = mfAdvisorscalerankMapper.selectOne(new LambdaQueryWrapper<MfAdvisorscalerank>()
.eq(MfAdvisorscalerank::getInvestadvisorcode, userInfoNew.getUserInfoNewOrg().getBelongOrgId()) .eq(MfAdvisorscalerank::getInvestadvisorcode, userInfoNew.getUserInfoNewOrg().getBelongOrgId())
...@@ -119,7 +119,7 @@ public class HomePageManager { ...@@ -119,7 +119,7 @@ public class HomePageManager {
.last("limit 1")); .last("limit 1"));
userInfoNew.setFounded(ObjectUtils.anyNotNull(mfInvestadvisoroutline) ? mfInvestadvisoroutline.getEstablishmentdate().getTime() : null); 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())); Integer integer = fundInfoMapper.selectCount(new LambdaQueryWrapper<FundInfo>().eq(FundInfo::getTrustId, userInfoNew.getUserInfoNewOrg().getBelongOrgId()));
userInfoNew.setFundNumber(integer); userInfoNew.setFundNumber(integer);
...@@ -133,7 +133,7 @@ public class HomePageManager { ...@@ -133,7 +133,7 @@ public class HomePageManager {
} }
//设置团队成员 //设置团队成员
CommonResp<List<UserInfoOrg>> usetInfoByOrgUserId = feignClientForFatools.getUsetInfoByOrgUserId(userId); CommonResp<List<UserInfoOrg>> usetInfoByOrgUserId = feignClientForFatools.getUsetInfoByOrgUserId(userId);
if (usetInfoByOrgUserId.isSuccess()){ if (usetInfoByOrgUserId.isSuccess()) {
List<UserInfoOrg> userInfoOrgs = usetInfoByOrgUserId.getData(); List<UserInfoOrg> userInfoOrgs = usetInfoByOrgUserId.getData();
// 设置关注列表 // 设置关注列表
List<String> collect = userInfoOrgs.stream().map(UserInfoOrg::getUserId).collect(Collectors.toList()); List<String> collect = userInfoOrgs.stream().map(UserInfoOrg::getUserId).collect(Collectors.toList());
...@@ -143,14 +143,15 @@ public class HomePageManager { ...@@ -143,14 +143,15 @@ public class HomePageManager {
.eq(FollowRelEntity::getDeleteTag, BizStatus.DeleteTag.tag_init)); .eq(FollowRelEntity::getDeleteTag, BizStatus.DeleteTag.tag_init));
Map<String, FollowRelEntity> collect1 = followRelEntities.stream().collect(Collectors.toMap(FollowRelEntity::getFollowUserId, Function.identity())); Map<String, FollowRelEntity> collect1 = followRelEntities.stream().collect(Collectors.toMap(FollowRelEntity::getFollowUserId, Function.identity()));
userInfoOrgs.forEach(userInfoOrg -> { 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); userInfoNew.setUserInfoOrgList(userInfoOrgs);
} }
} else { } else {
//普通主页 //普通主页
userInfoNew.setPersonalCenterType(1); userInfoNew.setPersonalCenterType(PersonalCenterTypeEnum.GENERAL.getCode());
//设置课程数(学习数) //设置课程数(学习数)
CommonResp<Integer> integerCommonResp = feignClientForCourse.getStudyCourseCount(userId); CommonResp<Integer> integerCommonResp = feignClientForCourse.getStudyCourseCount(userId);
if (integerCommonResp.isSuccess()) userInfoNew.setCourseNumber(integerCommonResp.getData()); if (integerCommonResp.isSuccess()) userInfoNew.setCourseNumber(integerCommonResp.getData());
...@@ -166,6 +167,7 @@ public class HomePageManager { ...@@ -166,6 +167,7 @@ public class HomePageManager {
userInfoNew.setFollowNumber(followNumber); userInfoNew.setFollowNumber(followNumber);
userInfoNew.setFansNumber(fansNumber); userInfoNew.setFansNumber(fansNumber);
} }
public List<Customer> queryUserCustomerList(String userId) { public List<Customer> queryUserCustomerList(String userId) {
CommonResp<List<Customer>> ifaCustomerList = feignClientForDiagnose.getIfaCustomerList(userId); CommonResp<List<Customer>> ifaCustomerList = feignClientForDiagnose.getIfaCustomerList(userId);
if (ifaCustomerList.isSuccess()) return ifaCustomerList.getData(); if (ifaCustomerList.isSuccess()) return ifaCustomerList.getData();
...@@ -209,5 +211,4 @@ public class HomePageManager { ...@@ -209,5 +211,4 @@ public class HomePageManager {
} }
} }
...@@ -43,7 +43,7 @@ public class TopicManager { ...@@ -43,7 +43,7 @@ public class TopicManager {
//新增话题 //新增话题
public void insertTopic(String topicTitle, String userId) { public void insertTopic(String topicTitle, String userId) {
if (topicService.queryByTitile(topicTitle) == null) { if (topicService.queryByTitile(topicTitle) == null) {
throw new BizException("话题名称已存在:"+topicTitle); throw new BizException("话题名称已存在:" + topicTitle);
} }
topicService.addTopic(topicTitle, userId); topicService.addTopic(topicTitle, userId);
...@@ -66,7 +66,6 @@ public class TopicManager { ...@@ -66,7 +66,6 @@ public class TopicManager {
} }
public void refreshRedisCache() { public void refreshRedisCache() {
List<TopicEntity> topicEntities = topicService.queryAll(); List<TopicEntity> topicEntities = topicService.queryAll();
for (TopicEntity topic : topicEntities) { 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 { ...@@ -38,7 +38,7 @@ public class RankService {
* 计算主题热度排行 * 计算主题热度排行
*/ */
public void rankThemes() { public void rankThemes() {
List<ThemeEntity> themeEntities = themeService.queryAll(); List<ThemeEntity> themeEntities = themeService.queryRecent14days();
List<ThemeAnalysDO> themeAnalysDOS = ConvertUtil.themeEntityToAnalysDOs(themeEntities); List<ThemeAnalysDO> themeAnalysDOS = ConvertUtil.themeEntityToAnalysDOs(themeEntities);
for (ThemeAnalysDO theme : themeAnalysDOS) { for (ThemeAnalysDO theme : themeAnalysDOS) {
String themeId = theme.getThemeId(); String themeId = theme.getThemeId();
...@@ -101,8 +101,11 @@ public class RankService { ...@@ -101,8 +101,11 @@ public class RankService {
* @param newCount * @param newCount
* @return * @return
*/ */
public List<String> getHotAndNewThemes(Integer hotCount, Integer newCount) { public List<String> getHotAndNewThemes(Integer hotCount, Integer newCount,String userId) {
Set<String> hotThemeIds = this.rankThemeList.stream().limit(hotCount).map(ThemeAnalysDO::getThemeId).collect(Collectors.toSet()); 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) Set<String> newThemeIds = themeService.selectExcludeUser(null, null, newCount)
.stream().map(ThemeEntity::getThemeId).collect(Collectors.toSet()); .stream().map(ThemeEntity::getThemeId).collect(Collectors.toSet());
hotThemeIds.addAll(newThemeIds); hotThemeIds.addAll(newThemeIds);
...@@ -118,13 +121,13 @@ public class RankService { ...@@ -118,13 +121,13 @@ public class RankService {
if (this.rankTopicList.size()==0){ if (this.rankTopicList.size()==0){
rankTopics(); 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()); matchTopic.add(new TopicRankQo());
return matchTopic.get(0); return matchTopic.get(0);
} }
public List<ThemeAnalysDO> getRankThemeList() { public List<ThemeAnalysDO> getRankThemeListByTopic() {
if (this.rankThemeList.size()==0){ if (this.rankThemeList.size()==0){
rankThemes(); rankThemes();
} }
...@@ -145,10 +148,12 @@ public class RankService { ...@@ -145,10 +148,12 @@ public class RankService {
return rankTopicListTop4; return rankTopicListTop4;
} }
public List<ThemeAnalysDO> getRankThemeList(String topicId) { public List<String> getRankThemeListByTopic(String topicId) {
if (this.rankThemeList.size()==0){ if (this.rankThemeList.size()==0){
this.rankThemes(); 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; ...@@ -10,6 +10,7 @@ import com.tanpu.community.api.enums.ReportStatusEnum;
import com.tanpu.community.cache.RedisCache; import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.dao.entity.community.ThemeEntity; import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.mapper.community.ThemeMapper; import com.tanpu.community.dao.mapper.community.ThemeMapper;
import com.tanpu.community.util.TimeUtils;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -49,14 +50,11 @@ public class ThemeService { ...@@ -49,14 +50,11 @@ public class ThemeService {
themeMapper.update(themeEntity, new LambdaUpdateWrapper<ThemeEntity>().eq(ThemeEntity::getThemeId, themeId)); themeMapper.update(themeEntity, new LambdaUpdateWrapper<ThemeEntity>().eq(ThemeEntity::getThemeId, themeId));
} }
/** //14天内所有主题
* 根据主题Id查询列表 public List<ThemeEntity> queryRecent14days() {
*
* @return
*/
public List<ThemeEntity> queryAll() {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>() 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); return themeMapper.selectList(queryWrapper);
} }
......
...@@ -2,20 +2,17 @@ package com.tanpu.community.util; ...@@ -2,20 +2,17 @@ package com.tanpu.community.util;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.tanpu.common.util.JsonUtil; 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.qo.*;
import com.tanpu.community.api.beans.req.theme.CreateThemeReq; import com.tanpu.community.api.beans.req.theme.CreateThemeReq;
import com.tanpu.community.api.beans.req.theme.ThemeContentReq; 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.beans.vo.feign.fatools.UserInfoNew;
import com.tanpu.community.api.enums.DeleteTagEnum; import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.RelTypeEnum; import com.tanpu.community.api.enums.RelTypeEnum;
import com.tanpu.community.api.enums.TopicStatusEnum; import com.tanpu.community.api.enums.TopicStatusEnum;
import com.tanpu.community.dao.entity.community.*; 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.beans.BeanUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -29,18 +26,15 @@ import java.util.stream.Collectors; ...@@ -29,18 +26,15 @@ import java.util.stream.Collectors;
public class ConvertUtil { public class ConvertUtil {
/**
* THEME
*/
public static ThemeQo themeEntityToQo(ThemeEntity themeEntity) { public static ThemeQo themeEntityToQo(ThemeEntity themeEntity) {
if (themeEntity == null) { if (themeEntity == null) {
return null; return null;
} }
ThemeQo themeQO = new ThemeQo(); ThemeQo themeQO = new ThemeQo();
BeanUtils.copyProperties(themeEntity, themeQO); BeanUtils.copyProperties(themeEntity, themeQO);
themeQO.setUpdateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getUpdateTime())); themeQO.setUpdateTime(TimeUtils.getTimestampOfDateTime(themeEntity.getUpdateTime()));
themeQO.setCreateTime(TimeUtil.getTimestampOfDateTime(themeEntity.getCreateTime())); themeQO.setCreateTime(TimeUtils.getTimestampOfDateTime(themeEntity.getCreateTime()));
themeQO.setUpToNowTime(TimeUtil.calUpToNowTime(themeEntity.getCreateTime())); themeQO.setUpToNowTime(TimeUtils.calUpToNowTime(themeEntity.getCreateTime()));
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() { List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() {
}); });
themeQO.setContent(themeContentQos); themeQO.setContent(themeContentQos);
...@@ -53,7 +47,7 @@ public class ConvertUtil { ...@@ -53,7 +47,7 @@ public class ConvertUtil {
} }
ThemeAnalysDO themeAnalysDO = new ThemeAnalysDO(); ThemeAnalysDO themeAnalysDO = new ThemeAnalysDO();
BeanUtils.copyProperties(themeEntity, themeAnalysDO); BeanUtils.copyProperties(themeEntity, themeAnalysDO);
themeAnalysDO.setMinuteTillNow(TimeUtil.calMinuteTillNow(themeEntity.getCreateTime())); themeAnalysDO.setMinuteTillNow(TimeUtils.calMinuteTillNow(themeEntity.getCreateTime()));
return themeAnalysDO; return themeAnalysDO;
} }
...@@ -93,20 +87,11 @@ public class ConvertUtil { ...@@ -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) { public static TopicRankQo topicEntityToHotQo(TopicEntity topicEntity) {
TopicRankQo topicRankQo = new TopicRankQo(); TopicRankQo topicRankQo = new TopicRankQo();
BeanUtils.copyProperties(topicEntity, topicRankQo); BeanUtils.copyProperties(topicEntity, topicRankQo);
//2小时内发帖,添加新话题标签 //2小时内发帖,添加新话题标签
if(TimeUtil.calMinuteTillNow(topicEntity.getCreateTime())<120){ if(TimeUtils.calMinuteTillNow(topicEntity.getCreateTime())<120){
topicRankQo.setType(TopicStatusEnum.NEWEST.getCode()); topicRankQo.setType(TopicStatusEnum.NEWEST.getCode());
} }
return topicRankQo; return topicRankQo;
...@@ -119,16 +104,11 @@ public class ConvertUtil { ...@@ -119,16 +104,11 @@ public class ConvertUtil {
return topicEntities.stream().map(ConvertUtil::topicEntityToHotQo).collect(Collectors.toList()); 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) { public static CommentQo commentEntity2Qo(CommentEntity entity) {
CommentQo qo = new CommentQo(); CommentQo qo = new CommentQo();
BeanUtils.copyProperties(entity, qo); BeanUtils.copyProperties(entity, qo);
qo.setUpdateTime(TimeUtil.getTimestampOfDateTime(entity.getUpdateTime())); qo.setUpdateTime(TimeUtils.getTimestampOfDateTime(entity.getUpdateTime()));
return qo; return qo;
} }
...@@ -136,40 +116,6 @@ public class ConvertUtil { ...@@ -136,40 +116,6 @@ public class ConvertUtil {
return entities.stream().map(ConvertUtil::commentEntity2Qo).collect(Collectors.toList()); 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 * VISIT_SUMMARY
...@@ -236,16 +182,6 @@ public class ConvertUtil { ...@@ -236,16 +182,6 @@ public class ConvertUtil {
return list; 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) { public static FollowQo userInfoNew2FollowQo(UserInfoNew entity) {
if (entity == null) { 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; package com.tanpu.community.util;
import java.text.SimpleDateFormat;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Calendar;
public class TimeUtil { public class TimeUtils {
public static long getTimestampOfDateTime(LocalDateTime localDateTime) { public static long getTimestampOfDateTime(LocalDateTime localDateTime) {
ZoneId zone = ZoneId.systemDefault(); ZoneId zone = ZoneId.systemDefault();
Instant instant = localDateTime.atZone(zone).toInstant(); Instant instant = localDateTime.atZone(zone).toInstant();
...@@ -41,4 +43,16 @@ public class TimeUtil { ...@@ -41,4 +43,16 @@ public class TimeUtil {
return between.toMinutes(); 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