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
0bf55beb
Commit
0bf55beb
authored
Jul 09, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
话题接口修改
parent
4e1fe397
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
177 additions
and
110 deletions
+177
-110
MainTextQo.java
...ain/java/com/tanpu/community/api/beans/qo/MainTextQo.java
+6
-3
ThemeQo.java
...c/main/java/com/tanpu/community/api/beans/qo/ThemeQo.java
+5
-0
TopicDetailQo.java
.../java/com/tanpu/community/api/beans/qo/TopicDetailQo.java
+6
-2
TopicTitileQo.java
.../java/com/tanpu/community/api/beans/qo/TopicTitileQo.java
+1
-1
ThemeListReq.java
...com/tanpu/community/api/beans/req/theme/ThemeListReq.java
+4
-4
ThemeListTypeEnum.java
...java/com/tanpu/community/api/enums/ThemeListTypeEnum.java
+32
-0
AdminController.java
.../java/com/tanpu/community/controller/AdminController.java
+27
-31
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+2
-3
TopicController.java
.../java/com/tanpu/community/controller/TopicController.java
+4
-5
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+17
-22
TopicManager.java
...c/main/java/com/tanpu/community/manager/TopicManager.java
+36
-19
CollectionService.java
...n/java/com/tanpu/community/service/CollectionService.java
+4
-5
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+20
-7
TopicService.java
...c/main/java/com/tanpu/community/service/TopicService.java
+1
-1
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+10
-5
PageUtils.java
...ice/src/main/java/com/tanpu/community/util/PageUtils.java
+1
-1
application-dev.yml
community-service/src/main/resources/application-dev.yml
+1
-1
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/MainTextQo.java
View file @
0bf55beb
...
...
@@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModel;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.
util.List
;
import
java.
time.LocalDateTime
;
/**
* 正文
...
...
@@ -60,8 +60,11 @@ public class MainTextQo {
@ApiModelProperty
(
value
=
"点赞量"
)
private
Integer
likeCount
;
@ApiModelProperty
(
"附件,"
)
private
List
<
AttachmentQo
>
attachment
;
private
LocalDateTime
createTime
;
private
LocalDateTime
updateTime
;
}
community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeQo.java
View file @
0bf55beb
...
...
@@ -64,4 +64,9 @@ public class ThemeQo {
@ApiModelProperty
(
value
=
"转发的主题"
)
private
ThemeFormerQo
formerTheme
;
private
LocalDateTime
createTime
;
private
LocalDateTime
updateTime
;
}
community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicDetailQo.java
View file @
0bf55beb
...
...
@@ -2,9 +2,15 @@ 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
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel
(
"话题详情对象"
)
public
class
TopicDetailQo
{
...
...
@@ -20,6 +26,4 @@ public class TopicDetailQo {
@ApiModelProperty
(
value
=
"讨论量"
)
private
Integer
disscussCount
;
@ApiModelProperty
(
value
=
"类型 1:热 2:新"
)
private
Integer
type
;
}
community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicTitileQo.java
View file @
0bf55beb
...
...
@@ -15,7 +15,7 @@ public class TopicTitileQo {
private
String
topicId
;
@ApiModelProperty
(
"话题名称"
)
private
String
title
;
private
String
t
opicT
itle
;
@ApiModelProperty
(
"讨论数"
)
private
Integer
discussionCount
;
...
...
community-api/src/main/java/com/tanpu/community/api/beans/req/theme/ThemeListReq.java
View file @
0bf55beb
...
...
@@ -4,18 +4,18 @@ package com.tanpu.community.api.beans.req.theme;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.Not
Empty
;
import
javax.validation.constraints.Not
Null
;
@Data
public
class
ThemeListReq
{
@ApiModelProperty
(
value
=
"当前浏览的最后一个themeId,可以为空"
)
private
String
lastId
;
@Not
Empty
(
message
=
"PageSize不能为空"
)
@Not
Null
(
message
=
"PageSize不能为空"
)
@ApiModelProperty
(
value
=
"页面大小"
)
private
Integer
P
ageSize
;
private
Integer
p
ageSize
;
@Not
Empty
(
message
=
"主题类型不能为空"
)
@Not
Null
(
message
=
"主题类型不能为空"
)
@ApiModelProperty
(
value
=
"类型,1:推荐 2:关注"
)
private
Integer
type
;
...
...
community-api/src/main/java/com/tanpu/community/api/enums/ThemeListTypeEnum.java
0 → 100644
View file @
0bf55beb
package
com
.
tanpu
.
community
.
api
.
enums
;
public
enum
ThemeListTypeEnum
{
RECOMMEND
(
1
,
"推荐列表"
),
FOLLOW
(
2
,
"关注列表"
);
private
Integer
code
;
private
String
type
;
ThemeListTypeEnum
(
Integer
code
,
String
type
)
{
this
.
code
=
code
;
this
.
type
=
type
;
}
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
}
community-service/src/main/java/com/tanpu/community/controller/AdminController.java
View file @
0bf55beb
...
...
@@ -2,15 +2,11 @@ package com.tanpu.community.controller;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.auth.UserHolder
;
import
com.tanpu.community.api.beans.TopicDO
;
import
com.tanpu.community.api.beans.TopicDataAnalysDTO
;
import
com.tanpu.community.api.beans.req.topic.TopicConcealReq
;
import
com.tanpu.community.api.beans.req.topic.TopicModifyMountReq
;
import
com.tanpu.community.api.beans.req.topic.TopicTopReq
;
import
com.tanpu.community.manager.TopicManager
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.MissingServletRequestParameterException
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -35,17 +31,17 @@ public class AdminController {
topicManager
.
insertTopic
(
topicTitle
,
userId
);
return
CommonResp
.
success
();
}
@ApiOperation
(
"单个话题详细数据"
)
@GetMapping
(
"/detailData"
)
@ResponseBody
public
CommonResp
<
TopicDO
>
selectOne
(
@RequestParam
String
topicId
)
throws
MissingServletRequestParameterException
{
if
(
StringUtils
.
isEmpty
(
topicId
)){
throw
new
MissingServletRequestParameterException
(
"topicId"
,
"String"
);
}
TopicDO
topicDO
=
topicManager
.
getDetail
(
topicId
);
return
CommonResp
.
success
(
topicDO
);
}
//
//
@ApiOperation("单个话题详细数据")
//
@GetMapping("/detailData")
//
@ResponseBody
//
public CommonResp<TopicDO> selectOne(@RequestParam String topicId) throws MissingServletRequestParameterException {
//
if (StringUtils.isEmpty(topicId)){
//
throw new MissingServletRequestParameterException("topicId","String");
//
}
//
TopicDO topicDO =topicManager.getDetail(topicId);
//
return CommonResp.success(topicDO);
//
}
@PostMapping
(
value
=
"/setTop"
)
@ApiOperation
(
"顶置/取消顶置话题"
)
...
...
@@ -62,20 +58,20 @@ public class AdminController {
topicManager
.
setTopicConceal
(
req
.
getTopicId
(),
req
.
isConceal
());
return
CommonResp
.
success
();
}
@PostMapping
(
value
=
"/modifyViewNum"
)
@ApiOperation
(
"话题浏览数调整(后台管理)"
)
@ResponseBody
public
CommonResp
<
Void
>
modifyViewNum
(
@RequestBody
TopicModifyMountReq
req
)
throws
MissingServletRequestParameterException
{
topicManager
.
modifyViewCount
(
req
.
getTopicId
(),
req
.
getModifyMount
());
return
CommonResp
.
success
();
}
@GetMapping
(
value
=
"/dataAnalyse"
)
@ApiOperation
(
"话题数据分析"
)
@ResponseBody
public
CommonResp
<
TopicDataAnalysDTO
>
dataAnalyse
(
@RequestParam
String
topicId
)
throws
MissingServletRequestParameterException
{
TopicDataAnalysDTO
result
=
topicManager
.
queryDataAnalysis
(
topicId
);
return
CommonResp
.
success
(
result
);
}
//
//
@PostMapping(value = "/modifyViewNum")
//
@ApiOperation("话题浏览数调整(后台管理)")
//
@ResponseBody
//
public CommonResp<Void> modifyViewNum(@RequestBody TopicModifyMountReq req) throws MissingServletRequestParameterException {
//
topicManager.modifyViewCount(req.getTopicId(),req.getModifyMount());
//
return CommonResp.success();
//
}
//
//
@GetMapping(value = "/dataAnalyse")
//
@ApiOperation("话题数据分析")
//
@ResponseBody
//
public CommonResp<TopicDataAnalysDTO> dataAnalyse(@RequestParam String topicId) throws MissingServletRequestParameterException {
//
TopicDataAnalysDTO result =topicManager.queryDataAnalysis(topicId);
//
return CommonResp.success(result);
//
}
}
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
0bf55beb
...
...
@@ -40,10 +40,9 @@ public class ThemeController {
@ApiOperation
(
"圈子首页-推荐/关注"
)
@PostMapping
(
value
=
"/list"
)
@ResponseBody
public
CommonResp
<
List
<
ThemeQo
>>
selectInterestList
(
@RequestBody
ThemeListReq
req
)
{
public
CommonResp
<
List
<
ThemeQo
>>
selectInterestList
(
@
Validated
@
RequestBody
ThemeListReq
req
)
{
String
userId
=
"liujm"
;
List
<
ThemeQo
>
result
=
req
.
getType
()==
1
?
themeManager
.
selectHotThemes
(
req
,
userId
)
:
themeManager
.
selectInterestThemes
(
req
,
userId
);
List
<
ThemeQo
>
result
=
themeManager
.
queryThemeList
(
req
,
userId
);
return
CommonResp
.
success
(
result
);
}
...
...
community-service/src/main/java/com/tanpu/community/controller/TopicController.java
View file @
0bf55beb
...
...
@@ -30,7 +30,7 @@ public class TopicController {
@PostMapping
(
value
=
"/list"
)
@ApiOperation
(
"APP全部话题页面,可搜索"
)
@ResponseBody
public
CommonResp
<
Page
<
TopicTitileQo
>>
getTopicBriefInfoList
(
TopicSearchReq
req
){
public
CommonResp
<
Page
<
TopicTitileQo
>>
getTopicBriefInfoList
(
@RequestBody
TopicSearchReq
req
){
Page
<
TopicTitileQo
>
allTopic
=
topicManager
.
getAllTopicBriefInfo
(
req
);
return
CommonResp
.
success
(
allTopic
);
}
...
...
@@ -40,8 +40,8 @@ public class TopicController {
@ResponseBody
public
CommonResp
<
TopicDetailQo
>
gethotThemes
(
@RequestParam
String
topicId
){
//todo
return
CommonResp
.
success
(
);
TopicDetailQo
detail
=
topicManager
.
getDetail
(
topicId
);
return
CommonResp
.
success
(
detail
);
}
...
...
@@ -49,8 +49,7 @@ public class TopicController {
@ApiOperation
(
"首页顶部话题标题列"
)
@ResponseBody
public
CommonResp
<
List
<
TopicHotQo
>>
getTitleList
(){
//todo
return
CommonResp
.
success
();
return
CommonResp
.
success
(
topicManager
.
getHotTopicTitles
());
}
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
0bf55beb
...
...
@@ -11,6 +11,7 @@ import com.tanpu.community.api.beans.req.theme.ThemeListByTopicReq;
import
com.tanpu.community.api.beans.req.theme.ThemeListReq
;
import
com.tanpu.community.api.enums.BlockTypeEnum
;
import
com.tanpu.community.api.enums.CollectionTypeEnum
;
import
com.tanpu.community.api.enums.ThemeListTypeEnum
;
import
com.tanpu.community.api.enums.ThemeTypeEnum
;
import
com.tanpu.community.dao.entity.community.BlackListEntity
;
import
com.tanpu.community.dao.entity.community.HomePageEntity
;
...
...
@@ -89,7 +90,6 @@ public class ThemeManager {
private
FeignClientForCourse
feignClientForCourse
;
public
void
publishTheme
(
CreateThemeReq
req
,
String
userId
)
{
ThemeEntity
themeEntity
=
new
ThemeEntity
();
BeanUtils
.
copyProperties
(
req
,
themeEntity
);
...
...
@@ -103,25 +103,22 @@ public class ThemeManager {
}
// 返回推荐主题文章
public
List
<
ThemeQo
>
selectHotThemes
(
ThemeListReq
req
,
String
userId
)
{
// TODO:推荐
List
<
ThemeEntity
>
themeEntities
=
themeService
.
selectAll
(
req
.
getLastId
(),
req
.
getPageSize
());
public
List
<
ThemeQo
>
queryThemeList
(
ThemeListReq
req
,
String
userId
)
{
List
<
ThemeEntity
>
themeEntities
;
if
(
ThemeListTypeEnum
.
RECOMMEND
.
getCode
().
equals
(
req
.
getType
()))
{
// TODO:推荐
themeEntities
=
themeService
.
selectAll
(
req
.
getLastId
(),
req
.
getPageSize
());
}
else
{
List
<
String
>
fansList
=
followRelService
.
queryFansByFollowerId
(
userId
);
themeEntities
=
themeService
.
queryByFans
(
fansList
,
req
.
getLastId
(),
req
.
getPageSize
());
}
List
<
ThemeQo
>
themeQos
=
convertEntityToQo
(
themeEntities
,
userId
);
return
themeQos
;
}
// 返回关注主题
public
List
<
ThemeQo
>
selectInterestThemes
(
ThemeListReq
req
,
String
userId
)
{
List
<
String
>
fansList
=
followRelService
.
queryFansByFollowerId
(
userId
);
List
<
ThemeEntity
>
themeEntities
=
themeService
.
queryByFans
(
fansList
,
req
.
getLastId
(),
req
.
getPageSize
());
List
<
ThemeQo
>
themeQos
=
convertEntityToQo
(
themeEntities
,
userId
);
return
themeQos
;
}
public
List
<
ThemeQo
>
queryByTopic
(
ThemeListByTopicReq
req
,
String
userId
)
{
//TODO
List
<
ThemeEntity
>
themeEntities
=
themeService
.
queryByTopic
(
req
.
getTopicId
(),
req
.
getLastId
(),
req
.
getPageSize
());
List
<
ThemeEntity
>
themeEntities
=
themeService
.
queryByTopic
(
req
.
getTopicId
(),
req
.
getLastId
(),
req
.
getPageSize
());
List
<
ThemeQo
>
themeQos
=
convertEntityToQo
(
themeEntities
,
userId
);
return
themeQos
;
}
...
...
@@ -129,13 +126,13 @@ public class ThemeManager {
//返回正文
public
MainTextQo
getMainText
(
String
themeId
,
String
userId
)
{
ThemeEntity
themeEntity
=
themeService
.
queryById
(
themeId
);
ThemeEntity
themeEntity
=
themeService
.
queryBy
Theme
Id
(
themeId
);
if
(
themeEntity
==
null
)
{
throw
new
BizException
(
"找不到帖子id:"
+
themeId
);
}
MainTextQo
mainTextQo
=
new
MainTextQo
();
BeanUtils
.
copyProperties
(
themeEntity
,
mainTextQo
);
buildMainTestExtraInfo
(
mainTextQo
,
userId
);
buildMainTestExtraInfo
(
mainTextQo
,
userId
);
return
mainTextQo
;
}
...
...
@@ -148,10 +145,9 @@ public class ThemeManager {
}
//转发
public
void
forward
(
ForwardThemeReq
req
,
String
userId
)
{
ThemeEntity
targetTheme
=
themeService
.
queryById
(
req
.
getFormerThemeId
());
ThemeEntity
targetTheme
=
themeService
.
queryBy
Theme
Id
(
req
.
getFormerThemeId
());
ThemeEntity
newTheme
=
ThemeEntity
.
builder
()
.
content
(
req
.
getContent
())
.
topicId
(
req
.
getTopicId
())
...
...
@@ -194,9 +190,9 @@ public class ThemeManager {
// 屏蔽(主题)
public
void
blockTheme
(
String
themeId
,
String
userId
)
{
blackListService
.
addBlock
(
themeId
,
userId
,
BlockTypeEnum
.
THEME
);
BlackListEntity
selectOne
=
blackListService
.
selectOne
(
themeService
.
queryById
(
themeId
).
getAuthorId
(),
userId
,
BlockTypeEnum
.
USER
.
getCode
());
BlackListEntity
selectOne
=
blackListService
.
selectOne
(
themeService
.
queryBy
Theme
Id
(
themeId
).
getAuthorId
(),
userId
,
BlockTypeEnum
.
USER
.
getCode
());
if
(
selectOne
==
null
)
{
blackListService
.
addBlock
(
themeService
.
queryById
(
themeId
).
getAuthorId
(),
userId
,
BlockTypeEnum
.
USER
);
blackListService
.
addBlock
(
themeService
.
queryBy
Theme
Id
(
themeId
).
getAuthorId
(),
userId
,
BlockTypeEnum
.
USER
);
}
}
...
...
@@ -253,9 +249,8 @@ public class ThemeManager {
List
<
AttachmentQo
>
attachmentQos
=
new
ArrayList
<>();
attachments
.
forEach
(
o
->
attachmentQos
.
add
(
AttachmentQo
.
builder
()
.
type
(
o
.
getAttachType
())
.
attachment
(
transferAttachment
(
o
,
userId
))
.
attachment
(
transferAttachment
(
o
,
userId
))
.
build
()));
maintTextQo
.
setAttachment
(
attachmentQos
);
}
//迄今时间
maintTextQo
.
setUpToNowTime
(
calUpToNowTime
(
maintTextQo
.
getCreateTime
()));
...
...
community-service/src/main/java/com/tanpu/community/manager/TopicManager.java
View file @
0bf55beb
...
...
@@ -3,23 +3,24 @@ package com.tanpu.community.manager;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.community.api.beans.TopicDO
;
import
com.tanpu.community.api.beans.TopicDataAnalysDTO
;
import
com.tanpu.community.api.beans.qo.TopicDetailQo
;
import
com.tanpu.community.api.beans.qo.TopicHotQo
;
import
com.tanpu.community.api.beans.qo.TopicTitileQo
;
import
com.tanpu.community.api.beans.req.topic.TopicSearchReq
;
import
com.tanpu.community.api.beans.req.page.Page
;
import
com.tanpu.community.api.beans.req.topic.TopicSearchReq
;
import
com.tanpu.community.api.constants.RedisKeyConstant
;
import
com.tanpu.community.api.enums.CollectionTypeEnum
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.service.*
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.PageUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
@Service
public
class
TopicManager
{
...
...
@@ -58,16 +59,43 @@ public class TopicManager {
public
Page
<
TopicTitileQo
>
getAllTopicBriefInfo
(
TopicSearchReq
req
)
{
List
<
TopicEntity
>
allTopic
=
topicService
.
queryByKeyword
(
req
.
getSearchKeyword
());
List
<
TopicTitileQo
>
topicTitileQos
=
ConvertUtil
.
topicEntitiesToBriefDTOs
(
allTopic
);
//讨论数=发布主题贴数+回复总数
for
(
TopicTitileQo
topicQo
:
topicTitileQos
)
{
//TODO 讨论数=发布主题贴数+回复总数
// Integer commentCountByThemeIds = commentService.getCommentCountByThemeIds(themeIds);
topicQo
.
setDiscussionCount
(
0
);
}
//TODO 判断顶置
return
PageUtils
.
page
(
req
.
getPage
(),
topicTitileQos
);
}
public
TopicDetailQo
getDetail
(
String
topicId
)
{
TopicEntity
topicEntity
=
topicService
.
queryById
(
topicId
);
if
(
topicEntity
==
null
)
{
throw
new
BizException
(
"找不到话题,id:"
+
topicId
);
}
TopicDetailQo
topicDetailQo
=
new
TopicDetailQo
();
BeanUtils
.
copyProperties
(
topicEntity
,
topicDetailQo
);
List
<
String
>
themeIds
=
themeService
.
queryThemeIdsByTopic
(
topicId
);
Integer
likeCountByThemeIds
=
collectionService
.
getCountByTypeAndIds
(
themeIds
,
CollectionTypeEnum
.
LIKE_THEME
);
Integer
bookCountByThemeIds
=
collectionService
.
getCountByTypeAndIds
(
themeIds
,
CollectionTypeEnum
.
BOOK_THEME
);
//TODO 浏览量
topicDetailQo
.
setViewCount
(
0
);
//讨论数=发布主题贴数+回复总数
Integer
commentCount
=
commentService
.
getCommentCountByThemeIds
(
themeIds
);
topicDetailQo
.
setDisscussCount
(
themeIds
.
size
()+
commentCount
);
return
topicDetailQo
;
}
public
List
<
TopicHotQo
>
getHotTopicTitles
(){
List
<
TopicEntity
>
topicEntities
=
topicService
.
queryAll
();
List
<
TopicHotQo
>
topicHotQos
=
ConvertUtil
.
topicEntityToHotQos
(
topicEntities
);
//TODO 添加类型:热 新 顶
return
topicHotQos
;
}
public
void
setTopTopic
(
String
topicId
,
boolean
setTop
)
{
TopicEntity
topicEntity
=
topicService
.
queryById
(
topicId
);
...
...
@@ -93,17 +121,7 @@ public class TopicManager {
}
}
public
TopicDO
getDetail
(
String
topicId
)
{
TopicEntity
topicEntity
=
topicService
.
queryById
(
topicId
);
if
(
topicEntity
==
null
)
{
throw
new
BizException
(
"找不到话题,id:"
+
topicId
);
}
TopicDO
topicDO
=
ConvertUtil
.
topicEntityToDTO
(
topicEntity
);
topicDO
.
setViewCount
(
redisService
.
getInteger
(
RedisKeyConstant
.
TOPIC_TOTAL_VIEW_COUNT_
+
topicId
));
topicDO
.
setLikeCount
(
redisService
.
getInteger
(
RedisKeyConstant
.
TOPIC_LIKE_COUNT_
+
topicId
));
topicDO
.
setUserCount
(
redisService
.
getInteger
(
RedisKeyConstant
.
TOPIC_USER_COUNT_
+
topicId
));
return
topicDO
;
}
public
void
modifyViewCount
(
String
topicId
,
Long
modifyMount
)
{
TopicEntity
topicEntity
=
topicService
.
queryById
(
topicId
);
...
...
@@ -125,8 +143,7 @@ public class TopicManager {
for
(
TopicEntity
topic
:
topicEntities
)
{
String
topicId
=
topic
.
getTopicId
();
Long
viewCountModify
=
topic
.
getviewCntAdjust
();
List
<
ThemeEntity
>
themeEntities
=
themeService
.
queryByTopic
(
topicId
,
null
,
null
);
List
<
String
>
themeIds
=
themeEntities
.
stream
().
map
(
ThemeEntity:
:
getThemeId
).
collect
(
Collectors
.
toList
());
List
<
String
>
themeIds
=
themeService
.
queryThemeIdsByTopic
(
topicId
);
Integer
likeCountByThemeIds
=
collectionService
.
getCountByTypeAndIds
(
themeIds
,
CollectionTypeEnum
.
LIKE_THEME
);
Integer
bookCountByThemeIds
=
collectionService
.
getCountByTypeAndIds
(
themeIds
,
CollectionTypeEnum
.
BOOK_THEME
);
Long
commentCountByThemeIds
=
(
long
)
commentService
.
getCommentCountByThemeIds
(
themeIds
);
...
...
community-service/src/main/java/com/tanpu/community/service/CollectionService.java
View file @
0bf55beb
...
...
@@ -68,8 +68,7 @@ public class CollectionService {
}
// 统计单个主题的数量
// 统计单个对象(主题、评论)的数量(点赞、收藏)
public
Integer
getCountByTypeAndId
(
String
targetId
,
CollectionTypeEnum
type
)
{
return
collectionMapper
.
selectCount
((
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getTargetId
,
targetId
)
...
...
@@ -77,10 +76,10 @@ public class CollectionService {
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())));
}
// 统计多个
主题的点赞量
public
Integer
getCountByTypeAndIds
(
List
<
String
>
t
heme
Ids
,
CollectionTypeEnum
type
)
{
// 统计多个
对象(主题、评论)的数量(点赞、收藏)
public
Integer
getCountByTypeAndIds
(
List
<
String
>
t
arget
Ids
,
CollectionTypeEnum
type
)
{
return
collectionMapper
.
selectCount
((
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
in
(
CollectionEntity:
:
getTargetId
,
t
heme
Ids
)
.
in
(
CollectionEntity:
:
getTargetId
,
t
arget
Ids
)
.
eq
(
CollectionEntity:
:
getCollectionType
,
type
.
getCode
()))
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()));
}
...
...
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
0bf55beb
...
...
@@ -30,27 +30,40 @@ public class ThemeService {
}
//根据id返回主题详情
public
ThemeEntity
queryById
(
String
themeId
)
{
return
themeMapper
.
select
ById
(
themeId
);
public
ThemeEntity
queryBy
Theme
Id
(
String
themeId
)
{
return
themeMapper
.
select
One
(
new
LambdaQueryWrapper
<
ThemeEntity
>().
eq
(
ThemeEntity:
:
getThemeId
,
themeId
)
);
}
//根据话题查询主题
/**
* 根据条件查询主题
* @param topidId 话题Id
* @param lastId 查询此主题Id之前的主题
* @param pageSize 查询数量
* @return
*/
public
List
<
ThemeEntity
>
queryByTopic
(
String
topidId
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getTopicId
,
topidId
);
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
ThemeEntity
lastEntity
=
queryById
(
lastId
);
ThemeEntity
lastEntity
=
queryBy
Theme
Id
(
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getUpdateTime
());
}
if
(
pageSize
!=
null
){
queryWrapper
.
last
(
"limit "
+
pageSize
);
}
return
themeMapper
.
selectList
(
queryWrapper
);
}
//根据话题查询所有的主题Id
public
List
<
String
>
queryThemeIdsByTopic
(
String
topidId
)
{
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getTopicId
,
topidId
);
queryWrapper
.
select
(
ThemeEntity:
:
getThemeId
);
return
themeMapper
.
selectList
(
queryWrapper
).
stream
().
map
(
ThemeEntity:
:
getThemeId
).
collect
(
Collectors
.
toList
());
}
//关注的主题列表
public
List
<
ThemeEntity
>
queryByFans
(
List
<
String
>
fansList
,
String
lastId
,
Integer
pageSize
)
{
...
...
@@ -58,7 +71,7 @@ public class ThemeService {
.
in
(
ThemeEntity:
:
getAuthorId
,
fansList
)
.
orderByDesc
(
ThemeEntity:
:
getUpdateTime
);
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
ThemeEntity
lastEntity
=
queryById
(
lastId
);
ThemeEntity
lastEntity
=
queryBy
Theme
Id
(
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getUpdateTime
());
}
...
...
@@ -73,7 +86,7 @@ public class ThemeService {
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
orderByDesc
(
ThemeEntity:
:
getUpdateTime
);
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
ThemeEntity
lastEntity
=
queryById
(
lastId
);
ThemeEntity
lastEntity
=
queryBy
Theme
Id
(
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getUpdateTime
());
}
...
...
community-service/src/main/java/com/tanpu/community/service/TopicService.java
View file @
0bf55beb
...
...
@@ -78,7 +78,7 @@ public class TopicService {
}
public
TopicEntity
queryById
(
String
topicId
)
{
return
topicMapper
.
select
ById
(
topicId
);
return
topicMapper
.
select
One
(
new
LambdaQueryWrapper
<
TopicEntity
>().
eq
(
TopicEntity:
:
getTopicId
,
topicId
)
);
}
public
void
modifyViewCount
(
String
topicId
,
long
Count
)
{
...
...
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
0bf55beb
...
...
@@ -33,17 +33,22 @@ public class ConvertUtil {
}
public
static
List
<
ThemeEntity
>
themeDTOSToEntitys
(
List
<
ThemeQo
>
themeQos
)
{
return
themeQos
.
stream
().
map
(
ConvertUtil:
:
themeDTOToEntity
).
collect
(
Collectors
.
toList
());
}
public
static
TopicDO
topicEntityToDTO
(
TopicEntity
topicEntity
)
{
TopicDO
topicDO
=
new
TopicDO
();
BeanUtils
.
copyProperties
(
topicEntity
,
topicDO
);
return
topicDO
;
}
public
static
TopicHotQo
topicEntityToHotQo
(
TopicEntity
topicEntity
)
{
TopicHotQo
topicHotQo
=
new
TopicHotQo
();
BeanUtils
.
copyProperties
(
topicEntity
,
topicHotQo
);
return
topicHotQo
;
}
public
static
List
<
TopicHotQo
>
topicEntityToHotQos
(
List
<
TopicEntity
>
topicEntities
){
return
topicEntities
.
stream
().
map
(
ConvertUtil:
:
topicEntityToHotQo
).
collect
(
Collectors
.
toList
());
}
public
static
TopicTitileQo
topicToBriefInfoDTO
(
TopicEntity
topicEntity
)
{
TopicTitileQo
topicTitileQo
=
new
TopicTitileQo
();
BeanUtils
.
copyProperties
(
topicEntity
,
topicTitileQo
);
...
...
community-service/src/main/java/com/tanpu/community/util/PageUtils.java
View file @
0bf55beb
...
...
@@ -32,7 +32,7 @@ public class PageUtils {
int
toIndex
;
// 防止索引越界
if
(
Integer
.
getInteger
(
"0"
).
equals
(
pageable
.
getPageNumber
()))
{
if
(
Integer
.
valueOf
(
0
).
equals
(
pageable
.
getPageNumber
()))
{
pageable
.
setPageNumber
(
1
);
}
...
...
community-service/src/main/resources/application-dev.yml
View file @
0bf55beb
apollo.bootstrap.enabled
:
tru
e
apollo.bootstrap.enabled
:
fals
e
#app.id: tanpu-community
#apollo:
...
...
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