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
28642621
Commit
28642621
authored
Jun 18, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ConvertUtil
parent
8ef1fbcd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
26 deletions
+57
-26
TopicController.java
.../java/com/tanpu/community/controller/TopicController.java
+2
-2
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+4
-3
TopicManager.java
...c/main/java/com/tanpu/community/manager/TopicManager.java
+3
-2
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+46
-0
ThemeConvert.java
.../src/main/java/com/tanpu/community/util/ThemeConvert.java
+1
-11
TopicConverter.java
...rc/main/java/com/tanpu/community/util/TopicConverter.java
+1
-8
No files found.
community-service/src/main/java/com/tanpu/community/controller/TopicController.java
View file @
28642621
...
@@ -2,12 +2,12 @@ package com.tanpu.community.controller;
...
@@ -2,12 +2,12 @@ package com.tanpu.community.controller;
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.controller.convert.TopicConverter
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.manager.TopicManager
;
import
com.tanpu.community.manager.TopicManager
;
import
com.tanpu.community.model.req.topic.TopicConcealReq
;
import
com.tanpu.community.model.req.topic.TopicConcealReq
;
import
com.tanpu.community.model.req.topic.TopicModifyMountReq
;
import
com.tanpu.community.model.req.topic.TopicModifyMountReq
;
import
com.tanpu.community.model.req.topic.TopicTopReq
;
import
com.tanpu.community.model.req.topic.TopicTopReq
;
import
com.tanpu.community.util.ConvertUtil
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -40,7 +40,7 @@ public class TopicController {
...
@@ -40,7 +40,7 @@ public class TopicController {
@ResponseBody
@ResponseBody
public
List
<
TopicDTO
>
getAllTopicList
(){
public
List
<
TopicDTO
>
getAllTopicList
(){
List
<
TopicEntity
>
allTopic
=
topicManager
.
getAllTopic
();
List
<
TopicEntity
>
allTopic
=
topicManager
.
getAllTopic
();
List
<
TopicDTO
>
topicDTOS
=
TopicConverter
.
convert
ToDTOs
(
allTopic
);
List
<
TopicDTO
>
topicDTOS
=
ConvertUtil
.
topicEntities
ToDTOs
(
allTopic
);
//获取浏览数据:浏览、发帖、回帖
//获取浏览数据:浏览、发帖、回帖
return
topicDTOS
;
return
topicDTOS
;
}
}
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
28642621
...
@@ -4,7 +4,8 @@ import com.tanpu.community.api.beans.ThemeDTO;
...
@@ -4,7 +4,8 @@ import com.tanpu.community.api.beans.ThemeDTO;
import
com.tanpu.community.api.constants.BlockTypeEnum
;
import
com.tanpu.community.api.constants.BlockTypeEnum
;
import
com.tanpu.community.api.constants.CollectionTypeEnum
;
import
com.tanpu.community.api.constants.CollectionTypeEnum
;
import
com.tanpu.community.api.constants.CommentTypeEnum
;
import
com.tanpu.community.api.constants.CommentTypeEnum
;
import
com.tanpu.community.controller.convert.ThemeConvert
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.ThemeConvert
;
import
com.tanpu.community.dao.entity.community.BlackListEntity
;
import
com.tanpu.community.dao.entity.community.BlackListEntity
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.community.FansRelEntity
;
import
com.tanpu.community.dao.entity.community.FansRelEntity
;
...
@@ -44,7 +45,7 @@ public class ThemeManager {
...
@@ -44,7 +45,7 @@ public class ThemeManager {
public
List
<
ThemeDTO
>
selectHotThemes
(){
public
List
<
ThemeDTO
>
selectHotThemes
(){
//TODO:根据算法计算推荐主题
//TODO:根据算法计算推荐主题
List
<
ThemeEntity
>
themeEntities
=
themeService
.
selectAll
();
List
<
ThemeEntity
>
themeEntities
=
themeService
.
selectAll
();
List
<
ThemeDTO
>
themeDTOS
=
ThemeConvert
.
convert
ToDTOs
(
themeEntities
);
List
<
ThemeDTO
>
themeDTOS
=
ConvertUtil
.
themeEntities
ToDTOs
(
themeEntities
);
for
(
ThemeDTO
themeDTO
:
themeDTOS
)
{
for
(
ThemeDTO
themeDTO
:
themeDTOS
)
{
themeDTO
.
setUpToNowTime
(
calUpToNowTime
(
themeDTO
.
getCreateTime
()));
themeDTO
.
setUpToNowTime
(
calUpToNowTime
(
themeDTO
.
getCreateTime
()));
...
@@ -57,7 +58,7 @@ public class ThemeManager {
...
@@ -57,7 +58,7 @@ public class ThemeManager {
public
List
<
ThemeDTO
>
selectInterestThemes
(
String
userId
){
public
List
<
ThemeDTO
>
selectInterestThemes
(
String
userId
){
List
<
String
>
fansList
=
fansRelService
.
queryFansByFollowerId
(
userId
).
stream
().
map
(
FansRelEntity:
:
getIdolId
).
collect
(
Collectors
.
toList
());
List
<
String
>
fansList
=
fansRelService
.
queryFansByFollowerId
(
userId
).
stream
().
map
(
FansRelEntity:
:
getIdolId
).
collect
(
Collectors
.
toList
());
List
<
ThemeEntity
>
themeEntities
=
themeService
.
selectByFans
(
fansList
);
List
<
ThemeEntity
>
themeEntities
=
themeService
.
selectByFans
(
fansList
);
List
<
ThemeDTO
>
themeDTOS
=
ThemeConvert
.
convert
ToDTOs
(
themeEntities
);
List
<
ThemeDTO
>
themeDTOS
=
ConvertUtil
.
themeEntities
ToDTOs
(
themeEntities
);
for
(
ThemeDTO
themeDTO
:
themeDTOS
)
{
for
(
ThemeDTO
themeDTO
:
themeDTOS
)
{
themeDTO
.
setUpToNowTime
(
calUpToNowTime
(
themeDTO
.
getCreateTime
()));
themeDTO
.
setUpToNowTime
(
calUpToNowTime
(
themeDTO
.
getCreateTime
()));
...
...
community-service/src/main/java/com/tanpu/community/manager/TopicManager.java
View file @
28642621
...
@@ -5,10 +5,10 @@ import com.tanpu.community.api.beans.TopicBriefInfoDTO;
...
@@ -5,10 +5,10 @@ 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.constants.RedisKeyConstant
;
import
com.tanpu.community.api.constants.RedisKeyConstant
;
import
com.tanpu.community.api.constants.TopicStatusEnum
;
import
com.tanpu.community.api.constants.TopicStatusEnum
;
import
com.tanpu.community.controller.convert.TopicConverter
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.service.*
;
import
com.tanpu.community.service.*
;
import
com.tanpu.community.util.ConvertUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -74,7 +74,7 @@ public class TopicManager {
...
@@ -74,7 +74,7 @@ public class TopicManager {
public
TopicDTO
getDetail
(
String
topicId
)
{
public
TopicDTO
getDetail
(
String
topicId
)
{
TopicEntity
topicEntity
=
topicService
.
queryById
(
topicId
);
TopicEntity
topicEntity
=
topicService
.
queryById
(
topicId
);
TopicDTO
topicDTO
=
TopicConverter
.
convert
ToDTO
(
topicEntity
);
TopicDTO
topicDTO
=
ConvertUtil
.
topicEntity
ToDTO
(
topicEntity
);
//TODO:添加实时数据(浏览量,点赞量,评论量,收藏量)
//TODO:添加实时数据(浏览量,点赞量,评论量,收藏量)
topicDTO
.
setViewAmount
(
redisService
.
getLong
(
RedisKeyConstant
.
TOPIC_VIEW_AMOUNT_
+
topicId
));
topicDTO
.
setViewAmount
(
redisService
.
getLong
(
RedisKeyConstant
.
TOPIC_VIEW_AMOUNT_
+
topicId
));
topicDTO
.
setLikeAmount
(
redisService
.
getLong
(
RedisKeyConstant
.
TOPIC_LIKE_AMOUNT_
+
topicId
));
topicDTO
.
setLikeAmount
(
redisService
.
getLong
(
RedisKeyConstant
.
TOPIC_LIKE_AMOUNT_
+
topicId
));
...
@@ -114,3 +114,4 @@ public class TopicManager {
...
@@ -114,3 +114,4 @@ public class TopicManager {
}
}
}
}
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
0 → 100644
View file @
28642621
package
com
.
tanpu
.
community
.
util
;
import
com.tanpu.community.api.beans.ThemeDTO
;
import
com.tanpu.community.api.beans.TopicDTO
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
org.springframework.beans.BeanUtils
;
import
java.util.List
;
import
java.util.stream.Collectors
;
public
class
ConvertUtil
{
public
static
ThemeDTO
themeEntityToDTO
(
ThemeEntity
themeEntity
){
ThemeDTO
themeDTO
=
new
ThemeDTO
();
BeanUtils
.
copyProperties
(
themeEntity
,
themeDTO
);
return
themeDTO
;
}
public
static
ThemeEntity
themeDTOToEntity
(
ThemeDTO
themeDTO
){
ThemeEntity
themeEntity
=
new
ThemeEntity
();
BeanUtils
.
copyProperties
(
themeDTO
,
themeEntity
);
return
themeEntity
;
}
public
static
List
<
ThemeDTO
>
themeEntitiesToDTOs
(
List
<
ThemeEntity
>
themeEntities
){
return
themeEntities
.
stream
().
map
(
ConvertUtil:
:
themeEntityToDTO
).
collect
(
Collectors
.
toList
());
}
public
static
List
<
ThemeEntity
>
themeDTOSToEntitys
(
List
<
ThemeDTO
>
themeDTOS
){
return
themeDTOS
.
stream
().
map
(
ConvertUtil:
:
themeDTOToEntity
).
collect
(
Collectors
.
toList
());
}
public
static
TopicDTO
topicEntityToDTO
(
TopicEntity
topicEntity
){
TopicDTO
topicDTO
=
new
TopicDTO
();
BeanUtils
.
copyProperties
(
topicEntity
,
topicDTO
);
return
topicDTO
;
}
public
static
List
<
TopicDTO
>
topicEntitiesToDTOs
(
List
<
TopicEntity
>
topicEntities
){
return
topicEntities
.
stream
().
map
(
ConvertUtil:
:
topicEntityToDTO
).
collect
(
Collectors
.
toList
());
}
}
community-service/src/main/java/com/tanpu/community/
controller/convert
/ThemeConvert.java
→
community-service/src/main/java/com/tanpu/community/
util
/ThemeConvert.java
View file @
28642621
package
com
.
tanpu
.
community
.
controller
.
convert
;
package
com
.
tanpu
.
community
.
util
;
import
com.tanpu.community.api.beans.ThemeDTO
;
import
com.tanpu.community.api.beans.ThemeDTO
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
java.util.List
;
import
java.util.stream.Collectors
;
public
class
ThemeConvert
{
public
class
ThemeConvert
{
public
static
ThemeDTO
convertToDTO
(
ThemeEntity
themeEntity
){
public
static
ThemeDTO
convertToDTO
(
ThemeEntity
themeEntity
){
ThemeDTO
themeDTO
=
new
ThemeDTO
();
ThemeDTO
themeDTO
=
new
ThemeDTO
();
...
@@ -45,11 +42,4 @@ public class ThemeConvert {
...
@@ -45,11 +42,4 @@ public class ThemeConvert {
return
themeEntity
;
return
themeEntity
;
}
}
public
static
List
<
ThemeDTO
>
convertToEntitys
(
List
<
ThemeEntity
>
topicEntities
){
return
topicEntities
.
stream
().
map
(
ThemeConvert:
:
convertToDTO
).
collect
(
Collectors
.
toList
());
}
public
static
List
<
ThemeDTO
>
convertToDTOs
(
List
<
ThemeEntity
>
topicEntities
){
return
topicEntities
.
stream
().
map
(
ThemeConvert:
:
convertToDTO
).
collect
(
Collectors
.
toList
());
}
}
}
community-service/src/main/java/com/tanpu/community/
controller/convert
/TopicConverter.java
→
community-service/src/main/java/com/tanpu/community/
util
/TopicConverter.java
View file @
28642621
package
com
.
tanpu
.
community
.
controller
.
convert
;
package
com
.
tanpu
.
community
.
util
;
import
com.tanpu.community.api.beans.TopicDTO
;
import
com.tanpu.community.api.beans.TopicDTO
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
java.util.List
;
import
java.util.stream.Collectors
;
public
class
TopicConverter
{
public
class
TopicConverter
{
...
@@ -22,8 +19,4 @@ public class TopicConverter {
...
@@ -22,8 +19,4 @@ public class TopicConverter {
topicDTO
.
setDeleteTag
(
topicEntity
.
getDeleteTag
());
topicDTO
.
setDeleteTag
(
topicEntity
.
getDeleteTag
());
return
topicDTO
;
return
topicDTO
;
}
}
public
static
List
<
TopicDTO
>
convertToDTOs
(
List
<
TopicEntity
>
topicEntities
){
return
topicEntities
.
stream
().
map
(
TopicConverter:
:
convertToDTO
).
collect
(
Collectors
.
toList
());
}
}
}
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