Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
add127c1
Commit
add127c1
authored
Jul 22, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除无用方法
parent
8e4d5c03
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
146 additions
and
137 deletions
+146
-137
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+5
-11
FileManager.java
...rc/main/java/com/tanpu/community/manager/FileManager.java
+2
-2
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+10
-9
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+97
-93
TopicManager.java
...c/main/java/com/tanpu/community/manager/TopicManager.java
+1
-2
VisitSummaryManager.java
...java/com/tanpu/community/manager/VisitSummaryManager.java
+0
-4
RankService.java
...rc/main/java/com/tanpu/community/service/RankService.java
+1
-1
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+5
-7
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+6
-7
RankUtils.java
...ice/src/main/java/com/tanpu/community/util/RankUtils.java
+4
-0
TimeUtils.java
...ice/src/main/java/com/tanpu/community/util/TimeUtils.java
+15
-1
No files found.
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
add127c1
...
...
@@ -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
());
}
}
community-service/src/main/java/com/tanpu/community/manager/FileManager.java
View file @
add127c1
...
...
@@ -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
));
}
...
...
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
add127c1
...
...
@@ -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 {
}
}
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
add127c1
...
...
@@ -138,20 +138,35 @@ 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
());
...
...
@@ -163,7 +178,7 @@ 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
());
List
<
ThemeAnalysDO
>
rankThemeList
ByTopic
=
rankService
.
getRankThemeList
(
req
.
getTopicId
());
themeEntities
=
themeService
.
queryByTopic
(
req
.
getTopicId
(),
req
.
getLastId
(),
req
.
getPageSize
());
}
else
if
(
ThemeListTypeEnum
.
TOPIC_LATEST
.
getCode
().
equals
(
req
.
getType
()))
{
//根据话题查询最新
...
...
@@ -181,20 +196,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
();
...
...
@@ -219,51 +222,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
)
{
...
...
@@ -296,27 +254,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
);
}
// 屏蔽(用户)
...
...
@@ -342,6 +296,8 @@ public class ThemeManager {
}
//主题Entity转QO
private
List
<
ThemeQo
>
convertEntityToQo
(
List
<
ThemeEntity
>
themeEntities
,
String
userId
)
{
//Entity转Qo
...
...
@@ -364,7 +320,6 @@ public class ThemeManager {
buildFormerTheme
(
themeQo
);
//是否关注作者
String
authorId
=
themeQo
.
getAuthorId
();
Set
<
String
>
fansSet
=
new
HashSet
<>(
followRelService
.
queryFansByFollowerId
(
userId
));
...
...
@@ -411,14 +366,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
)
{
...
...
@@ -434,12 +385,13 @@ public class ThemeManager {
throw
new
BizException
(
"内容校验失败,请检查内容后重新发送"
);
}
}
return
;
return
;
}
/**
* 直播类型做转播检查
*
* @param userId
* @param contents
*/
...
...
@@ -458,4 +410,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
null
;
}
}
community-service/src/main/java/com/tanpu/community/manager/TopicManager.java
View file @
add127c1
...
...
@@ -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
)
{
...
...
community-service/src/main/java/com/tanpu/community/manager/VisitSummaryManager.java
View file @
add127c1
...
...
@@ -40,10 +40,6 @@ public class VisitSummaryManager {
}
public
void
addTopicPageView
(
String
topicId
)
{
String
userId
=
userHolder
.
getUserId
();
visitSummaryService
.
addPageView
(
userId
,
topicId
,
VisitTypeEnum
.
TOPIC_PAGE_VIEW
);
...
...
community-service/src/main/java/com/tanpu/community/service/RankService.java
View file @
add127c1
...
...
@@ -38,7 +38,7 @@ public class RankService {
* 计算主题热度排行
*/
public
void
rankThemes
()
{
List
<
ThemeEntity
>
themeEntities
=
themeService
.
query
All
();
List
<
ThemeEntity
>
themeEntities
=
themeService
.
query
Recent14days
();
List
<
ThemeAnalysDO
>
themeAnalysDOS
=
ConvertUtil
.
themeEntityToAnalysDOs
(
themeEntities
);
for
(
ThemeAnalysDO
theme
:
themeAnalysDOS
)
{
String
themeId
=
theme
.
getThemeId
();
...
...
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
add127c1
...
...
@@ -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
);
}
...
...
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
add127c1
...
...
@@ -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
(
TimeUtil
s
.
getTimestampOfDateTime
(
themeEntity
.
getUpdateTime
()));
themeQO
.
setCreateTime
(
TimeUtil
s
.
getTimestampOfDateTime
(
themeEntity
.
getCreateTime
()));
themeQO
.
setUpToNowTime
(
TimeUtil
s
.
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
(
TimeUtil
s
.
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
(
TimeUtil
s
.
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
(
TimeUtil
s
.
getTimestampOfDateTime
(
entity
.
getUpdateTime
()));
return
qo
;
}
...
...
community-service/src/main/java/com/tanpu/community/util/RankUtils.java
0 → 100644
View file @
add127c1
package
com
.
tanpu
.
community
.
util
;
public
class
RankUtils
{
}
community-service/src/main/java/com/tanpu/community/util/TimeUtil.java
→
community-service/src/main/java/com/tanpu/community/util/TimeUtil
s
.java
View file @
add127c1
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
TimeUtil
s
{
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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment