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
c6f57eff
Commit
c6f57eff
authored
Jul 29, 2021
by
张辰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove excludeIds
parent
a016a8f0
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
17 deletions
+33
-17
ThemeFullSearchReq.java
...pu/community/api/beans/req/search/ThemeFullSearchReq.java
+1
-1
ThemeListReq.java
...com/tanpu/community/api/beans/req/theme/ThemeListReq.java
+1
-1
ThemeFullSearchResp.java
...m/tanpu/community/api/beans/resp/ThemeFullSearchResp.java
+0
-2
ThemeListResp.java
...ava/com/tanpu/community/api/beans/resp/ThemeListResp.java
+0
-1
RedisCache.java
...e/src/main/java/com/tanpu/community/cache/RedisCache.java
+2
-2
SearchController.java
...java/com/tanpu/community/controller/SearchController.java
+1
-1
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+28
-9
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/req/search/ThemeFullSearchReq.java
View file @
c6f57eff
...
...
@@ -9,5 +9,5 @@ import java.util.List;
public
class
ThemeFullSearchReq
{
public
Pageable
page
;
public
String
keyword
;
public
List
<
String
>
excludeIds
;
public
String
ident
;
}
community-api/src/main/java/com/tanpu/community/api/beans/req/theme/ThemeListReq.java
View file @
c6f57eff
...
...
@@ -25,5 +25,5 @@ public class ThemeListReq {
@NotNull
(
message
=
"分页"
)
public
Pageable
page
;
public
List
<
String
>
excludeIds
;
public
String
ident
;
}
community-api/src/main/java/com/tanpu/community/api/beans/resp/ThemeFullSearchResp.java
View file @
c6f57eff
...
...
@@ -8,11 +8,9 @@ import java.util.List;
@Data
public
class
ThemeFullSearchResp
{
public
List
<
String
>
excludeIds
;
public
List
<
ThemeQo
>
themes
;
public
ThemeFullSearchResp
()
{
this
.
excludeIds
=
new
ArrayList
<>();
this
.
themes
=
new
ArrayList
<>();
}
}
community-api/src/main/java/com/tanpu/community/api/beans/resp/ThemeListResp.java
View file @
c6f57eff
...
...
@@ -8,5 +8,4 @@ import java.util.List;
@Data
public
class
ThemeListResp
{
public
List
<
ThemeQo
>
themes
;
public
List
<
String
>
excludeIds
;
}
community-service/src/main/java/com/tanpu/community/cache/RedisCache.java
View file @
c6f57eff
...
...
@@ -46,12 +46,12 @@ public class RedisCache {
delete
(
key
);
}
p
rivate
String
get
(
String
key
)
{
p
ublic
String
get
(
String
key
)
{
key
=
cacheName
+
":"
+
key
;
return
redisHelper
.
get
(
key
);
}
p
rivate
void
put
(
String
key
,
Object
obj
,
Integer
expireSeconds
)
{
p
ublic
void
put
(
String
key
,
Object
obj
,
Integer
expireSeconds
)
{
key
=
cacheName
+
":"
+
key
;
String
value
=
JsonUtil
.
toJson
(
obj
);
if
(
expireSeconds
==
0
)
{
...
...
community-service/src/main/java/com/tanpu/community/controller/SearchController.java
View file @
c6f57eff
...
...
@@ -32,7 +32,7 @@ public class SearchController {
@PostMapping
(
value
=
"/themeFullText"
)
@ResponseBody
public
CommonResp
<
ThemeFullSearchResp
>
themeFullText
(
@RequestBody
ThemeFullSearchReq
req
)
{
ThemeFullSearchResp
resp
=
themeManager
.
themeFullSearch
(
req
.
keyword
,
req
.
page
.
pageNumber
,
req
.
page
.
pageSize
,
req
.
excludeIds
,
userHolder
.
getUserId
());
ThemeFullSearchResp
resp
=
themeManager
.
themeFullSearch
(
req
.
keyword
,
req
.
page
.
pageNumber
,
req
.
page
.
pageSize
,
req
.
ident
,
userHolder
.
getUserId
());
return
CommonResp
.
success
(
resp
);
}
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
c6f57eff
package
com
.
tanpu
.
community
.
manager
;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.collect.Sets
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.exception.BizException
;
...
...
@@ -89,7 +90,15 @@ public class ThemeManager {
@Autowired
private
RecommendService
recommendService
;
public
ThemeFullSearchResp
themeFullSearch
(
String
keyword
,
Integer
pageNo
,
Integer
pageSize
,
List
<
String
>
excludeIds
,
String
userId
)
{
public
ThemeFullSearchResp
themeFullSearch
(
String
keyword
,
Integer
pageNo
,
Integer
pageSize
,
String
ident
,
String
userId
)
{
List
<
String
>
excludeIds
;
if
(
pageNo
>
1
)
{
String
l
=
redisCache
.
get
(
"themeFullSearch_"
+
ident
);
excludeIds
=
StringUtils
.
isBlank
(
l
)
?
new
ArrayList
<>()
:
JSON
.
parseArray
(
l
,
String
.
class
);
}
else
{
excludeIds
=
new
ArrayList
<>();
}
Integer
from
=
(
pageNo
-
1
)
*
pageSize
;
ThemeFullSearchResp
resp
=
new
ThemeFullSearchResp
();
...
...
@@ -115,7 +124,9 @@ public class ThemeManager {
for
(
ThemeQo
theme
:
resp
.
themes
)
{
theme
.
briefContent4FullSearch
=
BizUtils
.
getThemeContent
(
keyword
,
theme
);
}
resp
.
excludeIds
.
addAll
(
filterEsIds
);
excludeIds
.
addAll
(
resp
.
themes
.
stream
().
map
(
ThemeQo:
:
getThemeId
).
collect
(
Collectors
.
toList
()));
redisCache
.
put
(
"themeFullSearch_"
+
ident
,
JSON
.
toJSONString
(
excludeIds
),
60
*
60
*
6
);
return
resp
;
}
...
...
@@ -126,7 +137,6 @@ public class ThemeManager {
*/
@Transactional
public
CreateThemeResp
publishTheme
(
CreateThemeReq
req
,
String
userId
)
{
// 保存主题表
ThemeEntity
themeEntity
=
new
ThemeEntity
();
BeanUtils
.
copyProperties
(
req
,
themeEntity
);
...
...
@@ -193,6 +203,14 @@ public class ThemeManager {
*/
// 查询主题列表:推荐/关注/热门/最新
public
ThemeListResp
queryThemes
(
ThemeListReq
req
,
String
userId
)
{
List
<
String
>
excludeIds
;
if
(
req
.
page
.
pageNumber
>
1
)
{
String
l
=
redisCache
.
get
(
"queryThemes_"
+
req
.
ident
);
excludeIds
=
StringUtils
.
isBlank
(
l
)
?
new
ArrayList
<>()
:
JSON
.
parseArray
(
l
,
String
.
class
);
}
else
{
excludeIds
=
new
ArrayList
<>();
}
Integer
pageStart
=
(
req
.
page
.
pageNumber
-
1
)
*
req
.
page
.
pageSize
;
Integer
pageSize
=
req
.
page
.
pageSize
;
Integer
querySize
=
pageSize
*
3
;
...
...
@@ -203,7 +221,7 @@ public class ThemeManager {
//推荐
// 需要筛掉用户访问过详情的 & 最近出现在列表页过的.
List
<
String
>
visitedIds
=
visitLogService
.
queryUserRecentVisited
(
userId
);
List
<
String
>
excludes
=
ListUtils
.
union
(
req
.
excludeIds
,
visitedIds
);
List
<
String
>
excludes
=
ListUtils
.
union
(
excludeIds
,
visitedIds
);
List
<
String
>
recmdIds
=
recommendService
.
getRecommendThemes
(
pageStart
,
querySize
,
userId
,
excludes
);
recmdIds
=
BizUtils
.
subList
(
recmdIds
,
pageStart
,
pageSize
);
...
...
@@ -212,7 +230,7 @@ public class ThemeManager {
}
else
if
(
ThemeListTypeEnum
.
FOLLOW
.
getCode
().
equals
(
req
.
getType
()))
{
// TODO 临时埋点,接入新埋点后删除
if
(
CollectionUtils
.
isEmpty
(
req
.
getExcludeIds
()
))
{
if
(
CollectionUtils
.
isEmpty
(
excludeIds
))
{
visitLogService
.
addPageView
(
userId
,
userId
,
VisitTypeEnum
.
FOLLOW_THEME_VIEW
);
}
// 根据关注列表查询,按时间倒序
...
...
@@ -225,7 +243,7 @@ public class ThemeManager {
throw
new
BizException
(
"TopicId为空"
);
}
List
<
String
>
rankThemeIds
=
rankService
.
getRankThemeListByTopic
(
req
.
getTopicId
(),
req
.
excludeIds
);
List
<
String
>
rankThemeIds
=
rankService
.
getRankThemeListByTopic
(
req
.
getTopicId
(),
excludeIds
);
rankThemeIds
=
BizUtils
.
subList
(
rankThemeIds
,
pageStart
,
pageSize
);
themes
=
themeService
.
queryByThemeIds
(
rankThemeIds
);
...
...
@@ -236,14 +254,15 @@ public class ThemeManager {
if
(
StringUtils
.
isEmpty
(
req
.
getTopicId
()))
{
throw
new
BizException
(
"TopicId为空"
);
}
themes
=
themeService
.
queryNewestByTopic
(
req
.
topicId
,
pageStart
,
querySize
,
req
.
excludeIds
);
themes
=
themeService
.
queryNewestByTopic
(
req
.
topicId
,
pageStart
,
querySize
,
excludeIds
);
}
ThemeListResp
resp
=
new
ThemeListResp
();
resp
.
excludeIds
=
req
.
excludeIds
;
resp
.
excludeIds
.
addAll
(
themes
.
stream
().
map
(
ThemeEntity:
:
getThemeId
).
collect
(
Collectors
.
toList
()));
resp
.
themes
=
convertEntityToQo
(
themes
,
userId
);
excludeIds
.
addAll
(
resp
.
themes
.
stream
().
map
(
ThemeQo:
:
getThemeId
).
collect
(
Collectors
.
toList
()));
redisCache
.
put
(
"queryThemes_"
+
req
.
ident
,
JSON
.
toJSONString
(
excludeIds
),
60
*
60
*
6
);
//组装详情
return
resp
;
}
...
...
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