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

删除无用方法

parent 8e4d5c03
......@@ -41,7 +41,7 @@ public class CommentManager {
@Resource
private ReportLogService reportLogService;
// 评论(对主题)
// 发表评论(对主题)
public void comment(CreateCommentReq req, String userId) {
CommentEntity commentEntity = CommentEntity.builder()
.themeId(req.getThemeId())
......@@ -55,16 +55,14 @@ 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);
Set<String> likeCommentList = collectionService.getListByUser(userId, CollectionTypeEnum.LIKE_COMMENT);
for (CommentQo commentQo : commentQos) {
//用户信息
//查询用户信息
String authorId = commentQo.getAuthorId();
CommonResp<UserInfoNew> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(authorId);
if (userInfoNewCommonResp.isNotSuccess()) {
......@@ -86,10 +84,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()).
......@@ -111,8 +105,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));
}
......
......@@ -69,13 +69,13 @@ public class HomePageManager {
//查询 个人中心 相关信息
public UserInfoNew queryUsersListNew(String userIdMyself, String userId) {
CommonResp<UserInfoNew> queryUsersListNew = feignClientForFatools.queryUsersListNew(StringUtils.isNotBlank(userId) ? userId : userIdMyself);
if (queryUsersListNew.isNotSuccess()) new BizException("内部接口调用失败");
if (queryUsersListNew.isNotSuccess()) new BizException("内部接口调用失败");
UserInfoNew userInfoNew = queryUsersListNew.getData();
if (StringUtils.isNotBlank(userId) && !StringUtils.equals(userIdMyself, userId)) { //查询别人的个人主页
// 关注 按钮的显示逻辑
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(ShowFollowStatusEnum.FOLLOWED.getCode()); // 已关注
} else {
userInfoNew.setShowFollowStatus(ShowFollowStatusEnum.NOT_FOLLOWED.getCode()); // 未关注
......@@ -89,7 +89,7 @@ public class HomePageManager {
getFansNUmAndFollowNum(userInfoNew);
// 主页类型 显示逻辑
if (UserLevelEnum.USER_CHIEF_FINANCIAL_ADVISER.getCode() == userInfoNew.getLevelGrade()){
if (UserLevelEnum.USER_CHIEF_FINANCIAL_ADVISER.getCode() == userInfoNew.getLevelGrade()) {
// 首席投顾
userInfoNew.setPersonalCenterType(PersonalCenterTypeEnum.CHIEF.getCode());
// 成功案例客户
......@@ -103,10 +103,10 @@ public class HomePageManager {
userInfoNew.getUserInfoNewChief().setClientId(null);
}
}
} else if (UserTypeEnum.USER_ORG.getCode() == userInfoNew.getUserType()){
} else if (UserTypeEnum.USER_ORG.getCode() == userInfoNew.getUserType()) {
// 机构账号
userInfoNew.setPersonalCenterType(PersonalCenterTypeEnum.ORG.getCode());
if (FundCompanyTypeEnum.PUBLIC.getCode() == 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>()
.eq(MfAdvisorscalerank::getInvestadvisorcode, userInfoNew.getUserInfoNewOrg().getBelongOrgId())
......@@ -118,7 +118,7 @@ public class HomePageManager {
.last("limit 1"));
userInfoNew.setFounded(ObjectUtils.anyNotNull(mfInvestadvisoroutline) ? mfInvestadvisoroutline.getEstablishmentdate().getTime() : null);
}
if(FundCompanyTypeEnum.PRIVATE.getCode() == 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);
......@@ -132,7 +132,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());
......@@ -142,7 +142,8 @@ 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(ShowFollowStatusEnum.FOLLOWED.getCode());//1已关注
if (collect1.containsKey(userInfoOrg.getUserId()))
userInfoOrg.setIsFollower(ShowFollowStatusEnum.FOLLOWED.getCode());//1已关注
});
userInfoNew.setUserInfoOrgList(userInfoOrgs);
}
......@@ -165,6 +166,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();
......@@ -208,5 +210,4 @@ public class HomePageManager {
}
}
......@@ -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) {
......
......@@ -40,10 +40,6 @@ public class VisitSummaryManager {
}
public void addTopicPageView(String topicId) {
String userId = userHolder.getUserId();
visitSummaryService.addPageView(userId, topicId, VisitTypeEnum.TOPIC_PAGE_VIEW);
......
......@@ -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();
......
......@@ -8,6 +8,7 @@ import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.ReportStatusEnum;
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;
......@@ -41,14 +42,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);
}
......
......@@ -15,7 +15,6 @@ 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;
......@@ -38,9 +37,9 @@ public class ConvertUtil {
}
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 +52,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;
}
......@@ -106,7 +105,7 @@ public class ConvertUtil {
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;
......@@ -128,7 +127,7 @@ public class ConvertUtil {
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;
}
......
package com.tanpu.community.util;
public class RankUtils {
}
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;
}
}
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