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
12c3a20d
Commit
12c3a20d
authored
Jul 06, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
正文resp
parent
f043bc2c
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
220 additions
and
85 deletions
+220
-85
CommentQo.java
...main/java/com/tanpu/community/api/beans/qo/CommentQo.java
+45
-0
MainTextQo.java
...ain/java/com/tanpu/community/api/beans/qo/MainTextQo.java
+31
-0
CreateThemeReq.java
...ava/com/tanpu/community/api/beans/req/CreateThemeReq.java
+3
-3
HomePageController.java
...va/com/tanpu/community/controller/HomePageController.java
+9
-9
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+11
-20
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+71
-34
CollectionService.java
...n/java/com/tanpu/community/service/CollectionService.java
+4
-1
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+11
-0
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+16
-7
application-dev.yml
community-service/src/main/resources/application-dev.yml
+18
-10
application.yml
community-service/src/main/resources/application.yml
+1
-1
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/CommentQo.java
0 → 100644
View file @
12c3a20d
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.time.LocalDateTime
;
@Data
public
class
CommentQo
{
@ApiModelProperty
(
value
=
"id"
)
private
String
id
;
@ApiModelProperty
(
value
=
"类型"
)
private
Integer
commentType
;
@ApiModelProperty
(
value
=
"文本内容"
)
private
String
content
;
@ApiModelProperty
(
value
=
"作者id"
)
private
String
authorId
;
@ApiModelProperty
(
value
=
"评论的目标id"
)
private
String
targetId
;
@ApiModelProperty
(
value
=
"是否屏蔽"
)
private
Integer
isBlock
;
@ApiModelProperty
(
value
=
"转发量"
)
private
Long
forwardAomunt
;
@ApiModelProperty
(
value
=
"点赞量"
)
private
Long
likeAmount
;
private
String
createBy
;
private
LocalDateTime
createTime
;
private
String
updateBy
;
private
LocalDateTime
updateTime
;
private
Integer
deleteTag
;
}
community-api/src/main/java/com/tanpu/community/api/beans/qo/MainTextQo.java
View file @
12c3a20d
...
@@ -2,12 +2,24 @@ package com.tanpu.community.api.beans.qo;
...
@@ -2,12 +2,24 @@ package com.tanpu.community.api.beans.qo;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 正文
* 正文
*/
*/
@Data
public
class
MainTextQo
{
public
class
MainTextQo
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"id"
)
private
String
id
;
@ApiModelProperty
(
value
=
"标题"
)
@ApiModelProperty
(
value
=
"标题"
)
private
String
title
;
private
String
title
;
...
@@ -39,4 +51,23 @@ public class MainTextQo {
...
@@ -39,4 +51,23 @@ public class MainTextQo {
private
String
formerThemeId
;
private
String
formerThemeId
;
@ApiModelProperty
(
value
=
"转发量"
)
private
Long
forwardAomunt
;
@ApiModelProperty
(
value
=
"评论量"
)
private
Long
commentAmount
;
@ApiModelProperty
(
value
=
"点赞量"
)
private
Long
likeAmount
;
@ApiModelProperty
(
"附件,key是类型,1:产品 2:直播 3:短视频 4:课程"
)
private
Map
<
String
,
Object
>
attachment
;
@ApiModelProperty
(
value
=
"评论"
)
private
List
<
CommentQo
>
comments
;
private
LocalDateTime
createTime
;
private
LocalDateTime
updateTime
;
}
}
community-api/src/main/java/com/tanpu/community/api/beans/req/CreateThemeReq.java
View file @
12c3a20d
...
@@ -21,13 +21,13 @@ public class CreateThemeReq {
...
@@ -21,13 +21,13 @@ public class CreateThemeReq {
@ApiModelProperty
(
value
=
"文本内容"
)
@ApiModelProperty
(
value
=
"文本内容"
)
private
String
content
;
private
String
content
;
@ApiModelProperty
(
value
=
"所属的话题"
)
@ApiModelProperty
(
value
=
"所属的话题
id
"
)
private
String
topicId
;
private
String
topicId
;
@ApiModelProperty
(
value
=
"被转发的主题"
)
@ApiModelProperty
(
value
=
"被转发的主题
,不是转发则为空
"
)
private
String
formerThemeId
;
private
String
formerThemeId
;
@ApiModelProperty
(
"附件"
)
@ApiModelProperty
(
"附件
,key是类型:1:产品 2:直播 3:短视频 4:课程,value是对应id,(注:course需要用逗号拼接‘courseId,package_id’)
"
)
private
Map
<
String
,
String
>
attachment
;
private
Map
<
String
,
String
>
attachment
;
}
}
community-service/src/main/java/com/tanpu/community/controller/HomePageController.java
View file @
12c3a20d
...
@@ -2,10 +2,10 @@ package com.tanpu.community.controller;
...
@@ -2,10 +2,10 @@ package com.tanpu.community.controller;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.req.HomePageReq
;
import
com.tanpu.community.api.beans.req.HomePageReq
;
import
com.tanpu.community.api.beans.req.homepage.AddIdolReq
;
import
com.tanpu.community.api.beans.req.homepage.AddIdolReq
;
import
com.tanpu.community.manager.HomePageManager
;
import
com.tanpu.community.manager.HomePageManager
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -26,7 +26,7 @@ public class HomePageController {
...
@@ -26,7 +26,7 @@ public class HomePageController {
private
HomePageManager
homePageManager
;
private
HomePageManager
homePageManager
;
@PostMapping
(
value
=
"/editUserInfo"
)
@PostMapping
(
value
=
"/editUserInfo"
)
@Api
ModelProperty
(
"编辑
个人资料"
)
@Api
Operation
(
"编辑圈子
个人资料"
)
@ResponseBody
@ResponseBody
public
CommonResp
<
String
>
editUserInfo
(
@Validated
@RequestBody
HomePageReq
req
){
public
CommonResp
<
String
>
editUserInfo
(
@Validated
@RequestBody
HomePageReq
req
){
String
userId
=
"liujm"
;
String
userId
=
"liujm"
;
...
@@ -35,7 +35,7 @@ public class HomePageController {
...
@@ -35,7 +35,7 @@ public class HomePageController {
}
}
@GetMapping
(
value
=
"/queryMyFans"
)
@GetMapping
(
value
=
"/queryMyFans"
)
@ApiOperation
(
"查询自己的粉丝"
)
@ApiOperation
(
"查询自己的粉丝
列表
"
)
@ResponseBody
@ResponseBody
public
CommonResp
<
List
<
FollowQo
>>
queryMyFans
()
{
public
CommonResp
<
List
<
FollowQo
>>
queryMyFans
()
{
String
userId
=
"123"
;
String
userId
=
"123"
;
...
@@ -45,7 +45,7 @@ public class HomePageController {
...
@@ -45,7 +45,7 @@ public class HomePageController {
}
}
@GetMapping
(
value
=
"/queryFansByUserId"
)
@GetMapping
(
value
=
"/queryFansByUserId"
)
@ApiOperation
(
"查询他人的粉丝"
)
@ApiOperation
(
"查询他人的粉丝
列表
"
)
@ResponseBody
@ResponseBody
public
CommonResp
<
List
<
FollowQo
>>
queryFans
(
@RequestParam
String
targetUser
)
{
public
CommonResp
<
List
<
FollowQo
>>
queryFans
(
@RequestParam
String
targetUser
)
{
String
userId
=
"123"
;
String
userId
=
"123"
;
...
@@ -55,7 +55,7 @@ public class HomePageController {
...
@@ -55,7 +55,7 @@ public class HomePageController {
}
}
@GetMapping
(
value
=
"/queryMyIdols"
)
@GetMapping
(
value
=
"/queryMyIdols"
)
@ApiOperation
(
"
查询自己的关注
"
)
@ApiOperation
(
"
获取自己的关注列表
"
)
@ResponseBody
@ResponseBody
public
CommonResp
<
List
<
FollowQo
>>
queryMyIdols
()
{
public
CommonResp
<
List
<
FollowQo
>>
queryMyIdols
()
{
String
userId
=
"123"
;
String
userId
=
"123"
;
...
@@ -66,9 +66,9 @@ public class HomePageController {
...
@@ -66,9 +66,9 @@ public class HomePageController {
@GetMapping
(
value
=
"/queryIdolsByUserId"
)
@GetMapping
(
value
=
"/queryIdolsByUserId"
)
@ApiOperation
(
"
查询他人的关注
"
)
@ApiOperation
(
"
获取他人的关注列表
"
)
@ResponseBody
@ResponseBody
public
CommonResp
queryIdols
(
@RequestParam
String
targetUser
)
{
public
CommonResp
<
List
<
FollowQo
>>
queryIdols
(
@RequestParam
String
targetUser
)
{
String
userId
=
"123"
;
String
userId
=
"123"
;
List
<
FollowQo
>
data
=
homePageManager
.
queryIdolsByFollowerId
(
targetUser
);
List
<
FollowQo
>
data
=
homePageManager
.
queryIdolsByFollowerId
(
targetUser
);
homePageManager
.
judgeFollowed
(
data
,
userId
);
homePageManager
.
judgeFollowed
(
data
,
userId
);
...
@@ -85,9 +85,9 @@ public class HomePageController {
...
@@ -85,9 +85,9 @@ public class HomePageController {
}
}
@PostMapping
(
value
=
"/query/queryMyLike"
)
@PostMapping
(
value
=
"/query/queryMyLike"
)
@ApiOperation
(
"我的点赞"
)
@ApiOperation
(
"我的点赞
帖子列表
"
)
@ResponseBody
@ResponseBody
public
CommonResp
likeList
(){
public
CommonResp
<
List
<
ThemeQo
>>
likeList
(){
String
userId
=
"123"
;
String
userId
=
"123"
;
return
CommonResp
.
success
();
return
CommonResp
.
success
();
}
}
...
...
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
12c3a20d
...
@@ -15,9 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -15,9 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RestController
@Slf4j
@Slf4j
...
@@ -33,14 +31,14 @@ public class ThemeController {
...
@@ -33,14 +31,14 @@ public class ThemeController {
@ApiOperation
(
"发表主题"
)
@ApiOperation
(
"发表主题"
)
@PostMapping
(
value
=
"/publish"
)
@PostMapping
(
value
=
"/publish"
)
@ResponseBody
@ResponseBody
public
CommonResp
publishTheme
(
@RequestBody
CreateThemeReq
req
)
{
public
CommonResp
<
Void
>
publishTheme
(
@RequestBody
CreateThemeReq
req
)
{
String
userId
=
"liujm"
;
String
userId
=
"liujm"
;
themeManager
.
publishTheme
(
req
,
userId
);
themeManager
.
publishTheme
(
req
,
userId
);
return
CommonResp
.
success
();
return
CommonResp
.
success
();
}
}
@ApiOperation
(
"圈子首页-推荐"
)
@ApiOperation
(
"圈子首页-推荐"
)
@
RequestMapping
(
value
=
"/recmend_list"
)
@
GetMapping
(
value
=
"/recmend_list"
)
@ResponseBody
@ResponseBody
public
List
<
ThemeQo
>
selectHotList
()
{
public
List
<
ThemeQo
>
selectHotList
()
{
String
userId
=
"liujm"
;
String
userId
=
"liujm"
;
...
@@ -48,7 +46,7 @@ public class ThemeController {
...
@@ -48,7 +46,7 @@ public class ThemeController {
}
}
@ApiOperation
(
"圈子首页-关注"
)
@ApiOperation
(
"圈子首页-关注"
)
@
Reques
tMapping
(
value
=
"/interest_list"
)
@
Ge
tMapping
(
value
=
"/interest_list"
)
@ResponseBody
@ResponseBody
public
List
<
ThemeQo
>
selectInterestList
()
{
public
List
<
ThemeQo
>
selectInterestList
()
{
String
userId
=
"liujm012"
;
String
userId
=
"liujm012"
;
...
@@ -56,25 +54,25 @@ public class ThemeController {
...
@@ -56,25 +54,25 @@ public class ThemeController {
}
}
@ApiOperation
(
"评论"
)
@ApiOperation
(
"评论"
)
@
Reque
stMapping
(
value
=
"/comment"
)
@
Po
stMapping
(
value
=
"/comment"
)
@ResponseBody
@ResponseBody
public
CommonResp
commetOnTheme
(
@RequestBody
CreateCommentReq
req
)
{
public
CommonResp
<
Void
>
commetOnTheme
(
@RequestBody
CreateCommentReq
req
)
{
String
userId
=
"liujm"
;
String
userId
=
"liujm"
;
themeManager
.
comment
(
req
,
userId
);
themeManager
.
comment
(
req
,
userId
);
return
CommonResp
.
success
();
return
CommonResp
.
success
();
}
}
@ApiOperation
(
"主题正文"
)
@ApiOperation
(
"主题正文"
)
@
Reques
tMapping
(
value
=
"/main_text"
)
@
Ge
tMapping
(
value
=
"/main_text"
)
@ResponseBody
@ResponseBody
public
CommonResp
getThemeMainText
(
@RequestParam
String
topicId
)
{
public
CommonResp
<
MainTextQo
>
getThemeMainText
(
@RequestParam
String
topicId
)
{
String
userId
=
"liujm"
;
String
userId
=
"liujm"
;
MainTextQo
mainTextQo
=
themeManager
.
getMainText
(
topicId
);
MainTextQo
mainTextQo
=
themeManager
.
getMainText
(
topicId
,
userId
);
return
CommonResp
.
success
(
mainTextQo
);
return
CommonResp
.
success
(
mainTextQo
);
}
}
@ApiOperation
(
"转发主题"
)
@ApiOperation
(
"转发主题"
)
@
Reque
stMapping
(
value
=
"/forward"
)
@
Po
stMapping
(
value
=
"/forward"
)
@ResponseBody
@ResponseBody
public
CommonResp
forwardTheme
(
@Validated
@RequestBody
ForwardThemeReq
forwardThemeReq
)
{
public
CommonResp
forwardTheme
(
@Validated
@RequestBody
ForwardThemeReq
forwardThemeReq
)
{
String
userId
=
"liujm"
;
String
userId
=
"liujm"
;
...
@@ -100,7 +98,7 @@ public class ThemeController {
...
@@ -100,7 +98,7 @@ public class ThemeController {
}
}
@ApiOperation
(
"收藏主题"
)
@ApiOperation
(
"收藏主题"
)
@
Reques
tMapping
(
value
=
"/book"
)
@
Ge
tMapping
(
value
=
"/book"
)
@ResponseBody
@ResponseBody
public
CommonResp
bookTheme
(
String
themeId
)
{
public
CommonResp
bookTheme
(
String
themeId
)
{
String
user
=
"liujm"
;
String
user
=
"liujm"
;
...
@@ -117,7 +115,7 @@ public class ThemeController {
...
@@ -117,7 +115,7 @@ public class ThemeController {
}
}
@ApiOperation
(
"屏蔽"
)
@ApiOperation
(
"屏蔽"
)
@
Reques
tMapping
(
value
=
"/conceal"
)
@
Ge
tMapping
(
value
=
"/conceal"
)
@ResponseBody
@ResponseBody
public
CommonResp
concealTheme
(
String
themeId
)
{
public
CommonResp
concealTheme
(
String
themeId
)
{
String
user
=
"liujm"
;
String
user
=
"liujm"
;
...
@@ -125,11 +123,4 @@ public class ThemeController {
...
@@ -125,11 +123,4 @@ public class ThemeController {
return
CommonResp
.
success
();
return
CommonResp
.
success
();
}
}
@GetMapping
(
value
=
"/text"
)
@ResponseBody
public
Map
<
String
,
String
>
test
(
@RequestParam
String
themeId
)
{
HashMap
<
String
,
String
>
result
=
new
HashMap
<>();
result
.
put
(
"k"
,
"v"
);
return
result
;
}
}
}
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
12c3a20d
...
@@ -3,6 +3,7 @@ package com.tanpu.community.manager;
...
@@ -3,6 +3,7 @@ package com.tanpu.community.manager;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.community.api.beans.ForwardThemeReq
;
import
com.tanpu.community.api.beans.ForwardThemeReq
;
import
com.tanpu.community.api.beans.qo.CommentQo
;
import
com.tanpu.community.api.beans.qo.MainTextQo
;
import
com.tanpu.community.api.beans.qo.MainTextQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.req.CreateCommentReq
;
import
com.tanpu.community.api.beans.req.CreateCommentReq
;
...
@@ -112,20 +113,17 @@ public class ThemeManager {
...
@@ -112,20 +113,17 @@ public class ThemeManager {
return
themeQos
;
return
themeQos
;
}
}
//计算迄今时间
//返回正文
private
String
calUpToNowTime
(
LocalDateTime
start
)
{
public
MainTextQo
getMainText
(
String
themeId
,
String
userId
)
{
Duration
between
=
Duration
.
between
(
start
,
LocalDateTime
.
now
());
long
duration
=
between
.
toMinutes
();
ThemeEntity
themeEntity
=
themeService
.
selectById
(
themeId
);
if
(
duration
<
1
)
{
if
(
themeEntity
==
null
)
{
return
"刚刚"
;
throw
new
BizException
(
"找不到帖子id:"
+
themeId
);
}
else
if
(
duration
<
60
)
{
return
duration
+
"分钟前"
;
}
else
if
(
duration
<
60
*
24
)
{
return
duration
/
60
+
"小时前"
;
}
else
if
(
start
.
getYear
()
==
LocalDateTime
.
now
().
getYear
())
{
return
start
.
format
(
DateTimeFormatter
.
ofPattern
(
"MM-dd HH:mm:ss"
));
}
}
return
start
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
));
MainTextQo
mainTextQo
=
new
MainTextQo
();
BeanUtils
.
copyProperties
(
themeEntity
,
mainTextQo
);
buildMainTestExtraInfo
(
mainTextQo
,
userId
);
return
mainTextQo
;
}
}
// 点赞
// 点赞
...
@@ -171,7 +169,7 @@ public class ThemeManager {
...
@@ -171,7 +169,7 @@ public class ThemeManager {
}
}
public
void
unFavorite
(
String
themeId
,
String
userId
)
{
public
void
unFavorite
(
String
themeId
,
String
userId
)
{
collectionService
.
delete
(
themeId
,
userId
,
CollectionTypeEnum
.
BOOK
);
}
}
//投诉(主题)
//投诉(主题)
...
@@ -189,6 +187,7 @@ public class ThemeManager {
...
@@ -189,6 +187,7 @@ public class ThemeManager {
// 解除屏蔽(用户)
// 解除屏蔽(用户)
public
void
unblockUser
(
String
blockUser
,
String
userId
)
{
public
void
unblockUser
(
String
blockUser
,
String
userId
)
{
//todo
}
}
// 屏蔽(主题)
// 屏蔽(主题)
...
@@ -210,11 +209,19 @@ public class ThemeManager {
...
@@ -210,11 +209,19 @@ public class ThemeManager {
private
List
<
ThemeQo
>
convertEntityToQo
(
List
<
ThemeEntity
>
themeEntities
,
String
userId
)
{
private
List
<
ThemeQo
>
convertEntityToQo
(
List
<
ThemeEntity
>
themeEntities
,
String
userId
)
{
List
<
ThemeQo
>
themeQos
=
ConvertUtil
.
themeEntitiesToDTOs
(
themeEntities
);
List
<
ThemeQo
>
themeQos
=
ConvertUtil
.
themeEntitiesToDTOs
(
themeEntities
);
for
(
ThemeQo
themeQO
:
themeQos
)
{
for
(
ThemeQo
themeQO
:
themeQos
)
{
buildThemeQoExtraInfo
(
userId
,
themeQO
);
}
return
themeQos
;
}
//组装主题列表
private
void
buildThemeQoExtraInfo
(
String
userId
,
ThemeQo
themeQO
)
{
//附件列表
//附件列表
List
<
ThemeAttachmentEntity
>
attachments
=
themeAttachmentService
.
selectByThemeId
(
themeQO
.
getId
());
List
<
ThemeAttachmentEntity
>
attachments
=
themeAttachmentService
.
selectByThemeId
(
themeQO
.
getId
());
if
(!
CollectionUtils
.
isEmpty
(
attachments
))
{
if
(!
CollectionUtils
.
isEmpty
(
attachments
))
{
HashMap
<
String
,
Object
>
attachmentQos
=
new
HashMap
<>();
HashMap
<
String
,
Object
>
attachmentQos
=
new
HashMap
<>();
attachments
.
forEach
(
o
->
attachmentQos
.
put
(
o
.
getAttchId
(),
transferAttachment
(
o
,
userId
)));
attachments
.
forEach
(
o
->
attachmentQos
.
put
(
o
.
getAttchId
(),
transferAttachment
(
o
,
userId
)));
themeQO
.
setAttachment
(
attachmentQos
);
themeQO
.
setAttachment
(
attachmentQos
);
}
}
//迄今时间
//迄今时间
...
@@ -227,10 +234,27 @@ public class ThemeManager {
...
@@ -227,10 +234,27 @@ public class ThemeManager {
HomePageEntity
userEntity
=
homePageService
.
selectByUserId
(
userId
);
HomePageEntity
userEntity
=
homePageService
.
selectByUserId
(
userId
);
themeQO
.
setUserImg
(
userEntity
.
getHeadImg
());
themeQO
.
setUserImg
(
userEntity
.
getHeadImg
());
themeQO
.
setNickName
(
userEntity
.
getNickName
());
themeQO
.
setNickName
(
userEntity
.
getNickName
());
}
//组装正文详情
private
void
buildMainTestExtraInfo
(
MainTextQo
maintTextQo
,
String
userId
)
{
//附件列表
List
<
ThemeAttachmentEntity
>
attachments
=
themeAttachmentService
.
selectByThemeId
(
maintTextQo
.
getId
());
if
(!
CollectionUtils
.
isEmpty
(
attachments
))
{
HashMap
<
String
,
Object
>
attachmentQos
=
new
HashMap
<>();
attachments
.
forEach
(
o
->
attachmentQos
.
put
(
o
.
getAttchId
(),
transferAttachment
(
o
,
userId
)));
maintTextQo
.
setAttachment
(
attachmentQos
);
}
}
return
themeQos
;
//迄今时间
maintTextQo
.
setUpToNowTime
(
calUpToNowTime
(
maintTextQo
.
getCreateTime
()));
//用户信息:头像、昵称
HomePageEntity
userEntity
=
homePageService
.
selectByUserId
(
userId
);
maintTextQo
.
setUserImg
(
userEntity
.
getHeadImg
());
maintTextQo
.
setNickName
(
userEntity
.
getNickName
());
//评论
List
<
CommentQo
>
commentQos
=
ConvertUtil
.
commentEntity2Qos
(
commentService
.
selectByTargetId
(
maintTextQo
.
getId
()));
maintTextQo
.
setComments
(
commentQos
);
return
;
}
}
...
@@ -280,7 +304,20 @@ public class ThemeManager {
...
@@ -280,7 +304,20 @@ public class ThemeManager {
}
}
public
MainTextQo
getMainText
(
String
topicId
)
{
//计算迄今时间
return
null
;
private
String
calUpToNowTime
(
LocalDateTime
start
)
{
Duration
between
=
Duration
.
between
(
start
,
LocalDateTime
.
now
());
long
duration
=
between
.
toMinutes
();
if
(
duration
<
1
)
{
return
"刚刚"
;
}
else
if
(
duration
<
60
)
{
return
duration
+
"分钟前"
;
}
else
if
(
duration
<
60
*
24
)
{
return
duration
/
60
+
"小时前"
;
}
else
if
(
start
.
getYear
()
==
LocalDateTime
.
now
().
getYear
())
{
return
start
.
format
(
DateTimeFormatter
.
ofPattern
(
"MM-dd HH:mm:ss"
));
}
}
return
start
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
));
}
}
}
community-service/src/main/java/com/tanpu/community/service/CollectionService.java
View file @
12c3a20d
...
@@ -87,7 +87,7 @@ public class CollectionService {
...
@@ -87,7 +87,7 @@ public class CollectionService {
.
size
();
.
size
();
}
}
//统多个主题的收藏量
//统
计
多个主题的收藏量
public
Long
getBookAmountByThemeIds
(
List
<
String
>
themeIds
)
{
public
Long
getBookAmountByThemeIds
(
List
<
String
>
themeIds
)
{
return
(
long
)
collectionMapper
.
selectList
((
new
LambdaQueryWrapper
<
CollectionEntity
>()
return
(
long
)
collectionMapper
.
selectList
((
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
in
(
CollectionEntity:
:
getTargetId
,
themeIds
)
.
in
(
CollectionEntity:
:
getTargetId
,
themeIds
)
...
@@ -96,4 +96,7 @@ public class CollectionService {
...
@@ -96,4 +96,7 @@ public class CollectionService {
.
size
();
.
size
();
}
}
public
void
delete
(
String
themeId
,
String
userId
,
CollectionTypeEnum
book
)
{
//TODO
}
}
}
community-service/src/main/java/com/tanpu/community/service/CommentService.java
View file @
12c3a20d
package
com
.
tanpu
.
community
.
service
;
package
com
.
tanpu
.
community
.
service
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.TopicStatusEnum
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.mapper.community.CommentMapper
;
import
com.tanpu.community.dao.mapper.community.CommentMapper
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -37,4 +39,13 @@ public class CommentService {
...
@@ -37,4 +39,13 @@ public class CommentService {
.
in
(
CommentEntity:
:
getTargetId
,
themeIds
)))
.
in
(
CommentEntity:
:
getTargetId
,
themeIds
)))
.
stream
().
map
(
CommentEntity:
:
getAuthorId
).
collect
(
Collectors
.
toSet
());
.
stream
().
map
(
CommentEntity:
:
getAuthorId
).
collect
(
Collectors
.
toSet
());
}
}
public
List
<
CommentEntity
>
selectByTargetId
(
String
id
)
{
return
commentMapper
.
selectList
(
new
LambdaQueryWrapper
<
CommentEntity
>()
.
eq
(
CommentEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
eq
(
CommentEntity:
:
getIsBlock
,
TopicStatusEnum
.
FALSE
.
getCode
())
.
orderByDesc
(
CommentEntity:
:
getCreateTime
));
}
}
}
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
12c3a20d
package
com
.
tanpu
.
community
.
util
;
package
com
.
tanpu
.
community
.
util
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.req.CreateThemeReq
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.TopicBriefInfoDTO
;
import
com.tanpu.community.api.beans.TopicBriefInfoDTO
;
import
com.tanpu.community.api.beans.TopicDTO
;
import
com.tanpu.community.api.beans.TopicDTO
;
import
com.tanpu.community.api.beans.qo.CommentQo
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.req.CreateThemeReq
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.dao.entity.community.HomePageEntity
;
import
com.tanpu.community.dao.entity.community.*
;
import
com.tanpu.community.dao.entity.community.ThemeAttachmentEntity
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -53,6 +51,15 @@ public class ConvertUtil {
...
@@ -53,6 +51,15 @@ public class ConvertUtil {
BeanUtils
.
copyProperties
(
topicEntity
,
topicBriefInfoDTO
);
BeanUtils
.
copyProperties
(
topicEntity
,
topicBriefInfoDTO
);
return
topicBriefInfoDTO
;
return
topicBriefInfoDTO
;
}
}
public
static
CommentQo
commentEntity2Qo
(
CommentEntity
entity
)
{
CommentQo
qo
=
new
CommentQo
();
BeanUtils
.
copyProperties
(
entity
,
qo
);
return
qo
;
}
public
static
List
<
CommentQo
>
commentEntity2Qos
(
List
<
CommentEntity
>
entities
){
return
entities
.
stream
().
map
(
ConvertUtil:
:
commentEntity2Qo
).
collect
(
Collectors
.
toList
());
}
public
static
List
<
TopicDTO
>
topicEntitiesToDTOs
(
List
<
TopicEntity
>
topicEntities
)
{
public
static
List
<
TopicDTO
>
topicEntitiesToDTOs
(
List
<
TopicEntity
>
topicEntities
)
{
return
topicEntities
.
stream
().
map
(
ConvertUtil:
:
topicEntityToDTO
).
collect
(
Collectors
.
toList
());
return
topicEntities
.
stream
().
map
(
ConvertUtil:
:
topicEntityToDTO
).
collect
(
Collectors
.
toList
());
...
@@ -62,6 +69,8 @@ public class ConvertUtil {
...
@@ -62,6 +69,8 @@ public class ConvertUtil {
return
topicEntities
.
stream
().
map
(
ConvertUtil:
:
topicToBriefInfoDTO
).
collect
(
Collectors
.
toList
());
return
topicEntities
.
stream
().
map
(
ConvertUtil:
:
topicToBriefInfoDTO
).
collect
(
Collectors
.
toList
());
}
}
public
static
DeleteTagEnum
deleteTagShift
(
DeleteTagEnum
deleteTagEnum
)
{
public
static
DeleteTagEnum
deleteTagShift
(
DeleteTagEnum
deleteTagEnum
)
{
if
(
deleteTagEnum
.
getCode
().
equals
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
{
if
(
deleteTagEnum
.
getCode
().
equals
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
{
return
DeleteTagEnum
.
DELETED
;
return
DeleteTagEnum
.
DELETED
;
...
...
community-service/src/main/resources/application-dev.yml
View file @
12c3a20d
...
@@ -9,32 +9,40 @@ apollo.bootstrap.enabled: true
...
@@ -9,32 +9,40 @@ apollo.bootstrap.enabled: true
# namespaces: application.yml
# namespaces: application.yml
server
:
server
:
port
:
8
080
port
:
8
345
servlet
:
servlet
:
context-path
:
/community
context-path
:
/community
spring.datasource
:
spring.datasource
:
community
:
community
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
driver-class-name
:
com.mysql.cj.jdbc.Driver
jdbc-url
:
jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&rewriteBatchedStatements=true
jdbc-url
:
jdbc:mysql://47.101.189.151:31931/tamp_community?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&rewriteBatchedStatements=true
username
:
tamp_admin
username
:
dev
password
:
'
@imeng123'
password
:
qimeng123
maxActive
:
2
minIdle
:
2
initialSize
:
2
course
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
jdbc-url
:
jdbc:mysql://47.101.189.151:31931/tamp_course?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&rewriteBatchedStatements=true
username
:
dev
password
:
qimeng123
maxActive
:
2
maxActive
:
2
minIdle
:
2
minIdle
:
2
initialSize
:
2
initialSize
:
2
user
:
user
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
driver-class-name
:
com.mysql.cj.jdbc.Driver
jdbc-url
:
jdbc:mysql://
rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306
/tamp_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&rewriteBatchedStatements=true
jdbc-url
:
jdbc:mysql://
47.101.189.151:31931
/tamp_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&rewriteBatchedStatements=true
username
:
tamp_admin
username
:
dev
password
:
'
@imeng123'
password
:
qimeng123
maxActive
:
2
maxActive
:
2
minIdle
:
2
minIdle
:
2
initialSize
:
2
initialSize
:
2
zhibo
:
zhibo
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
driver-class-name
:
com.mysql.cj.jdbc.Driver
jdbc-url
:
jdbc:mysql://
rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306
/tamp_zhibo?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&rewriteBatchedStatements=true
jdbc-url
:
jdbc:mysql://
47.101.189.151:31931
/tamp_zhibo?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&rewriteBatchedStatements=true
username
:
tamp_admin
username
:
dev
password
:
'
@imeng123'
password
:
qimeng123
maxActive
:
2
maxActive
:
2
minIdle
:
2
minIdle
:
2
initialSize
:
2
initialSize
:
2
...
...
community-service/src/main/resources/application.yml
View file @
12c3a20d
server
:
server
:
port
:
8
190
port
:
8
345
servlet
:
servlet
:
context-path
:
/community2
context-path
:
/community2
...
...
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