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
591c1ebe
Commit
591c1ebe
authored
Jul 26, 2021
by
吴泽佳
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://47.100.44.39:10001/tp-backend/tanpu-community
into dev
parents
5cf95841
c95a12cc
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
83 additions
and
52 deletions
+83
-52
CommentQo.java
...main/java/com/tanpu/community/api/beans/qo/CommentQo.java
+1
-1
RedisKeyConstant.java
...a/com/tanpu/community/api/constants/RedisKeyConstant.java
+1
-1
RedisCache.java
...e/src/main/java/com/tanpu/community/cache/RedisCache.java
+1
-4
TopicMapper.java
...com/tanpu/community/dao/mapper/community/TopicMapper.java
+6
-1
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+5
-4
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+1
-2
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+12
-10
TopicManager.java
...c/main/java/com/tanpu/community/manager/TopicManager.java
+7
-5
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+9
-7
FollowRelService.java
...in/java/com/tanpu/community/service/FollowRelService.java
+2
-1
RankService.java
...rc/main/java/com/tanpu/community/service/RankService.java
+9
-4
RecommendService.java
...in/java/com/tanpu/community/service/RecommendService.java
+9
-7
TopicService.java
...c/main/java/com/tanpu/community/service/TopicService.java
+13
-3
VisitSummaryService.java
...java/com/tanpu/community/service/VisitSummaryService.java
+6
-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/CommentQo.java
View file @
591c1ebe
...
...
@@ -41,7 +41,7 @@ public class CommentQo {
@ApiModelProperty
(
value
=
"2级评论"
)
private
List
<
CommentLv2Qo
>
commentLv2Qos
;
//认证标签相关
//
认证标签相关
@ApiModelProperty
(
"认证标签用-用户等级体系 0 游客 1注册用户 10投资人 20 探普理顾 30 探普专家理顾 40 交易理财师 50 首席投顾"
)
private
Integer
levelGrade
;
@ApiModelProperty
(
"认证标签用-当levelGrade=10有值 1投资萌新 2投资达人"
)
...
...
community-api/src/main/java/com/tanpu/community/api/constants/RedisKeyConstant.java
View file @
591c1ebe
...
...
@@ -30,7 +30,7 @@ public class RedisKeyConstant {
public
static
final
String
THEME_APPEAR_IN_SEARCH_LIST
=
"THEME_APPEAR_IN_SEARCH_LIST_"
;
// feign 查询用户信息
public
static
final
String
CAC
G
E_FEIGN_USER_INFO
=
"CACHE_FEIGN_USER_INFO_"
;
public
static
final
String
CAC
H
E_FEIGN_USER_INFO
=
"CACHE_FEIGN_USER_INFO_"
;
// 主题下的评论
public
static
final
String
CACHE_COMMENT_THEMEID
=
"CACHE_COMMENT_THEMEID_"
;
// 评论本身
...
...
community-service/src/main/java/com/tanpu/community/cache/RedisCache.java
View file @
591c1ebe
package
com
.
tanpu
.
community
.
cache
;
import
com.alibaba.fastjson.JSON
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.tanpu.common.redis.RedisHelper
;
import
com.tanpu.common.redis.RedisKeyHelper
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.community.util.SpringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Component
;
import
java.time.Duration
;
import
java.util.List
;
import
java.util.function.Supplier
;
public
class
RedisCache
{
...
...
@@ -46,6 +42,7 @@ public class RedisCache {
}
public
void
evict
(
String
key
)
{
key
=
cacheName
+
":"
+
key
;
delete
(
key
);
}
...
...
community-service/src/main/java/com/tanpu/community/dao/mapper/community/TopicMapper.java
View file @
591c1ebe
...
...
@@ -2,6 +2,10 @@ package com.tanpu.community.dao.mapper.community;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
java.util.List
;
/**
* <p>
...
...
@@ -12,5 +16,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @since 2021-07-22
*/
public
interface
TopicMapper
extends
BaseMapper
<
TopicEntity
>
{
@Select
(
"select * from topic where id>#{startId} and delete_tag=0 order by id asc limit #{size}"
)
List
<
TopicEntity
>
selectGtIdPageable
(
@Param
(
"startId"
)
Long
startId
,
@Param
(
"size"
)
Integer
size
);
}
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
591c1ebe
...
...
@@ -28,7 +28,7 @@ import java.util.List;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
static
com
.
tanpu
.
community
.
api
.
constants
.
RedisKeyConstant
.
CAC
G
E_FEIGN_USER_INFO
;
import
static
com
.
tanpu
.
community
.
api
.
constants
.
RedisKeyConstant
.
CAC
H
E_FEIGN_USER_INFO
;
@Service
public
class
CommentManager
{
...
...
@@ -63,9 +63,10 @@ public class CommentManager {
commentService
.
insertComment
(
commentEntity
);
}
//查询评论
//
查询评论
public
List
<
CommentQo
>
queryComments
(
String
themeId
,
String
userId
)
{
List
<
CommentEntity
>
commentEntities
=
commentService
.
selectByThemeIdAndParentId
(
themeId
,
null
);
// 因为需要排序,所以从库中查询所有评论
List
<
CommentEntity
>
commentEntities
=
commentService
.
selectByThemeId
(
themeId
);
List
<
CommentQo
>
commentQos
=
ConvertUtil
.
commentEntity2Qos
(
commentEntities
);
Set
<
String
>
likeCommentList
=
collectionService
.
getListByUser
(
userId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
...
...
@@ -73,7 +74,7 @@ public class CommentManager {
for
(
CommentQo
commentQo
:
commentQos
)
{
//查询用户信息
String
authorId
=
commentQo
.
getAuthorId
();
UserInfoNew
userInfo
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
CAC
G
E_FEIGN_USER_INFO
,
authorId
),
UserInfoNew
userInfo
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
CAC
H
E_FEIGN_USER_INFO
,
authorId
),
60
*
10
,
()
->
this
.
getUserInfo
(
authorId
)
,
UserInfoNew
.
class
);
if
(
userInfo
!=
null
)
{
commentQo
.
setUserImg
(
userInfo
.
getHeadImageUrl
());
...
...
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
591c1ebe
...
...
@@ -27,9 +27,7 @@ import com.tanpu.community.dao.mapper.jydb.MfInvestadvisoroutlineMapper;
import
com.tanpu.community.feign.course.FeignClientForCourse
;
import
com.tanpu.community.feign.diagnose.FeignClientForDiagnose
;
import
com.tanpu.community.feign.fatools.FeignClientForFatools
;
import
com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom
;
import
com.tanpu.community.service.FollowRelService
;
import
com.tanpu.community.service.UserInfoService
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.PageUtils
;
import
org.apache.commons.collections.CollectionUtils
;
...
...
@@ -181,6 +179,7 @@ public class HomePageManager {
//获取用户关注、粉丝列表
public
Page
<
FollowQo
>
queryFollow
(
QueryFollowReq
req
,
String
userId
)
{
//TODO 数据库分页
List
<
String
>
userIds
=
QueryFollowTypeEnum
.
QUERY_FANS
.
getCode
().
equals
(
req
.
getQueryType
())
?
followRelService
.
queryFansByIdolId
(
req
.
getUserId
())
:
followRelService
.
queryFansByFollowerId
(
req
.
getUserId
());
List
<
FollowQo
>
followQos
=
new
ArrayList
<>();
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
591c1ebe
...
...
@@ -154,7 +154,7 @@ public class ThemeManager {
return
CreateThemeResp
.
builder
().
themeId
(
themeEntity
.
getThemeId
()).
build
();
}
//转发主题
//
转发主题
public
CreateThemeResp
forward
(
ForwardThemeReq
req
,
String
userId
)
{
ThemeEntity
targetTheme
=
themeService
.
queryByThemeId
(
req
.
getFormerThemeId
());
ThemeEntity
themeEntity
=
ThemeEntity
.
builder
()
...
...
@@ -178,7 +178,7 @@ public class ThemeManager {
}
//查询主题列表:推荐/关注/热门/最新
//
查询主题列表:推荐/关注/热门/最新
public
List
<
ThemeQo
>
queryThemes
(
ThemeListReq
req
,
String
userId
)
{
List
<
ThemeEntity
>
themeEntities
=
new
ArrayList
<>();
if
(
ThemeListTypeEnum
.
RECOMMEND
.
getCode
().
equals
(
req
.
getType
()))
{
...
...
@@ -437,9 +437,9 @@ public class ThemeManager {
List
<
ThemeQo
>
commentThemeList
=
new
ArrayList
<>();
List
<
ThemeEntity
>
themeEntities
;
//评论列表
List
<
CommentEntity
>
commentEntities
=
commentService
.
query
Theme
sByUserId
(
req
.
getUserId
(),
req
.
getLastId
(),
req
.
getPageSize
());
List
<
CommentEntity
>
commentEntities
=
commentService
.
query
Comment
sByUserId
(
req
.
getUserId
(),
req
.
getLastId
(),
req
.
getPageSize
());
//当前用户信息
UserInfoNew
userInfo
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
CAC
G
E_FEIGN_USER_INFO
,
req
.
getUserId
()),
UserInfoNew
userInfo
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
CAC
H
E_FEIGN_USER_INFO
,
req
.
getUserId
()),
60
*
10
,
()
->
this
.
getUserInfo
(
req
.
getUserId
())
,
UserInfoNew
.
class
);
Set
<
String
>
replyThemeIds
=
commentEntities
.
stream
().
map
(
CommentEntity:
:
getThemeId
).
collect
(
Collectors
.
toSet
());
if
(
CollectionUtils
.
isEmpty
(
replyThemeIds
))
{
...
...
@@ -462,8 +462,7 @@ public class ThemeManager {
.
build
();
//原主题包装到FormerThemeQo中
ThemeQo
themeQo
=
themeMap
.
get
(
themeId
);
FormerThemeQo
f
=
ConvertUtil
.
themeQo2FormerThemeQo
(
themeQo
);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo
commentThemeQo
=
ThemeQo
.
builder
()
.
authorId
(
userInfo
.
getUserId
())
.
nickName
(
userInfo
.
getNickName
())
...
...
@@ -473,13 +472,16 @@ public class ThemeManager {
.
userInvestorType
(
userInfo
.
getUserInvestorType
())
.
belongUserOrgId
(
userInfo
.
getBelongUserOrgId
())
.
belongUserOrgName
(
userInfo
.
getBelongUserOrgName
())
.
content
(
Arrays
.
asList
(
commentContent
))
.
formerTheme
(
f
)
.
content
(
Collections
.
singletonList
(
commentContent
))
.
commentId
(
commentEntity
.
getCommentId
())
.
themeType
(
ThemeTypeEnum
.
RES_COMMENT
.
getCode
())
.
follow
(
followRelService
.
checkFollow
(
themeQo
.
getAuthorId
()
,
userId
))
.
follow
(
followRelService
.
checkFollow
(
userId
,
userId
))
.
build
();
//如果原文未被删除,组装数据到formerTheme中
if
(
themeQo
!=
null
){
FormerThemeQo
f
=
ConvertUtil
.
themeQo2FormerThemeQo
(
themeQo
);
themeQo
.
setFormerTheme
(
f
);
}
commentThemeList
.
add
(
commentThemeQo
);
}
return
commentThemeList
;
...
...
community-service/src/main/java/com/tanpu/community/manager/TopicManager.java
View file @
591c1ebe
...
...
@@ -28,7 +28,7 @@ public class TopicManager {
@Resource
private
UserHolder
userHolder
;
//新增话题
//
新增话题
public
void
insertTopic
(
String
topicTitle
,
String
userId
)
{
if
(
topicService
.
queryByTitile
(
topicTitle
)
==
null
)
{
throw
new
BizException
(
"话题名称已存在:"
+
topicTitle
);
...
...
@@ -37,18 +37,20 @@ public class TopicManager {
}
//首页-话题标签
//
首页-话题标签
public
List
<
TopicRankQo
>
getTop4TopicTitles
()
{
return
rankService
.
getRankTopicListTop4
();
}
//话题搜索列表
//
话题搜索列表
public
Page
<
TopicRankQo
>
getAllTopicBriefInfo
(
TopicSearchReq
req
)
{
return
PageUtils
.
page
(
req
.
getPage
(),
rankService
.
getRankTopicList
());
List
<
TopicRankQo
>
topicList
=
rankService
.
getRankTopicList
(
req
.
getSearchKeyword
());
return
PageUtils
.
page
(
req
.
getPage
(),
topicList
);
}
//话题详情页
//
话题详情页
public
TopicRankQo
getDetail
(
String
topicId
)
{
//话题详情
visitSummaryService
.
addPageView
(
userHolder
.
getUserId
(),
topicId
,
VisitTypeEnum
.
TOPIC_PAGE_VIEW
);
...
...
community-service/src/main/java/com/tanpu/community/service/CommentService.java
View file @
591c1ebe
...
...
@@ -3,7 +3,6 @@ package com.tanpu.community.service;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.redis.RedisKeyHelper
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.community.api.enums.CommentTypeEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
...
...
@@ -41,6 +40,8 @@ public class CommentService {
public
void
insertComment
(
CommentEntity
commentEntity
)
{
commentEntity
.
setCommentId
(
uuidGenHelper
.
getUuidStr
());
commentMapper
.
insert
(
commentEntity
);
//失效缓存
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CACHE_COMMENT_THEMEID
,
commentEntity
.
getThemeId
()));
}
...
...
@@ -72,8 +73,8 @@ public class CommentService {
.
stream
().
map
(
CommentEntity:
:
getAuthorId
).
collect
(
Collectors
.
toSet
());
}
public
List
<
CommentEntity
>
selectByThemeId
AndParentId
(
String
themeId
,
String
parent
Id
)
{
return
redisCache
.
getList
(
StringUtils
.
joinWith
(
"_"
,
CACHE_COMMENT_THEMEID
,
themeId
,
parentId
),
public
List
<
CommentEntity
>
selectByThemeId
(
String
theme
Id
)
{
return
redisCache
.
getList
(
StringUtils
.
joinWith
(
"_"
,
CACHE_COMMENT_THEMEID
,
themeId
),
60
,
()
->
{
LambdaQueryWrapper
<
CommentEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CommentEntity
>()
.
eq
(
CommentEntity:
:
getThemeId
,
themeId
)
...
...
@@ -84,7 +85,7 @@ public class CommentService {
}
public
List
<
CommentEntity
>
query
Theme
sByUserId
(
String
userId
)
{
public
List
<
CommentEntity
>
query
Comment
sByUserId
(
String
userId
)
{
return
commentMapper
.
selectList
(
new
LambdaQueryWrapper
<
CommentEntity
>()
.
eq
(
CommentEntity:
:
getAuthorId
,
userId
)
.
eq
(
CommentEntity:
:
getCommentType
,
CommentTypeEnum
.
THEME
.
getCode
())
...
...
@@ -92,15 +93,16 @@ public class CommentService {
}
public
List
<
CommentEntity
>
query
ThemesByUserId
(
String
userId
,
String
lastId
,
Integer
pageSize
)
{
public
List
<
CommentEntity
>
query
CommentsByUserId
(
String
userId
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
CommentEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CommentEntity
>()
.
eq
(
CommentEntity:
:
getAuthorId
,
userId
)
.
eq
(
CommentEntity:
:
getCommentType
,
CommentTypeEnum
.
THEME
.
getCode
())
.
eq
(
CommentEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
.
eq
(
CommentEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByDesc
(
CommentEntity:
:
getCreateTime
);
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
CommentEntity
commentEntity
=
commentMapper
.
selectOne
(
new
LambdaQueryWrapper
<
CommentEntity
>()
.
eq
(
CommentEntity:
:
getCommentId
,
lastId
));
if
(
commentEntity
==
null
)
throw
new
BizException
(
"
主题
未找到,id:"
+
lastId
);
if
(
commentEntity
==
null
)
throw
new
BizException
(
"
评论
未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
CommentEntity:
:
getUpdateTime
,
commentEntity
.
getCreateTime
());
}
if
(
pageSize
!=
null
){
...
...
community-service/src/main/java/com/tanpu/community/service/FollowRelService.java
View file @
591c1ebe
...
...
@@ -82,7 +82,8 @@ public class FollowRelService {
public
boolean
checkFollow
(
String
idolId
,
String
followerId
){
return
followRelMapper
.
selectCount
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getFollowUserId
,
idolId
)
.
eq
(
FollowRelEntity:
:
getFollowerId
,
followerId
))
.
eq
(
FollowRelEntity:
:
getFollowerId
,
followerId
)
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
>
0
;
}
...
...
community-service/src/main/java/com/tanpu/community/service/RankService.java
View file @
591c1ebe
...
...
@@ -21,7 +21,7 @@ import javax.annotation.Resource;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
com
.
tanpu
.
community
.
api
.
constants
.
RedisKeyConstant
.
CAC
G
E_FEIGN_USER_INFO
;
import
static
com
.
tanpu
.
community
.
api
.
constants
.
RedisKeyConstant
.
CAC
H
E_FEIGN_USER_INFO
;
@Service
public
class
RankService
{
...
...
@@ -71,7 +71,7 @@ public class RankService {
theme
.
setViewCount
(
viewCount
);
//查询用户质量
String
authorId
=
theme
.
getAuthorId
();
UserInfoNew
authorInfo
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
CAC
G
E_FEIGN_USER_INFO
,
authorId
),
UserInfoNew
authorInfo
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
CAC
H
E_FEIGN_USER_INFO
,
authorId
),
60
*
10
,
()
->
this
.
getUserInfo
(
authorId
),
UserInfoNew
.
class
);
if
(
authorInfo
==
null
||
authorInfo
.
getLevelGrade
()
==
null
)
{
theme
.
setUserWeight
(
0.0
);
...
...
@@ -166,11 +166,16 @@ public class RankService {
}
public
List
<
TopicRankQo
>
getRankTopicList
()
{
public
List
<
TopicRankQo
>
getRankTopicList
(
String
keyword
)
{
if
(
this
.
rankTopicList
.
size
()
==
0
)
{
this
.
rankTopics
();
}
if
(
StringUtils
.
isEmpty
(
keyword
)){
return
rankTopicList
;
}
else
{
//过滤关键字
return
this
.
rankTopicList
.
stream
().
filter
(
o
->
o
.
getTopicTitle
().
contains
(
keyword
)).
collect
(
Collectors
.
toList
());
}
}
public
List
<
TopicRankQo
>
getRankTopicListTop4
()
{
...
...
community-service/src/main/java/com/tanpu/community/service/RecommendService.java
View file @
591c1ebe
...
...
@@ -66,18 +66,20 @@ public class RecommendService {
List
<
String
>
recThemeIds
=
getPythonRecommendList
(
userId
);
//混合
Set
<
String
>
returnedIds
=
(
StringUtils
.
isEmpty
(
lastId
))
?
new
HashSet
<>()
:
returnedIdsMap
.
get
(
userId
);
Set
<
String
>
returnedIds
=
(
StringUtils
.
isEmpty
(
lastId
))
||
!
returnedIdsMap
.
containsKey
(
userId
)
||
returnedIdsMap
.
get
(
userId
)
==
null
?
new
HashSet
<>()
:
returnedIdsMap
.
get
(
userId
);
List
<
String
>
result
=
new
ArrayList
<>();
getResultList
(
hotThemeIds
,
0
,
newThemeIds
,
0
,
recThemeIds
,
0
,
returnedIds
,
result
,
pageSize
,
userId
);
getResultList
(
hotThemeIds
,
0
,
newThemeIds
,
0
,
recThemeIds
,
0
,
returnedIds
,
result
,
pageSize
,
userId
);
result
=
result
.
stream
().
limit
(
pageSize
).
collect
(
Collectors
.
toList
());
//记录已返回主题id
if
(
StringUtils
.
isEmpty
(
lastId
))
{
returnedIdsMap
.
put
(
userId
,
new
HashSet
<>(
result
));
}
else
{
if
(
StringUtils
.
isEmpty
(
lastId
))
{
returnedIdsMap
.
put
(
userId
,
new
HashSet
<>(
result
));
}
else
{
HashSet
<
String
>
newSet
=
new
HashSet
<>();
newSet
.
addAll
(
returnedIdsMap
.
get
(
userId
));
newSet
.
addAll
(
result
);
returnedIdsMap
.
put
(
userId
,
newSet
);
returnedIdsMap
.
put
(
userId
,
newSet
);
}
return
result
;
}
...
...
@@ -168,7 +170,7 @@ public class RecommendService {
}
//去重已看过(查看正文)
result
=
visitSummaryService
.
filterUserNotVisited
(
userId
,
result
);
result
=
visitSummaryService
.
filterUserNotVisited
(
userId
,
result
);
if
(
result
.
size
()
<
pageSize
)
{
getResultList
(
hotThemeIds
,
hotTag
,
newThemeIds
,
newTag
,
recThemeIds
,
recTag
,
returnedIds
,
result
,
pageSize
,
userId
);
...
...
community-service/src/main/java/com/tanpu/community/service/TopicService.java
View file @
591c1ebe
...
...
@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -29,9 +30,18 @@ public class TopicService {
private
UuidGenHelper
uuidGenHelper
;
public
List
<
TopicEntity
>
queryAll
()
{
return
topicMapper
.
selectList
(
new
LambdaQueryWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByDesc
(
TopicEntity:
:
getCreateTime
));
List
<
TopicEntity
>
retList
=
new
ArrayList
<>();
Long
lastId
=
0L
;
while
(
true
)
{
List
<
TopicEntity
>
tmpList
=
topicMapper
.
selectGtIdPageable
(
lastId
,
100
);
if
(
tmpList
.
isEmpty
())
{
break
;
}
retList
.
addAll
(
tmpList
);
lastId
=
tmpList
.
stream
().
map
(
TopicEntity:
:
getId
).
max
(
Long:
:
compareTo
).
get
();
}
return
retList
;
}
public
List
<
TopicEntity
>
queryByKeyword
(
String
keyword
)
{
...
...
community-service/src/main/java/com/tanpu/community/service/VisitSummaryService.java
View file @
591c1ebe
package
com
.
tanpu
.
community
.
service
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.tanpu.community.api.enums.VisitTypeEnum
;
import
com.tanpu.community.dao.entity.community.VisitSummaryEntity
;
import
com.tanpu.community.dao.mapper.community.VisitSummaryMapper
;
...
...
@@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
...
...
@@ -26,7 +28,10 @@ public class VisitSummaryService {
if
(
refIds
.
isEmpty
())
{
return
refIds
;
}
List
<
String
>
visited
=
visitSummaryMapper
.
selectRefIdByUserId
(
userId
,
StringUtils
.
joinWith
(
","
,
refIds
));
List
<
String
>
visited
=
visitSummaryMapper
.
selectList
(
new
LambdaQueryWrapper
<
VisitSummaryEntity
>()
.
eq
(
VisitSummaryEntity:
:
getVisitorId
,
userId
)
.
in
(
VisitSummaryEntity:
:
getRefId
,
refIds
))
.
stream
().
map
(
VisitSummaryEntity:
:
getRefId
).
distinct
().
collect
(
Collectors
.
toList
());
return
ListUtils
.
subtract
(
refIds
,
visited
);
}
...
...
community-service/src/main/resources/application-dev.yml
View file @
591c1ebe
...
...
@@ -110,5 +110,5 @@ recommend:
new
:
2
python
:
1
python
:
enable
:
tru
e
enable
:
fals
e
url
:
http://172.168.0.164:9000/api/get_recommend?user_id=2431614397151511
\ No newline at end of file
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