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
3e985168
Commit
3e985168
authored
Feb 18, 2022
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
话题关联附件
parent
22030d18
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
142 additions
and
18 deletions
+142
-18
TopicAttachement.java
...va/com/tanpu/community/api/beans/qo/TopicAttachement.java
+23
-0
TopicPageDetailQo.java
...a/com/tanpu/community/api/beans/qo/TopicPageDetailQo.java
+45
-0
TopicRankQo.java
...in/java/com/tanpu/community/api/beans/qo/TopicRankQo.java
+3
-0
CreateCommentReq.java
...npu/community/api/beans/req/comment/CreateCommentReq.java
+10
-5
TopicController.java
.../java/com/tanpu/community/controller/TopicController.java
+3
-3
TopicManager.java
...c/main/java/com/tanpu/community/manager/TopicManager.java
+36
-8
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+6
-1
TopicService.java
...c/main/java/com/tanpu/community/service/TopicService.java
+8
-0
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+7
-0
TopicFollowRelEntityMapper.xml
...resources/mapper/community/TopicFollowRelEntityMapper.xml
+1
-1
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicAttachement.java
0 → 100644
View file @
3e985168
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@ApiModel
(
value
=
"主题关联产品"
)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
TopicAttachement
{
@ApiModelProperty
(
value
=
"RelTypeEnum类型,108:文本,88:产品 3:直播 6:短视频 303:新版课程-音频,304: 新版课程-视频,109:单图(长文) 110:多图(讨论)"
)
private
String
type
;
@ApiModelProperty
(
value
=
"对象详情"
)
private
AttachmentDetailVo
detail
;
}
community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicPageDetailQo.java
0 → 100644
View file @
3e985168
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
@Data
@ApiModel
(
"热点话题对象"
)
public
class
TopicPageDetailQo
{
@ApiModelProperty
(
value
=
"话题ID"
)
private
String
topicId
;
@ApiModelProperty
(
value
=
"话题名称"
)
private
String
topicTitle
;
@ApiModelProperty
(
value
=
"阅读量"
)
private
Integer
viewCount
;
@ApiModelProperty
(
value
=
"讨论量"
)
private
Integer
disscussCount
;
@ApiModelProperty
(
value
=
"阅读量-格式化"
)
private
String
formatViewCount
;
@ApiModelProperty
(
value
=
"讨论量-格式化"
)
private
String
formatDisscussCount
;
@ApiModelProperty
(
value
=
"话题介绍"
)
private
String
topicDesc
;
@ApiModelProperty
(
value
=
"封面"
)
private
String
coverImg
;
@ApiModelProperty
(
value
=
"是否专属 0否,1是"
)
private
Integer
specialPermission
;
@ApiModelProperty
(
value
=
"是否有权限"
)
private
boolean
hasPermission
;
@ApiModelProperty
(
value
=
"关联产品"
)
private
List
<
TopicAttachement
>
attachments
;
}
community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicRankQo.java
View file @
3e985168
...
@@ -48,6 +48,9 @@ public class TopicRankQo {
...
@@ -48,6 +48,9 @@ public class TopicRankQo {
@ApiModelProperty
(
value
=
"是否专属 0否,1是"
)
@ApiModelProperty
(
value
=
"是否专属 0否,1是"
)
private
Integer
specialPermission
;
private
Integer
specialPermission
;
@ApiModelProperty
(
value
=
"是否有权限"
)
private
boolean
hasPermission
;
private
Integer
minutesTillNow
;
private
Integer
minutesTillNow
;
private
Double
score
;
private
Double
score
;
...
...
community-api/src/main/java/com/tanpu/community/api/beans/req/comment/CreateCommentReq.java
View file @
3e985168
...
@@ -14,11 +14,6 @@ public class CreateCommentReq {
...
@@ -14,11 +14,6 @@ public class CreateCommentReq {
@ApiModelProperty
(
value
=
"主题Id"
)
@ApiModelProperty
(
value
=
"主题Id"
)
private
String
themeId
;
private
String
themeId
;
@ApiModelProperty
(
value
=
"一级评论id(对主题的一级评论,此项为空)"
)
private
String
parentId
;
@ApiModelProperty
(
value
=
"回复对象的id(非对评论回复时,此项为空)"
)
private
String
replyId
;
@NotBlank
(
message
=
"评论内容不能为空"
)
@NotBlank
(
message
=
"评论内容不能为空"
)
@ApiModelProperty
(
value
=
"评论内容"
)
@ApiModelProperty
(
value
=
"评论内容"
)
...
@@ -27,4 +22,14 @@ public class CreateCommentReq {
...
@@ -27,4 +22,14 @@ public class CreateCommentReq {
@ApiModelProperty
(
value
=
"同步转发,1 同步 ,0 不同步(默认)"
)
@ApiModelProperty
(
value
=
"同步转发,1 同步 ,0 不同步(默认)"
)
private
int
syncForward
=
0
;
private
int
syncForward
=
0
;
@ApiModelProperty
(
value
=
"回复对象的commentId(非对评论回复时,此项为空)"
)
private
String
replyId
;
@ApiModelProperty
(
value
=
"回复对象的userid"
)
private
String
replyUserId
;
@ApiModelProperty
(
value
=
"一级评论id(对主题的一级评论,此项为空,目前未使用)"
)
private
String
parentId
;
}
}
community-service/src/main/java/com/tanpu/community/controller/TopicController.java
View file @
3e985168
...
@@ -51,7 +51,7 @@ public class TopicController {
...
@@ -51,7 +51,7 @@ public class TopicController {
}
}
@GetMapping
(
value
=
"/detailPage"
)
@GetMapping
(
value
=
"/detailPage"
)
@ApiOperation
(
"话题详情页
顶部
"
)
@ApiOperation
(
"话题详情页"
)
public
CommonResp
<
TopicRankQo
>
getDetail
(
@RequestParam
String
topicId
)
{
public
CommonResp
<
TopicRankQo
>
getDetail
(
@RequestParam
String
topicId
)
{
return
topicManager
.
getDetail
(
topicId
);
return
topicManager
.
getDetail
(
topicId
);
}
}
...
@@ -66,9 +66,9 @@ public class TopicController {
...
@@ -66,9 +66,9 @@ public class TopicController {
@AuthLogin
@AuthLogin
@PostMapping
(
value
=
"/follow"
)
@PostMapping
(
value
=
"/follow"
)
@ApiOperation
(
"
首页顶部话题标题列
"
)
@ApiOperation
(
"
关注话题(讨论区)
"
)
public
CommonResp
<
Void
>
follow
(
@RequestBody
FollowTopicReq
req
)
{
public
CommonResp
<
Void
>
follow
(
@RequestBody
FollowTopicReq
req
)
{
topicManager
.
follow
(
req
,
userHolder
.
getUserId
());
topicManager
.
follow
Topic
(
req
,
userHolder
.
getUserId
());
return
CommonResp
.
success
();
return
CommonResp
.
success
();
}
}
...
...
community-service/src/main/java/com/tanpu/community/manager/TopicManager.java
View file @
3e985168
...
@@ -11,6 +11,7 @@ import com.tanpu.community.api.beans.req.topic.TopicSearchReq;
...
@@ -11,6 +11,7 @@ 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
;
...
@@ -52,7 +53,10 @@ public class TopicManager {
...
@@ -52,7 +53,10 @@ public class TopicManager {
public
Page
<
TopicRankQo
>
getAllTopicBriefInfo
(
TopicSearchReq
req
)
{
public
Page
<
TopicRankQo
>
getAllTopicBriefInfo
(
TopicSearchReq
req
)
{
// 全量排序,内存分页
// 全量排序,内存分页
List
<
TopicRankQo
>
topicList
=
rankService
.
getRankTopicList
(
req
.
getSearchKeyword
());
List
<
TopicRankQo
>
topicList
=
rankService
.
getRankTopicList
(
req
.
getSearchKeyword
());
return
PageUtils
.
page
(
req
.
getPage
(),
topicList
);
Page
<
TopicRankQo
>
result
=
PageUtils
.
page
(
req
.
getPage
(),
topicList
);
// 添加权限
topicService
.
batchCheckPermission
(
result
.
getContent
(),
userHolder
.
getUserId
());
return
result
;
}
}
/**
/**
...
@@ -64,12 +68,12 @@ public class TopicManager {
...
@@ -64,12 +68,12 @@ public class TopicManager {
String
userId
=
userHolder
.
getUserId
();
String
userId
=
userHolder
.
getUserId
();
// 查库
// 查库
List
<
TopicFollowQo
>
topicFollowQos
=
topicService
.
queryFollowTopic
(
userId
);
List
<
TopicFollowQo
>
topicFollowQos
=
topicService
.
queryFollowTopic
(
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
));
topicFollowQos
.
stream
().
forEach
(
o
->
{
topicFollowQos
.
stream
().
forEach
(
o
->
{
TopicRankQo
topicRankQo
=
topicMap
.
get
(
o
.
getTopicId
());
TopicRankQo
topicRankQo
=
topicMap
.
get
(
o
.
getTopicId
());
BeanUtils
.
copyProperties
(
topicRankQo
,
o
);
BeanUtils
.
copyProperties
(
topicRankQo
,
o
);
});
});
...
@@ -86,6 +90,7 @@ public class TopicManager {
...
@@ -86,6 +90,7 @@ public class TopicManager {
/**
/**
* 话题详情页
* 话题详情页
*
* @param topicId
* @param topicId
* @return
* @return
*/
*/
...
@@ -109,8 +114,8 @@ public class TopicManager {
...
@@ -109,8 +114,8 @@ public class TopicManager {
String
permission
=
"专业版会员"
;
String
permission
=
"专业版会员"
;
//
return "暂无权限参与此话题~您可联系官方客服 021- 了解详情";
return
"暂无权限参与此话题~您可联系官方客服 021- 了解详情"
;
return
"该话题仅限"
+
permission
+
"可参与哦~"
;
//
return "该话题仅限" + permission + "可参与哦~";
}
}
/**
/**
...
@@ -121,17 +126,40 @@ public class TopicManager {
...
@@ -121,17 +126,40 @@ public class TopicManager {
*/
*/
private
boolean
checkPermission
(
String
topicId
,
String
userId
)
{
private
boolean
checkPermission
(
String
topicId
,
String
userId
)
{
return
true
;
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
;
}
}
}
public
void
follow
(
FollowTopicReq
req
,
String
userId
)
{
/**
* 关注/取关 话题
*
* @param req
* @param userId
* @return
*/
public
CommonResp
<
Void
>
followTopic
(
FollowTopicReq
req
,
String
userId
)
{
// 检验话题权限是否专属
TopicEntity
topicEntity
=
topicService
.
queryOnlineTopicById
(
req
.
getTopicId
());
if
(
TopicSpecialPermissionEnum
.
TRUE
.
equals
(
topicEntity
.
getSpecialPermission
()))
{
return
CommonResp
.
error
(
ErrorCodeConstant
.
ILLEGAL_ARGEMENT
.
getCode
(),
"专属话题不支持关注"
);
}
if
(
OperationTypeEnum
.
CONFIRM
.
getCode
().
equals
(
req
.
getType
()))
{
if
(
OperationTypeEnum
.
CONFIRM
.
getCode
().
equals
(
req
.
getType
()))
{
topicService
.
addFollowTopic
(
req
.
getTopicId
(),
userId
);
topicService
.
addFollowTopic
(
req
.
getTopicId
(),
userId
);
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()))
{
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()))
{
topicService
.
deleteFollowTopic
(
req
.
getTopicId
(),
userId
);
topicService
.
deleteFollowTopic
(
req
.
getTopicId
(),
userId
);
}
}
return
CommonResp
.
success
();
}
}
}
}
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
3e985168
...
@@ -312,7 +312,7 @@ public class ThemeService {
...
@@ -312,7 +312,7 @@ public class ThemeService {
ThemeEntity
themeEntity
=
themeMapper
.
queryOneByTopicIdOrderByUpdateTimeDesc
(
topicId
);
ThemeEntity
themeEntity
=
themeMapper
.
queryOneByTopicIdOrderByUpdateTimeDesc
(
topicId
);
if
(
themeEntity
!=
null
)
{
if
(
themeEntity
!=
null
)
{
ThemeQo
themeQo
=
ConvertUtil
.
themeEntityToQo
(
themeEntity
);
ThemeQo
themeQo
=
ConvertUtil
.
themeEntityToQo
(
themeEntity
);
topic
.
setLastTheme
(
themeQo
.
getAuthorId
()
+
themeQo
.
content
.
get
(
0
).
getValue
());
topic
.
setLastTheme
(
getUserName
(
themeQo
.
getAuthorId
())
+
":"
+
themeQo
.
content
.
get
(
0
).
getValue
());
topic
.
setLastThemeTime
(
TimeUtils
.
format
(
themeEntity
.
getUpdateTime
()));
topic
.
setLastThemeTime
(
TimeUtils
.
format
(
themeEntity
.
getUpdateTime
()));
}
}
...
@@ -330,4 +330,9 @@ public class ThemeService {
...
@@ -330,4 +330,9 @@ public class ThemeService {
}
}
}
}
private
String
getUserName
(
String
authorId
)
{
return
"理财师Jack"
;
}
}
}
community-service/src/main/java/com/tanpu/community/service/TopicService.java
View file @
3e985168
...
@@ -3,6 +3,7 @@ package com.tanpu.community.service;
...
@@ -3,6 +3,7 @@ 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.TopicFollowQo
;
import
com.tanpu.community.api.beans.qo.TopicFollowQo
;
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.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
...
@@ -11,6 +12,7 @@ import com.tanpu.community.dao.mapper.community.TopicFollowRelMapper;
...
@@ -11,6 +12,7 @@ import com.tanpu.community.dao.mapper.community.TopicFollowRelMapper;
import
com.tanpu.community.dao.mapper.community.TopicMapper
;
import
com.tanpu.community.dao.mapper.community.TopicMapper
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.ConvertUtil
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -121,4 +123,10 @@ public class TopicService {
...
@@ -121,4 +123,10 @@ public class TopicService {
topicFollowRelMapper
.
updateById
(
searchResult
);
topicFollowRelMapper
.
updateById
(
searchResult
);
}
}
}
}
public
void
batchCheckPermission
(
List
<
TopicRankQo
>
content
,
String
userId
)
{
if
(
StringUtils
.
isBlank
(
userId
)){
}
}
}
}
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
3e985168
...
@@ -14,6 +14,7 @@ import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg;
...
@@ -14,6 +14,7 @@ import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.NotificationTypeEnum
;
import
com.tanpu.community.api.enums.NotificationTypeEnum
;
import
com.tanpu.community.api.enums.TopicSpecialPermissionEnum
;
import
com.tanpu.community.dao.entity.NotificationLikeDO
;
import
com.tanpu.community.dao.entity.NotificationLikeDO
;
import
com.tanpu.community.dao.entity.NotificationForwardDO
;
import
com.tanpu.community.dao.entity.NotificationForwardDO
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
...
@@ -122,6 +123,12 @@ public class ConvertUtil {
...
@@ -122,6 +123,12 @@ public class ConvertUtil {
if
(
TimeUtils
.
calMinuteTillNow
(
topicEntity
.
getCreateTime
())
<
60
*
24
)
{
if
(
TimeUtils
.
calMinuteTillNow
(
topicEntity
.
getCreateTime
())
<
60
*
24
)
{
topicRankQo
.
setType
(
TopicStatusEnum
.
NEWEST
.
getCode
());
topicRankQo
.
setType
(
TopicStatusEnum
.
NEWEST
.
getCode
());
}
}
// 根据是否专属设置默认权限
if
(
TopicSpecialPermissionEnum
.
FALSE
.
getCode
().
equals
(
topicEntity
.
getSpecialPermission
())){
topicRankQo
.
setHasPermission
(
true
);
}
else
{
topicRankQo
.
setHasPermission
(
false
);
}
topicRankQo
.
setMinutesTillNow
((
int
)
TimeUtils
.
calMinuteTillNow
(
topicEntity
.
getCreateTime
()));
topicRankQo
.
setMinutesTillNow
((
int
)
TimeUtils
.
calMinuteTillNow
(
topicEntity
.
getCreateTime
()));
return
topicRankQo
;
return
topicRankQo
;
}
}
...
...
community-service/src/main/resources/mapper/community/TopicFollowRelEntityMapper.xml
View file @
3e985168
...
@@ -37,6 +37,6 @@
...
@@ -37,6 +37,6 @@
select
select
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from topic_follow_rel
from topic_follow_rel
where topic_id=#{topicId} and user_id=#{userId}
where topic_id=#{topicId} and user_id=#{userId}
and delete_tag = 0
</select>
</select>
</mapper>
</mapper>
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