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
48adc132
Commit
48adc132
authored
Feb 13, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增话题贡献者列表
parent
477f2043
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
107 additions
and
1 deletions
+107
-1
src/main/java/cn/meteor/beyondclouds/modules/topic/api/TopicApi.java
+12
-0
src/main/java/cn/meteor/beyondclouds/modules/topic/mapper/TopicMapper.java
+7
-0
src/main/java/cn/meteor/beyondclouds/modules/topic/mapper/xml/TopicMapper.xml
+8
-0
src/main/java/cn/meteor/beyondclouds/modules/topic/service/ITopicService.java
+9
-0
src/main/java/cn/meteor/beyondclouds/modules/topic/service/impl/TopicServiceImpl.java
+25
-1
src/main/java/cn/meteor/beyondclouds/modules/user/mapper/UserMapper.java
+10
-0
src/main/java/cn/meteor/beyondclouds/modules/user/mapper/xml/UserMapper.xml
+22
-0
src/main/java/cn/meteor/beyondclouds/modules/user/service/IUserService.java
+9
-0
src/main/java/cn/meteor/beyondclouds/modules/user/service/impl/UserServiceImpl.java
+5
-0
No files found.
src/main/java/cn/meteor/beyondclouds/modules/topic/api/TopicApi.java
View file @
48adc132
...
...
@@ -20,6 +20,7 @@ import cn.meteor.beyondclouds.modules.topic.service.ITopicService;
import
cn.meteor.beyondclouds.modules.user.dto.UserFollowDTO
;
import
cn.meteor.beyondclouds.modules.user.dto.UserInfoDTO
;
import
cn.meteor.beyondclouds.modules.user.entity.User
;
import
cn.meteor.beyondclouds.modules.user.entity.UserFollow
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -219,4 +220,15 @@ public class TopicApi {
PageDTO
<
TopicDTO
>
topicDTOPage
=
topicService
.
getHotSearchTopics
(
pageForm
.
getPage
(),
pageForm
.
getSize
());
return
Response
.
success
(
topicDTOPage
);
}
@Anonymous
@ApiOperation
(
"话题贡献者列表"
)
@GetMapping
(
"/topic/{topicId}/contributes"
)
public
Response
<?>
topicContributes
(
@PathVariable
(
"topicId"
)
String
topicId
,
@Valid
PageForm
pageForm
,
BindingResult
bindingResult
)
{
if
(
bindingResult
.
hasErrors
())
{
return
Response
.
fieldError
(
bindingResult
.
getFieldError
());
}
PageDTO
<
UserFollowDTO
>
userFollowDTOPage
=
topicService
.
getTopicContributes
(
topicId
,
pageForm
.
getPage
(),
pageForm
.
getSize
());
return
Response
.
success
(
userFollowDTOPage
);
}
}
src/main/java/cn/meteor/beyondclouds/modules/topic/mapper/TopicMapper.java
View file @
48adc132
...
...
@@ -45,4 +45,11 @@ public interface TopicMapper extends BaseMapper<Topic> {
*/
IPage
<
Post
>
searchPostInTopicWithConditions
(
Page
<
Post
>
postPage
,
@Param
(
Constants
.
WRAPPER
)
QueryWrapper
<?>
queryWrapper
);
/**
* 获取话题贡献者的ID
* @param page
* @param topicId
* @return
*/
IPage
<
String
>
selectTopicContributeIdPage
(
Page
<
String
>
page
,
@Param
(
"topicId"
)
String
topicId
);
}
src/main/java/cn/meteor/beyondclouds/modules/topic/mapper/xml/TopicMapper.xml
View file @
48adc132
...
...
@@ -23,5 +23,13 @@
</if>
</select>
<select
id=
"selectTopicContributeIdPage"
resultType=
"java.lang.String"
>
SELECT user_id
FROM topic_reference tr
WHERE topic_id = #{topicId}
GROUP BY user_id
ORDER BY COUNT(user_id) DESC
</select>
</mapper>
src/main/java/cn/meteor/beyondclouds/modules/topic/service/ITopicService.java
View file @
48adc132
...
...
@@ -164,4 +164,13 @@ public interface ITopicService extends IService<Topic> {
*/
PageDTO
<
TopicDTO
>
getHotSearchTopics
(
Integer
pageNumber
,
Integer
pageSize
);
/**
* 获取话题的贡献者分页列表
*
* @param topicId
* @param page
* @param size
* @return
*/
PageDTO
<
UserFollowDTO
>
getTopicContributes
(
String
topicId
,
Integer
page
,
Integer
size
);
}
src/main/java/cn/meteor/beyondclouds/modules/topic/service/impl/TopicServiceImpl.java
View file @
48adc132
...
...
@@ -22,6 +22,7 @@ import cn.meteor.beyondclouds.modules.topic.service.ITopicFollowService;
import
cn.meteor.beyondclouds.modules.topic.service.ITopicReferenceService
;
import
cn.meteor.beyondclouds.modules.topic.service.ITopicService
;
import
cn.meteor.beyondclouds.modules.user.dto.UserFollowDTO
;
import
cn.meteor.beyondclouds.modules.user.dto.UserInfoDTO
;
import
cn.meteor.beyondclouds.modules.user.entity.User
;
import
cn.meteor.beyondclouds.modules.user.entity.UserStatistics
;
import
cn.meteor.beyondclouds.modules.user.service.IUserFollowService
;
...
...
@@ -34,7 +35,6 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -550,5 +550,29 @@ public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements
return
toPageDTO
(
topicPage
);
}
@Override
public
PageDTO
<
UserFollowDTO
>
getTopicContributes
(
String
topicId
,
Integer
pageNumber
,
Integer
pageSize
)
{
IPage
<
String
>
userIdPage
=
topicMapper
.
selectTopicContributeIdPage
(
new
Page
<>(
pageNumber
,
pageSize
),
topicId
);
List
<
String
>
userIds
=
userIdPage
.
getRecords
();
PageDTO
<
UserFollowDTO
>
userFollowDTOPage
=
new
PageDTO
<>();
PageUtils
.
copyMeta
(
userIdPage
,
userFollowDTOPage
);
if
(!
CollectionUtils
.
isEmpty
(
userIds
))
{
List
<
UserFollowDTO
>
userInfoDTOList
=
userService
.
listByIdsWithStatistics
(
userIds
);
if
(
SubjectUtils
.
isAuthenticated
())
{
Set
<
String
>
followedUserIds
=
userFollowService
.
getCurrentUserFollowedUserIds
();
userInfoDTOList
.
forEach
(
userFollowDTO
->
{
userFollowDTO
.
setFollowedUser
(
followedUserIds
.
contains
(
userFollowDTO
.
getUserId
()));
});
}
else
{
userInfoDTOList
.
forEach
(
userFollowDTO
->
{
userFollowDTO
.
setFollowedUser
(
false
);
});
}
userFollowDTOPage
.
setDataList
(
userInfoDTOList
);
}
else
{
userFollowDTOPage
.
setDataList
(
List
.
of
());
}
return
userFollowDTOPage
;
}
}
src/main/java/cn/meteor/beyondclouds/modules/user/mapper/UserMapper.java
View file @
48adc132
...
...
@@ -5,6 +5,9 @@ import cn.meteor.beyondclouds.modules.user.entity.User;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* @author 段启岩
...
...
@@ -18,4 +21,11 @@ public interface UserMapper extends BaseMapper<User> {
* @return
*/
IPage
<
UserFollowDTO
>
selectHotBloggerPage
(
Page
<
User
>
page
);
/**
* 批量查询用户-带统计信息
* @param userIds
* @return
*/
List
<
UserFollowDTO
>
listByIdsWithStatistics
(
@Param
(
"userIds"
)
List
<
String
>
userIds
);
}
src/main/java/cn/meteor/beyondclouds/modules/user/mapper/xml/UserMapper.xml
View file @
48adc132
...
...
@@ -18,5 +18,27 @@
AND US.blog_view_num > 0
order by us.blog_view_num desc
</select>
<select
id=
"listByIdsWithStatistics"
resultType=
"cn.meteor.beyondclouds.modules.user.dto.UserFollowDTO"
>
select
u.*,
u.nick_name user_nick,
us.followed_num `statistics.followed_num`,
us.fans_num `statistics.fans_num`,
us.blog_num `statistics.blog_num`,
us.blog_view_num `statistics.blog_view_num`,
us.project_num `statistics.project_num`,
us.post_num `statistics.post_num`,
us.question_num `statistics.question_num`,
us.visited_num `statistics.visited_num`
from `user` u, user_statistics us
where u.user_id = us.user_id
and u.user_id
in
<foreach
collection=
"userIds"
item=
"userId"
index=
"index"
open=
"("
close=
")"
separator=
","
>
#{userId}
</foreach>
order by us.blog_view_num desc
</select>
</mapper>
src/main/java/cn/meteor/beyondclouds/modules/user/service/IUserService.java
View file @
48adc132
...
...
@@ -9,6 +9,8 @@ import cn.meteor.beyondclouds.modules.user.entity.UserStatistics;
import
cn.meteor.beyondclouds.modules.user.exception.UserServiceException
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
java.util.List
;
/**
* @author meteor
*/
...
...
@@ -105,4 +107,11 @@ public interface IUserService extends IService<User> {
* @return
*/
PageDTO
<
UserFollowDTO
>
getHotBloggers
(
Integer
pageNumber
,
Integer
pageSize
);
/**
* 批量查询用户-带统计信息
* @param userIds
* @return
*/
List
<
UserFollowDTO
>
listByIdsWithStatistics
(
List
<
String
>
userIds
);
}
src/main/java/cn/meteor/beyondclouds/modules/user/service/impl/UserServiceImpl.java
View file @
48adc132
...
...
@@ -452,4 +452,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
userFollowDTOPage
.
setDataList
(
userFollowDTOList
);
return
userFollowDTOPage
;
}
@Override
public
List
<
UserFollowDTO
>
listByIdsWithStatistics
(
List
<
String
>
userIds
)
{
return
userMapper
.
listByIdsWithStatistics
(
userIds
);
}
}
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