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