Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
段启岩
beyond-clouds
Commits
d59d9d2c
Commit
d59d9d2c
authored
Feb 01, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提高listByIds时代码的稳定性
parent
f597bc35
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
src/main/java/cn/meteor/beyondclouds/modules/question/service/impl/QuestionTagServiceImpl.java
+4
-3
src/main/java/cn/meteor/beyondclouds/modules/topic/service/impl/TopicServiceImpl.java
+13
-2
No files found.
src/main/java/cn/meteor/beyondclouds/modules/question/service/impl/QuestionTagServiceImpl.java
View file @
d59d9d2c
...
@@ -13,6 +13,7 @@ import cn.meteor.beyondclouds.modules.tag.service.ITagService;
...
@@ -13,6 +13,7 @@ import cn.meteor.beyondclouds.modules.tag.service.ITagService;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Iterator
;
...
@@ -77,10 +78,10 @@ public class QuestionTagServiceImpl extends ServiceImpl<QuestionTagMapper, Quest
...
@@ -77,10 +78,10 @@ public class QuestionTagServiceImpl extends ServiceImpl<QuestionTagMapper, Quest
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
// 3.根据tagIds查询出标签并返回
// 3.根据tagIds查询出标签并返回
if
(
tagIds
.
size
()
>
0
)
{
if
(
CollectionUtils
.
isEmpty
(
tagIds
)
)
{
return
tagService
.
listByIds
(
tagIds
);
return
List
.
of
(
);
}
else
{
}
else
{
return
null
;
return
tagService
.
listByIds
(
tagIds
)
;
}
}
}
}
}
}
src/main/java/cn/meteor/beyondclouds/modules/topic/service/impl/TopicServiceImpl.java
View file @
d59d9d2c
...
@@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...
@@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -112,7 +113,12 @@ public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements
...
@@ -112,7 +113,12 @@ public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
// 3. 通过用户id批量查询用户
// 3. 通过用户id批量查询用户
List
<
Topic
>
topics
=
listByIds
(
topicIds
);
List
<
Topic
>
topics
;
if
(
CollectionUtils
.
isEmpty
(
topicIds
))
{
topics
=
List
.
of
();
}
else
{
topics
=
listByIds
(
topicIds
);
}
// 5.构造分页结果
// 5.构造分页结果
IPage
<
Topic
>
userPage
=
new
Page
<>();
IPage
<
Topic
>
userPage
=
new
Page
<>();
...
@@ -143,7 +149,12 @@ public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements
...
@@ -143,7 +149,12 @@ public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
// 3. 通过用户id批量查询用户
// 3. 通过用户id批量查询用户
List
<
User
>
followers
=
userService
.
listByIds
(
followerIds
);
List
<
User
>
followers
;
if
(
CollectionUtils
.
isEmpty
(
followerIds
))
{
followers
=
List
.
of
();
}
else
{
followers
=
userService
.
listByIds
(
followerIds
);
}
// 4.去除敏感信息
// 4.去除敏感信息
followers
.
stream
()
followers
.
stream
()
...
...
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