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
ec929dd6
Commit
ec929dd6
authored
Feb 18, 2022
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
评论回复评论
parent
3617c248
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
123 additions
and
60 deletions
+123
-60
TopicFollowQo.java
.../java/com/tanpu/community/api/beans/qo/TopicFollowQo.java
+4
-7
TopicHotQo.java
...ain/java/com/tanpu/community/api/beans/qo/TopicHotQo.java
+46
-0
TopicRankQo.java
...in/java/com/tanpu/community/api/beans/qo/TopicRankQo.java
+1
-1
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+9
-1
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+26
-14
TopicManager.java
...c/main/java/com/tanpu/community/manager/TopicManager.java
+5
-33
TopicService.java
...c/main/java/com/tanpu/community/service/TopicService.java
+31
-4
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+1
-0
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicFollowQo.java
View file @
ec929dd6
...
@@ -21,15 +21,9 @@ public class TopicFollowQo {
...
@@ -21,15 +21,9 @@ public class TopicFollowQo {
private
String
topicTitle
;
private
String
topicTitle
;
@ApiModelProperty
(
value
=
"阅读量"
)
@ApiModelProperty
(
value
=
"阅读量"
)
private
Integer
viewCount
;
@ApiModelProperty
(
value
=
"讨论量"
)
private
Integer
disscussCount
;
@ApiModelProperty
(
value
=
"阅读量-格式化"
)
private
String
formatViewCount
;
private
String
formatViewCount
;
@ApiModelProperty
(
value
=
"讨论量
-格式化
"
)
@ApiModelProperty
(
value
=
"讨论量"
)
private
String
formatDisscussCount
;
private
String
formatDisscussCount
;
@ApiModelProperty
(
value
=
"话题介绍"
)
@ApiModelProperty
(
value
=
"话题介绍"
)
...
@@ -41,6 +35,9 @@ public class TopicFollowQo {
...
@@ -41,6 +35,9 @@ public class TopicFollowQo {
@ApiModelProperty
(
value
=
"是否专属 0否,1是"
)
@ApiModelProperty
(
value
=
"是否专属 0否,1是"
)
private
Integer
specialPermission
;
private
Integer
specialPermission
;
@ApiModelProperty
(
value
=
"是否有权限"
)
private
boolean
hasPermission
;
@ApiModelProperty
(
value
=
"更新帖子数量"
)
@ApiModelProperty
(
value
=
"更新帖子数量"
)
private
Integer
updateCount
;
private
Integer
updateCount
;
...
...
community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicHotQo.java
0 → 100644
View file @
ec929dd6
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
@ApiModel
(
"热点话题对象"
)
public
class
TopicHotQo
{
@ApiModelProperty
(
value
=
"话题ID"
)
private
String
topicId
;
@ApiModelProperty
(
value
=
"话题名称"
)
private
String
topicTitle
;
@ApiModelProperty
(
value
=
"类型 1:热 2:新"
)
private
Integer
type
;
@ApiModelProperty
(
value
=
"阅读量"
)
private
String
formatViewCount
;
@ApiModelProperty
(
value
=
"讨论量"
)
private
String
formatDisscussCount
;
@ApiModelProperty
(
value
=
"是否置顶"
)
private
Integer
isTop
;
@ApiModelProperty
(
value
=
"浏览量调整基数"
)
private
Integer
viewCntAdjust
;
@ApiModelProperty
(
value
=
"话题下的帖子权重"
)
private
Double
themeWeight
;
@ApiModelProperty
(
value
=
"话题介绍"
)
private
String
topicDesc
;
@ApiModelProperty
(
value
=
"封面"
)
private
String
coverImg
;
@ApiModelProperty
(
value
=
"是否专属 0否,1是"
)
private
Integer
specialPermission
;
@ApiModelProperty
(
value
=
"是否有权限"
)
private
boolean
hasPermission
;
}
community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicRankQo.java
View file @
ec929dd6
...
@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
...
@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import
lombok.Data
;
import
lombok.Data
;
@Data
@Data
@ApiModel
(
"
热点话题
对象"
)
@ApiModel
(
"
话题排序
对象"
)
public
class
TopicRankQo
{
public
class
TopicRankQo
{
@ApiModelProperty
(
value
=
"话题ID"
)
@ApiModelProperty
(
value
=
"话题ID"
)
...
...
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
ec929dd6
...
@@ -79,6 +79,7 @@ public class CommentManager {
...
@@ -79,6 +79,7 @@ public class CommentManager {
.
themeId
(
req
.
getThemeId
())
.
themeId
(
req
.
getThemeId
())
.
parentId
(
req
.
getParentId
())
.
parentId
(
req
.
getParentId
())
.
replyId
(
req
.
getReplyId
())
.
replyId
(
req
.
getReplyId
())
.
replyUserId
(
req
.
getReplyUserId
())
.
authorId
(
userId
)
.
authorId
(
userId
)
.
content
(
req
.
getComment
())
.
content
(
req
.
getComment
())
.
commentType
(
CommentTypeEnum
.
THEME
.
getCode
())
.
commentType
(
CommentTypeEnum
.
THEME
.
getCode
())
...
@@ -155,6 +156,13 @@ public class CommentManager {
...
@@ -155,6 +156,13 @@ public class CommentManager {
commentQo
.
setBelongUserOrgId
(
userInfo
.
getBelongUserOrgId
());
commentQo
.
setBelongUserOrgId
(
userInfo
.
getBelongUserOrgId
());
commentQo
.
setBelongUserOrgName
(
userInfo
.
getBelongUserOrgName
());
commentQo
.
setBelongUserOrgName
(
userInfo
.
getBelongUserOrgName
());
}
}
// 回复用户名
String
replyUserId
=
commentQo
.
getReplyUserId
();
UserInfoResp
replyUser
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
"_"
,
CACHE_FEIGN_USER_INFO
,
authorId
),
60
,
()
->
this
.
getUserInfo
(
replyUserId
),
UserInfoResp
.
class
);
if
(
replyUser
!=
null
)
{
commentQo
.
setReplyUserName
(
replyUser
.
getNickName
());
}
commentQo
.
setHasLiked
(
false
);
commentQo
.
setHasLiked
(
false
);
commentQo
.
setLikeCount
(
0
);
commentQo
.
setLikeCount
(
0
);
}
}
...
@@ -196,7 +204,7 @@ public class CommentManager {
...
@@ -196,7 +204,7 @@ public class CommentManager {
//删除评论
//删除评论
public
void
delete
(
String
commentId
,
String
userId
)
{
public
void
delete
(
String
commentId
,
String
userId
)
{
if
(
StringUtils
.
isBlank
(
commentId
)){
if
(
StringUtils
.
isBlank
(
commentId
))
{
throw
new
BizException
(
"commentId不能为空"
);
throw
new
BizException
(
"commentId不能为空"
);
}
}
commentService
.
delete
(
commentId
,
userId
);
commentService
.
delete
(
commentId
,
userId
);
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
ec929dd6
...
@@ -97,53 +97,55 @@ public class ThemeManager {
...
@@ -97,53 +97,55 @@ public class ThemeManager {
@Resource
@Resource
private
ThemeService
themeService
;
private
ThemeService
themeService
;
@
Autowired
@
Resource
private
CollectionService
collectionService
;
private
CollectionService
collectionService
;
@
Autowired
@
Resource
private
CommentService
commentService
;
private
CommentService
commentService
;
@
Autowired
@
Resource
private
FollowRelService
followRelService
;
private
FollowRelService
followRelService
;
@
Autowired
@
Resource
private
BlackListService
blackListService
;
private
BlackListService
blackListService
;
@
Autowired
@
Resource
private
ThemeAttachmentService
themeAttachmentService
;
private
ThemeAttachmentService
themeAttachmentService
;
@Resource
@Resource
private
BatchFeignCallService
batchFeignCallService
;
private
BatchFeignCallService
batchFeignCallService
;
@
Autowired
@
Resource
private
VisitLogService
visitLogService
;
private
VisitLogService
visitLogService
;
@
Autowired
@
Resource
private
ReportLogService
reportLogService
;
private
ReportLogService
reportLogService
;
@
Autowired
@
Resource
private
RankService
rankService
;
private
RankService
rankService
;
@
Autowired
@
Resource
private
ESService
esService
;
private
ESService
esService
;
@
Autowired
@
Resource
private
FeignClientForFatools
feignClientForFatools
;
private
FeignClientForFatools
feignClientForFatools
;
@
Autowired
@
Resource
private
RedisCache
redisCache
;
private
RedisCache
redisCache
;
@
Autowired
@
Resource
private
RecommendService
recommendService
;
private
RecommendService
recommendService
;
@Resource
@Resource
private
RestTemplate
restTemplate
;
private
RestTemplate
restTemplate
;
@
Autowired
@
Resource
private
NotificationService
notificationService
;
private
NotificationService
notificationService
;
@
Autowired
@
Resource
private
ThemeTextCheckService
themeTextCheckService
;
private
ThemeTextCheckService
themeTextCheckService
;
@Resource
private
TopicService
topicService
;
@PostConstruct
@PostConstruct
public
void
init
()
throws
IOException
{
public
void
init
()
throws
IOException
{
...
@@ -697,10 +699,20 @@ public class ThemeManager {
...
@@ -697,10 +699,20 @@ public class ThemeManager {
// 查询正文
// 查询正文
public
CommonResp
<
ThemeQo
>
getThemeDetail
(
String
themeId
,
String
userId
)
{
public
CommonResp
<
ThemeQo
>
getThemeDetail
(
String
themeId
,
String
userId
)
{
ThemeEntity
themeEntity
=
themeService
.
queryByThemeIdIgnoreDelete
(
themeId
);
ThemeEntity
themeEntity
=
themeService
.
queryByThemeIdIgnoreDelete
(
themeId
);
if
(
themeEntity
==
null
)
{
if
(
themeEntity
==
null
)
{
throw
new
BizException
(
"找不到帖子id:"
+
themeId
);
throw
new
BizException
(
"找不到帖子id:"
+
themeId
);
}
}
// 校验主题权限
if
(
StringUtils
.
isNotBlank
(
themeEntity
.
getTopicId
())
&&
!
topicService
.
checkPermission
(
themeEntity
.
getTopicId
(),
userId
))
{
return
CommonResp
.
error
(
ErrorCodeConstant
.
TOPIC_PERMISSION_ABORT
.
getCode
(),
topicService
.
getPermissionToast
(
themeEntity
.
getTopicId
()));
}
if
(
themeEntity
.
getDeleteTag
().
equals
(
DeleteTagEnum
.
DELETED
.
getCode
()))
{
if
(
themeEntity
.
getDeleteTag
().
equals
(
DeleteTagEnum
.
DELETED
.
getCode
()))
{
return
CommonResp
.
error
(
ErrorCodeConstant
.
UNREACHABLE
,
null
);
return
CommonResp
.
error
(
ErrorCodeConstant
.
UNREACHABLE
,
null
);
}
}
...
...
community-service/src/main/java/com/tanpu/community/manager/TopicManager.java
View file @
ec929dd6
...
@@ -11,7 +11,6 @@ import com.tanpu.community.api.beans.req.topic.TopicSearchReq;
...
@@ -11,7 +11,6 @@ import com.tanpu.community.api.beans.req.topic.TopicSearchReq;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
import
com.tanpu.community.api.enums.TopicSpecialPermissionEnum
;
import
com.tanpu.community.api.enums.TopicSpecialPermissionEnum
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.TopicFollowRelEntity
;
import
com.tanpu.community.dao.mapper.community.TopicFollowRelMapper
;
import
com.tanpu.community.dao.mapper.community.TopicFollowRelMapper
;
import
com.tanpu.community.service.RankService
;
import
com.tanpu.community.service.RankService
;
import
com.tanpu.community.service.ThemeService
;
import
com.tanpu.community.service.ThemeService
;
...
@@ -55,7 +54,7 @@ public class TopicManager {
...
@@ -55,7 +54,7 @@ public class TopicManager {
List
<
TopicRankQo
>
topicList
=
rankService
.
getRankTopicList
(
req
.
getSearchKeyword
());
List
<
TopicRankQo
>
topicList
=
rankService
.
getRankTopicList
(
req
.
getSearchKeyword
());
Page
<
TopicRankQo
>
result
=
PageUtils
.
page
(
req
.
getPage
(),
topicList
);
Page
<
TopicRankQo
>
result
=
PageUtils
.
page
(
req
.
getPage
(),
topicList
);
// 添加权限
// 添加权限
topicService
.
batchCheckPermission
(
result
.
getContent
(),
userHolder
.
getUserId
());
topicService
.
batchCheckPermission
(
result
.
getContent
(),
userHolder
.
getUserId
());
return
result
;
return
result
;
}
}
...
@@ -103,41 +102,14 @@ public class TopicManager {
...
@@ -103,41 +102,14 @@ public class TopicManager {
}
}
//
//
if
(
TopicSpecialPermissionEnum
.
TRUE
.
getCode
().
equals
(
topicEntity
.
getSpecialPermission
())
&&
!
checkPermission
(
topicId
,
userHolder
.
getUserId
()))
{
if
(
TopicSpecialPermissionEnum
.
TRUE
.
getCode
().
equals
(
topicEntity
.
getSpecialPermission
())
&&
return
CommonResp
.
error
(
ErrorCodeConstant
.
TOPIC_PERMISSION_ABORT
.
getCode
(),
getPermissionToast
(
topicId
));
!
topicService
.
checkPermission
(
topicId
,
userHolder
.
getUserId
()))
{
return
CommonResp
.
error
(
ErrorCodeConstant
.
TOPIC_PERMISSION_ABORT
.
getCode
(),
topicService
.
getPermissionToast
(
topicId
));
}
}
return
CommonResp
.
success
(
rankService
.
getTopicDetail
(
topicId
));
return
CommonResp
.
success
(
rankService
.
getTopicDetail
(
topicId
));
}
}
private
String
getPermissionToast
(
String
topicId
)
{
String
permission
=
"专业版会员"
;
return
"暂无权限参与此话题~您可联系官方客服 021- 了解详情"
;
// return "该话题仅限" + permission + "可参与哦~";
}
/**
* 判断用户是否拥有权限(1对1)
*
* @param topicId
* @param userId
*/
private
boolean
checkPermission
(
String
topicId
,
String
userId
)
{
TopicEntity
topicEntity
=
topicService
.
queryOnlineTopicById
(
topicId
);
if
(
TopicSpecialPermissionEnum
.
FALSE
.
equals
(
topicEntity
.
getSpecialPermission
()))
{
return
true
;
}
TopicFollowRelEntity
topicFollowRelEntity
=
topicFollowRelMapper
.
queryOneByTopicIdAndUserId
(
topicId
,
userId
);
if
(
topicFollowRelEntity
!=
null
)
{
return
true
;
}
else
{
return
false
;
}
}
/**
/**
* 关注/取关 话题
* 关注/取关 话题
...
@@ -150,7 +122,7 @@ public class TopicManager {
...
@@ -150,7 +122,7 @@ public class TopicManager {
// 检验话题权限是否专属
// 检验话题权限是否专属
TopicEntity
topicEntity
=
topicService
.
queryOnlineTopicById
(
req
.
getTopicId
());
TopicEntity
topicEntity
=
topicService
.
queryOnlineTopicById
(
req
.
getTopicId
());
if
(
TopicSpecialPermissionEnum
.
TRUE
.
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 @
ec929dd6
...
@@ -6,6 +6,7 @@ import com.tanpu.community.api.beans.qo.TopicFollowQo;
...
@@ -6,6 +6,7 @@ import com.tanpu.community.api.beans.qo.TopicFollowQo;
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
;
import
com.tanpu.community.api.enums.TopicSpecialPermissionEnum
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.TopicFollowRelEntity
;
import
com.tanpu.community.dao.entity.community.TopicFollowRelEntity
;
import
com.tanpu.community.dao.mapper.community.TopicFollowRelMapper
;
import
com.tanpu.community.dao.mapper.community.TopicFollowRelMapper
;
...
@@ -91,10 +92,6 @@ public class TopicService {
...
@@ -91,10 +92,6 @@ public class TopicService {
}
}
public
void
followTopic
(
String
topicId
,
String
userId
)
{
}
public
boolean
addFollowTopic
(
String
topicId
,
String
userId
)
{
public
boolean
addFollowTopic
(
String
topicId
,
String
userId
)
{
TopicFollowRelEntity
searchResult
=
topicFollowRelMapper
.
queryOneByTopicIdAndUserId
(
topicId
,
userId
);
TopicFollowRelEntity
searchResult
=
topicFollowRelMapper
.
queryOneByTopicIdAndUserId
(
topicId
,
userId
);
...
@@ -126,7 +123,37 @@ public class TopicService {
...
@@ -126,7 +123,37 @@ 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
;
}
}
/**
* 判断用户是否拥有权限(1对1)
*
* @param topicId
* @param userId
*/
public
boolean
checkPermission
(
String
topicId
,
String
userId
)
{
TopicEntity
topicEntity
=
queryOnlineTopicById
(
topicId
);
if
(
TopicSpecialPermissionEnum
.
FALSE
.
getCode
().
equals
(
topicEntity
.
getSpecialPermission
()))
{
return
true
;
}
}
TopicFollowRelEntity
topicFollowRelEntity
=
topicFollowRelMapper
.
queryOneByTopicIdAndUserId
(
topicId
,
userId
);
if
(
topicFollowRelEntity
!=
null
)
{
return
true
;
}
else
{
return
false
;
}
}
public
String
getPermissionToast
(
String
topicId
)
{
String
permission
=
"专业版会员"
;
return
"暂无权限参与此话题~您可联系官方客服 021- 了解详情"
;
// return "该话题仅限" + permission + "可参与哦~";
}
}
}
}
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
ec929dd6
...
@@ -150,6 +150,7 @@ public class ConvertUtil {
...
@@ -150,6 +150,7 @@ public class ConvertUtil {
private
static
TopicFollowQo
topicEntityToFollowQo
(
TopicEntity
topicEntity
)
{
private
static
TopicFollowQo
topicEntityToFollowQo
(
TopicEntity
topicEntity
)
{
TopicFollowQo
topicFollowQo
=
new
TopicFollowQo
();
TopicFollowQo
topicFollowQo
=
new
TopicFollowQo
();
BeanUtils
.
copyProperties
(
topicEntity
,
topicFollowQo
);
BeanUtils
.
copyProperties
(
topicEntity
,
topicFollowQo
);
topicFollowQo
.
setHasPermission
(
true
);
return
topicFollowQo
;
return
topicFollowQo
;
}
}
...
...
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