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
1ddb2104
Commit
1ddb2104
authored
Jul 15, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
转发详情
parent
bd6f25f5
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
78 additions
and
30 deletions
+78
-30
TopicTitileQo.java
.../java/com/tanpu/community/api/beans/qo/TopicTitileQo.java
+4
-1
CreateThemeReq.java
...m/tanpu/community/api/beans/req/theme/CreateThemeReq.java
+2
-2
ForwardThemeReq.java
.../tanpu/community/api/beans/req/theme/ForwardThemeReq.java
+2
-2
ThemeListByTopicReq.java
...pu/community/api/beans/req/theme/ThemeListByTopicReq.java
+9
-1
ThemeListReq.java
...com/tanpu/community/api/beans/req/theme/ThemeListReq.java
+1
-1
CreateThemeResp.java
...a/com/tanpu/community/api/beans/resp/CreateThemeResp.java
+19
-0
TestController.java
...n/java/com/tanpu/community/controller/TestController.java
+1
-1
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+3
-3
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+1
-1
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+1
-1
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+5
-3
TopicManager.java
...c/main/java/com/tanpu/community/manager/TopicManager.java
+5
-1
OSSFileService.java
...main/java/com/tanpu/community/service/OSSFileService.java
+2
-1
ProductService.java
...main/java/com/tanpu/community/service/ProductService.java
+1
-1
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+13
-8
TopicService.java
...c/main/java/com/tanpu/community/service/TopicService.java
+6
-1
UserInfoService.java
...ain/java/com/tanpu/community/service/UserInfoService.java
+2
-2
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/TopicTitileQo.java
View file @
1ddb2104
...
...
@@ -18,5 +18,8 @@ public class TopicTitileQo {
private
String
topicTitle
;
@ApiModelProperty
(
"讨论数"
)
private
Integer
discussionCount
;
private
String
discussionCount
;
@ApiModelProperty
(
"浏览量"
)
private
String
viewCount
;
}
community-api/src/main/java/com/tanpu/community/api/beans/req/theme/CreateThemeReq.java
View file @
1ddb2104
...
...
@@ -26,11 +26,11 @@ public class CreateThemeReq {
private
List
<
ThemeContentReq
>
content
;
@ApiModelProperty
(
value
=
"所属的话题id"
)
private
String
topicId
;
private
String
topicId
=
""
;
@ApiModelProperty
(
value
=
"修改,则传入正在编辑的ThemeId"
)
private
String
editThemeId
;
private
String
editThemeId
=
""
;
}
community-api/src/main/java/com/tanpu/community/api/beans/req/theme/ForwardThemeReq.java
View file @
1ddb2104
...
...
@@ -21,8 +21,8 @@ public class ForwardThemeReq {
private
List
<
ThemeContentReq
>
content
;
@ApiModelProperty
(
value
=
"话题Id"
)
private
String
topicId
;
private
String
topicId
=
""
;
@ApiModelProperty
(
value
=
"修改,则传入正在编辑的ThemeId"
)
private
String
editThemeId
;
private
String
editThemeId
=
""
;
}
community-api/src/main/java/com/tanpu/community/api/beans/req/theme/ThemeListByTopicReq.java
View file @
1ddb2104
...
...
@@ -4,14 +4,22 @@ package com.tanpu.community.api.beans.req.theme;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
@Data
public
class
ThemeListByTopicReq
{
@ApiModelProperty
(
value
=
"当前浏览的最后一个themeId"
)
private
String
lastId
;
private
String
lastId
=
""
;
@NotNull
@ApiModelProperty
(
value
=
"页面大小"
)
private
Integer
PageSize
;
@NotNull
@ApiModelProperty
(
value
=
"类型,1:最热 2:最新"
)
private
Integer
type
;
@NotNull
@ApiModelProperty
(
value
=
"话题Id"
)
private
String
topicId
;
...
...
community-api/src/main/java/com/tanpu/community/api/beans/req/theme/ThemeListReq.java
View file @
1ddb2104
...
...
@@ -18,7 +18,7 @@ public class ThemeListReq {
private
String
topicId
;
@ApiModelProperty
(
value
=
"当前浏览的最后一个themeId,可以为空"
)
private
String
lastId
;
private
String
lastId
=
""
;
@NotNull
(
message
=
"PageSize不能为空"
)
@ApiModelProperty
(
value
=
"页面大小"
)
...
...
community-api/src/main/java/com/tanpu/community/api/beans/resp/CreateThemeResp.java
0 → 100644
View file @
1ddb2104
package
com
.
tanpu
.
community
.
api
.
beans
.
resp
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@ApiModel
(
value
=
"创建主题"
)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
CreateThemeResp
{
@ApiModelProperty
(
value
=
"主题id"
)
private
String
themeId
;
}
community-service/src/main/java/com/tanpu/community/controller/TestController.java
View file @
1ddb2104
...
...
@@ -25,6 +25,6 @@ public class TestController {
@GetMapping
(
value
=
"/1"
)
@ResponseBody
public
Object
sendKafka
()
{
return
userInfoService
.
select
ById
(
"USER_INFO15912897523789"
);
return
userInfoService
.
queryUser
ById
(
"USER_INFO15912897523789"
);
}
}
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
1ddb2104
...
...
@@ -7,6 +7,7 @@ import com.tanpu.common.auth.UserHolder;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.req.theme.*
;
import
com.tanpu.community.api.beans.resp.CreateThemeResp
;
import
com.tanpu.community.manager.ThemeManager
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -32,13 +33,12 @@ public class ThemeController {
@ApiOperation
(
"发表主题"
)
@PostMapping
(
value
=
"/publish"
)
@ResponseBody
public
CommonResp
<
Void
>
publishTheme
(
@Validated
@RequestBody
CreateThemeReq
req
)
{
public
CommonResp
<
CreateThemeResp
>
publishTheme
(
@Validated
@RequestBody
CreateThemeReq
req
)
{
String
userId
=
userHolder
.
getUserId
();
if
(
StringUtils
.
isEmpty
(
userId
)){
throw
new
BizException
(
"用户为空"
);
}
themeManager
.
publishTheme
(
req
,
userId
);
return
CommonResp
.
success
();
return
CommonResp
.
success
(
themeManager
.
publishTheme
(
req
,
userId
));
}
@AuthLogin
...
...
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
1ddb2104
...
...
@@ -61,7 +61,7 @@ public class CommentManager {
for
(
CommentQo
commentQo
:
commentQos
)
{
//用户信息
String
authorId
=
commentQo
.
getAuthorId
();
UserInfoEntity
userInfo
=
userInfoService
.
select
ById
(
authorId
);
UserInfoEntity
userInfo
=
userInfoService
.
queryUser
ById
(
authorId
);
if
(
userInfo
!=
null
)
{
commentQo
.
setUserImg
(
userInfo
.
getUiHeadimg
());
commentQo
.
setNickName
(
userInfo
.
getUiNickname
());
...
...
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
1ddb2104
...
...
@@ -34,7 +34,7 @@ public class HomePageManager {
public
Page
<
FollowQo
>
queryFollow
(
QueryFollowReq
req
,
String
userId
)
{
List
<
String
>
userIds
=
QueryFollowTypeEnum
.
QUERY_FANS
.
getCode
().
equals
(
req
.
getQueryType
())
?
followRelService
.
queryFansByIdolId
(
req
.
getUserId
())
:
followRelService
.
queryFansByFollowerId
(
req
.
getUserId
());
List
<
UserInfoEntity
>
userInfos
=
userInfoService
.
select
ByIds
(
userIds
);
List
<
UserInfoEntity
>
userInfos
=
userInfoService
.
queryUser
ByIds
(
userIds
);
List
<
FollowQo
>
collect
=
userInfos
.
stream
().
map
(
ConvertUtil:
:
homePageEntity2FollowQo
).
collect
(
Collectors
.
toList
());
List
<
FollowQo
>
followQos
=
judgeFollowed
(
collect
,
userId
);
return
PageUtils
.
page
(
req
.
getPage
(),
followQos
);
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
1ddb2104
...
...
@@ -7,6 +7,7 @@ import com.tanpu.community.api.beans.qo.ThemeContentQo;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.req.homepage.QueryRecordThemeReq
;
import
com.tanpu.community.api.beans.req.theme.*
;
import
com.tanpu.community.api.beans.resp.CreateThemeResp
;
import
com.tanpu.community.api.enums.*
;
import
com.tanpu.community.dao.entity.community.*
;
import
com.tanpu.community.dao.entity.user.UserInfoEntity
;
...
...
@@ -58,7 +59,7 @@ public class ThemeManager {
@Transactional
public
void
publishTheme
(
CreateThemeReq
req
,
String
userId
)
{
public
CreateThemeResp
publishTheme
(
CreateThemeReq
req
,
String
userId
)
{
//TODO 敏感词过滤
...
...
@@ -78,6 +79,7 @@ public class ThemeManager {
//保存附件表
List
<
ThemeAttachmentEntity
>
themeAttachments
=
ConvertUtil
.
themeReqToAttachmentList
(
req
,
themeEntity
.
getThemeId
());
themeAttachmentService
.
insertList
(
themeAttachments
);
return
CreateThemeResp
.
builder
().
themeId
(
themeEntity
.
getThemeId
()).
build
();
}
// 返回推荐主题文章
...
...
@@ -111,14 +113,14 @@ public class ThemeManager {
List
<
ThemeEntity
>
themeEntities
=
Collections
.
emptyList
();
switch
(
req
.
getRecordType
())
{
case
1
:
//发布
themeEntities
=
themeService
.
queryTheme
Id
sByUserId
(
req
.
getUserId
(),
req
.
getLastId
(),
req
.
getPageSize
());
themeEntities
=
themeService
.
queryThemesByUserId
(
req
.
getUserId
(),
req
.
getLastId
(),
req
.
getPageSize
());
break
;
case
2
:
//回复
List
<
ThemeQo
>
commentThemeList
=
new
ArrayList
<>();
//评论列表
List
<
CommentEntity
>
commentEntities
=
commentService
.
queryThemesByUserId
(
req
.
getUserId
(),
req
.
getLastId
(),
req
.
getPageSize
());
//当前用户信息
UserInfoEntity
userInfoEntity
=
userInfoService
.
select
ById
(
req
.
getUserId
());
UserInfoEntity
userInfoEntity
=
userInfoService
.
queryUser
ById
(
req
.
getUserId
());
Set
<
String
>
replyThemeIds
=
commentEntities
.
stream
().
map
(
CommentEntity:
:
getThemeId
).
collect
(
Collectors
.
toSet
());
if
(
CollectionUtils
.
isEmpty
(
replyThemeIds
))
{
return
commentThemeList
;
...
...
community-service/src/main/java/com/tanpu/community/manager/TopicManager.java
View file @
1ddb2104
...
...
@@ -68,7 +68,11 @@ public class TopicManager {
//讨论数=发布主题贴数+回复总数
List
<
String
>
themeIds
=
themeService
.
queryThemeIdsByTopic
(
topicQo
.
getTopicId
());
Integer
commentCount
=
commentService
.
getCommentCountByThemeIds
(
themeIds
);
topicQo
.
setDiscussionCount
(
themeIds
.
size
()
+
commentCount
);
topicQo
.
setDiscussionCount
(
String
.
valueOf
(
themeIds
.
size
()
+
commentCount
));
//浏览量
Integer
topicPV
=
visitSummaryService
.
queryTopicDetailVisit
(
topicQo
.
getTopicId
());
Integer
themePV
=
visitSummaryService
.
queryThemeVisit
(
themeIds
);
topicQo
.
setViewCount
(
String
.
valueOf
(
topicPV
+
themePV
));
}
//TODO 判断顶置
return
PageUtils
.
page
(
req
.
getPage
(),
topicTitileQos
);
...
...
community-service/src/main/java/com/tanpu/community/service/OSSFileService.java
View file @
1ddb2104
...
...
@@ -116,7 +116,8 @@ public class OSSFileService {
}
public
FileRecordEntity
queryById
(
String
fileId
)
{
return
fileRecordMapper
.
selectById
(
fileId
);
return
fileRecordMapper
.
selectOne
(
new
LambdaQueryWrapper
<
FileRecordEntity
>()
.
eq
(
FileRecordEntity:
:
getFileId
,
fileId
));
}
public
List
<
FileRecordEntity
>
queryByIds
(
List
<
String
>
fileIds
)
{
...
...
community-service/src/main/java/com/tanpu/community/service/ProductService.java
View file @
1ddb2104
...
...
@@ -239,7 +239,7 @@ public class ProductService {
if
(!
CollectionUtils
.
isEmpty
(
userIds
))
{
// 查询用户信息
List
<
UserInfoEntity
>
userInfos
=
userInfoService
.
select
ByIds
(
setToList
(
userIds
));
userInfoService
.
queryUser
ByIds
(
setToList
(
userIds
));
if
(!
CollectionUtils
.
isEmpty
(
userIds
))
{
userMap
.
putAll
(
userInfos
.
stream
().
collect
(
Collectors
.
toMap
(
UserInfoEntity:
:
getId
,
o
->
o
)));
...
...
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
1ddb2104
...
...
@@ -44,14 +44,14 @@ public class ThemeService {
.
eq
(
ThemeEntity:
:
getThemeId
,
themeId
));
}
public
List
<
ThemeEntity
>
queryTheme
Id
sByUserId
(
String
userId
)
{
public
List
<
ThemeEntity
>
queryThemesByUserId
(
String
userId
)
{
return
themeMapper
.
selectList
(
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getAuthorId
,
userId
)
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByDesc
(
ThemeEntity:
:
getId
));
}
public
List
<
ThemeEntity
>
queryTheme
IdsByUserId
(
String
userId
,
String
lastId
,
Integer
pageSize
)
{
public
List
<
ThemeEntity
>
queryTheme
sByUserId
(
String
userId
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getAuthorId
,
userId
)
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
...
...
@@ -94,15 +94,19 @@ public class ThemeService {
//分页倒叙lastId之前的主题
public
List
<
ThemeEntity
>
selectAll
(
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
orderByDesc
(
ThemeEntity:
:
getUpdateTime
);
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>();
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
}
queryWrapper
.
last
(
"limit "
+
pageSize
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getId
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getCreateTime
);
queryWrapper
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
return
themeMapper
.
selectList
(
queryWrapper
);
}
...
...
@@ -125,7 +129,8 @@ public class ThemeService {
if
(
pageSize
!=
null
){
queryWrapper
.
last
(
"limit "
+
pageSize
);
}
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getId
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getCreateTime
);
queryWrapper
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
return
themeMapper
.
selectList
(
queryWrapper
);
}
...
...
@@ -144,15 +149,15 @@ public class ThemeService {
//关注的主题列表
public
List
<
ThemeEntity
>
queryByUserIds
(
List
<
String
>
userIds
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
in
(
ThemeEntity:
:
getAuthorId
,
userIds
)
.
orderByDesc
(
ThemeEntity:
:
getUpdateTime
);
.
in
(
ThemeEntity:
:
getAuthorId
,
userIds
);
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
}
queryWrapper
.
last
(
"limit "
+
pageSize
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getCreateTime
);
queryWrapper
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
return
themeMapper
.
selectList
(
queryWrapper
);
}
...
...
community-service/src/main/java/com/tanpu/community/service/TopicService.java
View file @
1ddb2104
...
...
@@ -7,12 +7,14 @@ import com.tanpu.community.api.enums.DeleteTagEnum;
import
com.tanpu.community.api.enums.TopicStatusEnum
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.mapper.community.TopicMapper
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -83,11 +85,14 @@ public class TopicService {
}
public
List
<
TopicEntity
>
queryByIds
(
List
<
String
>
topicIds
)
{
if
(
CollectionUtils
.
isEmpty
(
topicIds
)){
return
Collections
.
emptyList
();
}
return
topicMapper
.
selectList
(
new
LambdaQueryWrapper
<
TopicEntity
>().
in
(
TopicEntity:
:
getTopicId
,
topicIds
));
}
public
void
modifyViewCount
(
String
topicId
,
long
Count
)
{
TopicEntity
topicEntity
=
topicMapper
.
select
ById
(
topicId
);
TopicEntity
topicEntity
=
query
ById
(
topicId
);
Long
oldCount
=
topicEntity
.
getviewCntAdjust
();
topicEntity
.
setViewAmountModify
(
topicEntity
.
getviewCntAdjust
()
+
Count
);
topicMapper
.
update
(
topicEntity
,
new
LambdaUpdateWrapper
<
TopicEntity
>()
...
...
community-service/src/main/java/com/tanpu/community/service/UserInfoService.java
View file @
1ddb2104
...
...
@@ -14,11 +14,11 @@ public class UserInfoService {
private
UserInfoMapper
userInfoMapper
;
public
UserInfoEntity
select
ById
(
String
userId
)
{
public
UserInfoEntity
queryUser
ById
(
String
userId
)
{
return
userInfoMapper
.
selectById
(
userId
);
}
public
List
<
UserInfoEntity
>
select
ByIds
(
List
<
String
>
ids
)
{
public
List
<
UserInfoEntity
>
queryUser
ByIds
(
List
<
String
>
ids
)
{
return
userInfoMapper
.
selectBatchIds
(
ids
);
}
}
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
1ddb2104
...
...
@@ -203,4 +203,5 @@ public class ConvertUtil {
}
}
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