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
0b2384c0
Commit
0b2384c0
authored
Feb 10, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/fix-issue#42'
parents
962fac72
bdc8c62a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
109 additions
and
1 deletions
+109
-1
src/main/java/cn/meteor/beyondclouds/modules/post/listener/UserInfoChangeListener.java
+25
-0
src/main/java/cn/meteor/beyondclouds/modules/post/service/IPostCommentService.java
+11
-0
src/main/java/cn/meteor/beyondclouds/modules/post/service/IPostService.java
+12
-0
src/main/java/cn/meteor/beyondclouds/modules/post/service/impl/PostCommentServiceImpl.java
+27
-0
src/main/java/cn/meteor/beyondclouds/modules/post/service/impl/PostServiceImpl.java
+33
-0
src/main/resources/application.yml
+1
-1
No files found.
src/main/java/cn/meteor/beyondclouds/modules/post/listener/UserInfoChangeListener.java
View file @
0b2384c0
package
cn
.
meteor
.
beyondclouds
.
modules
.
post
.
listener
;
package
cn
.
meteor
.
beyondclouds
.
modules
.
post
.
listener
;
import
cn.meteor.beyondclouds.core.listener.DataItemChangeListener
;
import
cn.meteor.beyondclouds.core.listener.DataItemChangeListener
;
import
cn.meteor.beyondclouds.modules.post.service.IPostCommentService
;
import
cn.meteor.beyondclouds.modules.post.service.IPostService
;
import
cn.meteor.beyondclouds.modules.queue.message.DataItemChangeMessage
;
import
cn.meteor.beyondclouds.modules.queue.message.DataItemChangeMessage
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
/**
...
@@ -13,8 +16,30 @@ import org.springframework.stereotype.Component;
...
@@ -13,8 +16,30 @@ import org.springframework.stereotype.Component;
@Component
(
"postUserInfoChangeListener"
)
@Component
(
"postUserInfoChangeListener"
)
public
class
UserInfoChangeListener
extends
DataItemChangeListener
{
public
class
UserInfoChangeListener
extends
DataItemChangeListener
{
private
IPostService
postService
;
private
IPostCommentService
postCommentService
;
@Autowired
public
UserInfoChangeListener
(
IPostService
postService
,
IPostCommentService
postCommentService
)
{
this
.
postService
=
postService
;
this
.
postCommentService
=
postCommentService
;
}
@Override
@Override
public
void
onUserAvatarUpdate
(
DataItemChangeMessage
dataItemChangeMessage
)
{
public
void
onUserAvatarUpdate
(
DataItemChangeMessage
dataItemChangeMessage
)
{
String
userId
=
String
.
valueOf
(
dataItemChangeMessage
.
getItemId
());
postService
.
updatePostUserAvatar
(
userId
);
postCommentService
.
updatePostUserAvatar
(
userId
);
log
.
debug
(
"post-用户头像更新:{}"
,
dataItemChangeMessage
);
log
.
debug
(
"post-用户头像更新:{}"
,
dataItemChangeMessage
);
}
@Override
public
void
onUserNickUpdate
(
DataItemChangeMessage
dataItemChangeMessage
)
{
String
userId
=
String
.
valueOf
(
dataItemChangeMessage
.
getItemId
());
postService
.
updatePostUserNick
(
userId
);
postCommentService
.
updatePostUserNick
(
userId
);
log
.
debug
(
"post-用户昵称更新:{}"
,
dataItemChangeMessage
);
}
}
}
}
src/main/java/cn/meteor/beyondclouds/modules/post/service/IPostCommentService.java
View file @
0b2384c0
...
@@ -46,4 +46,15 @@ public interface IPostCommentService extends IService<PostComment> {
...
@@ -46,4 +46,15 @@ public interface IPostCommentService extends IService<PostComment> {
IPage
<
PostComment
>
getCommentPage
(
Integer
pageNumber
,
Integer
size
,
String
postId
,
Integer
parentId
)
throws
PostCommentServiceException
;
IPage
<
PostComment
>
getCommentPage
(
Integer
pageNumber
,
Integer
size
,
String
postId
,
Integer
parentId
)
throws
PostCommentServiceException
;
/**
* 更新动态评论里面的用户头像
* @param userId
*/
void
updatePostUserAvatar
(
String
userId
);
/**
* 更新动态评论里的用户昵称
* @param userId
*/
void
updatePostUserNick
(
String
userId
);
}
}
src/main/java/cn/meteor/beyondclouds/modules/post/service/IPostService.java
View file @
0b2384c0
...
@@ -46,4 +46,16 @@ public interface IPostService extends IService<Post> {
...
@@ -46,4 +46,16 @@ public interface IPostService extends IService<Post> {
* @return
* @return
*/
*/
IPage
<
Post
>
getUserPostPage
(
Integer
pageNumber
,
Integer
pageSize
,
String
userId
);
IPage
<
Post
>
getUserPostPage
(
Integer
pageNumber
,
Integer
pageSize
,
String
userId
);
/**
* 更新动态里的用户头像
* @param userId
*/
void
updatePostUserAvatar
(
String
userId
);
/**
* 更新动态里的用户昵称
* @param userId
*/
void
updatePostUserNick
(
String
userId
);
}
}
src/main/java/cn/meteor/beyondclouds/modules/post/service/impl/PostCommentServiceImpl.java
View file @
0b2384c0
...
@@ -12,6 +12,7 @@ import cn.meteor.beyondclouds.modules.post.service.IPostService;
...
@@ -12,6 +12,7 @@ import cn.meteor.beyondclouds.modules.post.service.IPostService;
import
cn.meteor.beyondclouds.modules.user.entity.User
;
import
cn.meteor.beyondclouds.modules.user.entity.User
;
import
cn.meteor.beyondclouds.modules.user.service.IUserService
;
import
cn.meteor.beyondclouds.modules.user.service.IUserService
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
...
@@ -167,4 +168,30 @@ public class PostCommentServiceImpl extends ServiceImpl<PostCommentMapper, PostC
...
@@ -167,4 +168,30 @@ public class PostCommentServiceImpl extends ServiceImpl<PostCommentMapper, PostC
return
page
(
page
,
postCommentQueryWrapper
);
return
page
(
page
,
postCommentQueryWrapper
);
}
}
/**
* 更新动态评论里的用户头像
* @param userId
*/
@Override
public
void
updatePostUserAvatar
(
String
userId
)
{
User
user
=
userService
.
getById
(
userId
);
if
(
null
!=
user
){
UpdateWrapper
<
PostComment
>
postUpdateWrapper
=
new
UpdateWrapper
<>();
postUpdateWrapper
.
eq
(
"user_id"
,
userId
);
postUpdateWrapper
.
set
(
"user_avatar"
,
user
.
getUserAvatar
());
update
(
postUpdateWrapper
);
}
}
@Override
public
void
updatePostUserNick
(
String
userId
)
{
User
user
=
userService
.
getById
(
userId
);
if
(
null
!=
user
){
UpdateWrapper
<
PostComment
>
postUpdateWrapper
=
new
UpdateWrapper
<>();
postUpdateWrapper
.
eq
(
"user_id"
,
userId
);
postUpdateWrapper
.
set
(
"user_nick"
,
user
.
getNickName
());
update
(
postUpdateWrapper
);
}
}
}
}
src/main/java/cn/meteor/beyondclouds/modules/post/service/impl/PostServiceImpl.java
View file @
0b2384c0
package
cn
.
meteor
.
beyondclouds
.
modules
.
post
.
service
.
impl
;
package
cn
.
meteor
.
beyondclouds
.
modules
.
post
.
service
.
impl
;
import
cn.meteor.beyondclouds.modules.post.entity.Post
;
import
cn.meteor.beyondclouds.modules.post.entity.Post
;
import
cn.meteor.beyondclouds.modules.post.entity.PostComment
;
import
cn.meteor.beyondclouds.modules.post.enums.PostErrorCode
;
import
cn.meteor.beyondclouds.modules.post.enums.PostErrorCode
;
import
cn.meteor.beyondclouds.modules.post.exception.PostServiceException
;
import
cn.meteor.beyondclouds.modules.post.exception.PostServiceException
;
import
cn.meteor.beyondclouds.modules.post.mapper.PostMapper
;
import
cn.meteor.beyondclouds.modules.post.mapper.PostMapper
;
...
@@ -9,6 +10,7 @@ import cn.meteor.beyondclouds.modules.project.exception.ProjectServiceException;
...
@@ -9,6 +10,7 @@ import cn.meteor.beyondclouds.modules.project.exception.ProjectServiceException;
import
cn.meteor.beyondclouds.modules.user.entity.User
;
import
cn.meteor.beyondclouds.modules.user.entity.User
;
import
cn.meteor.beyondclouds.modules.user.service.IUserService
;
import
cn.meteor.beyondclouds.modules.user.service.IUserService
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
...
@@ -125,5 +127,36 @@ public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements IP
...
@@ -125,5 +127,36 @@ public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements IP
return
page
(
postPage
,
queryWrapper
);
return
page
(
postPage
,
queryWrapper
);
}
}
/**
* 更新动态里的用户头像
* @param userId
*/
@Override
public
void
updatePostUserAvatar
(
String
userId
)
{
User
user
=
userService
.
getById
(
userId
);
if
(
null
!=
user
){
UpdateWrapper
<
Post
>
postUpdateWrapper
=
new
UpdateWrapper
<>();
postUpdateWrapper
.
eq
(
"user_id"
,
userId
);
postUpdateWrapper
.
set
(
"user_avatar"
,
user
.
getUserAvatar
());
update
(
postUpdateWrapper
);
}
}
/**
* 更新动态里的用户昵称
* @param userId
*/
@Override
public
void
updatePostUserNick
(
String
userId
)
{
User
user
=
userService
.
getById
(
userId
);
if
(
null
!=
user
){
UpdateWrapper
<
Post
>
postUpdateWrapper
=
new
UpdateWrapper
<>();
postUpdateWrapper
.
eq
(
"user_id"
,
userId
);
postUpdateWrapper
.
set
(
"user_nick"
,
user
.
getNickName
());
update
(
postUpdateWrapper
);
}
}
}
}
src/main/resources/application.yml
View file @
0b2384c0
...
@@ -5,7 +5,7 @@ spring:
...
@@ -5,7 +5,7 @@ spring:
driver-class-name
:
com.mysql.cj.jdbc.Driver
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://127.0.0.1:3306/beyond_clouds?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
url
:
jdbc:mysql://127.0.0.1:3306/beyond_clouds?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
username
:
root
username
:
root
password
:
100Centa30821%mysql
password
:
2018006709
# 邮箱
# 邮箱
mail
:
mail
:
...
...
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