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
67864f98
Commit
67864f98
authored
Aug 13, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
圈子消息通知-评论
parent
4fd648e9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
17 deletions
+34
-17
NotificationLikeDO.java
...va/com/tanpu/community/dao/entity/NotificationLikeDO.java
+4
-4
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+11
-0
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+8
-1
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+1
-1
FollowRelService.java
...in/java/com/tanpu/community/service/FollowRelService.java
+3
-1
NotificationService.java
...java/com/tanpu/community/service/NotificationService.java
+7
-10
No files found.
community-service/src/main/java/com/tanpu/community/dao/entity/NotificationLikeDO.java
View file @
67864f98
...
@@ -13,12 +13,12 @@ import java.util.TreeSet;
...
@@ -13,12 +13,12 @@ import java.util.TreeSet;
@NoArgsConstructor
@NoArgsConstructor
public
class
NotificationLikeDO
{
public
class
NotificationLikeDO
{
private
Integer
count
;
private
Integer
count
=
0
;
private
TreeSet
<
String
>
set
;
private
TreeSet
<
String
>
set
=
new
TreeSet
<>()
;
public
void
addItem
(
String
item
){
public
void
addItem
(
String
item
)
{
if
(
this
.
set
.
size
()
>=
3
)
{
if
(
this
.
set
.
size
()
>=
3
)
{
set
.
pollFirst
();
set
.
pollFirst
();
}
}
set
.
add
(
item
);
set
.
add
(
item
);
...
...
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
67864f98
...
@@ -10,14 +10,17 @@ import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
...
@@ -10,14 +10,17 @@ import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
import
com.tanpu.community.api.beans.req.comment.LikeCommentReq
;
import
com.tanpu.community.api.beans.req.comment.LikeCommentReq
;
import
com.tanpu.community.api.beans.req.comment.ReportCommentReq
;
import
com.tanpu.community.api.beans.req.comment.ReportCommentReq
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.enums.NotificationTypeEnum
;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.feign.fatools.FeignClientForFatools
;
import
com.tanpu.community.feign.fatools.FeignClientForFatools
;
import
com.tanpu.community.service.CollectionService
;
import
com.tanpu.community.service.CollectionService
;
import
com.tanpu.community.service.CommentService
;
import
com.tanpu.community.service.CommentService
;
import
com.tanpu.community.service.NotificationService
;
import
com.tanpu.community.service.NotificationService
;
import
com.tanpu.community.service.ReportLogService
;
import
com.tanpu.community.service.ReportLogService
;
import
com.tanpu.community.service.ThemeService
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.ConvertUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -51,7 +54,11 @@ public class CommentManager {
...
@@ -51,7 +54,11 @@ public class CommentManager {
@Autowired
@Autowired
private
RedisCache
redisCache
;
private
RedisCache
redisCache
;
@Autowired
private
NotificationService
notificationService
;
@Autowired
private
ThemeService
themeService
;
// 评论(对主题)
// 评论(对主题)
// 发表评论(对主题)
// 发表评论(对主题)
...
@@ -79,6 +86,10 @@ public class CommentManager {
...
@@ -79,6 +86,10 @@ public class CommentManager {
commentService
.
insertComment
(
commentEntity
);
commentService
.
insertComment
(
commentEntity
);
CommentQo
commentQo
=
ConvertUtil
.
commentEntity2Qo
(
commentEntity
);
CommentQo
commentQo
=
ConvertUtil
.
commentEntity2Qo
(
commentEntity
);
buildUserInfo
(
commentQo
);
buildUserInfo
(
commentQo
);
// 消息通知
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
req
.
getThemeId
());
notificationService
.
insert
(
userId
,
themeEntity
.
getAuthorId
(),
NotificationTypeEnum
.
COMMENT
,
req
.
getThemeId
(),
req
.
getComment
());
return
commentQo
;
return
commentQo
;
}
}
...
...
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
67864f98
...
@@ -27,11 +27,13 @@ import com.tanpu.community.feign.fatools.FeignClientForFatools;
...
@@ -27,11 +27,13 @@ import com.tanpu.community.feign.fatools.FeignClientForFatools;
import
com.tanpu.community.feign.product.FeignForFund
;
import
com.tanpu.community.feign.product.FeignForFund
;
import
com.tanpu.community.feign.product.FeignForPublicFund
;
import
com.tanpu.community.feign.product.FeignForPublicFund
;
import
com.tanpu.community.service.FollowRelService
;
import
com.tanpu.community.service.FollowRelService
;
import
com.tanpu.community.service.NotificationService
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.PageUtils
;
import
com.tanpu.community.util.PageUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -61,6 +63,9 @@ public class HomePageManager {
...
@@ -61,6 +63,9 @@ public class HomePageManager {
@Resource
@Resource
private
RedisCache
redisCache
;
private
RedisCache
redisCache
;
@Autowired
private
NotificationService
notificationService
;
//查询 个人中心 相关信息
//查询 个人中心 相关信息
public
UserInfoResp
queryUsersInfo
(
String
userIdMyself
,
String
userId
)
{
public
UserInfoResp
queryUsersInfo
(
String
userIdMyself
,
String
userId
)
{
CommonResp
<
UserInfoResp
>
queryUsersListNew
=
feignClientForFatools
.
queryUserInfoNew
(
StringUtils
.
isNotBlank
(
userId
)
?
userId
:
userIdMyself
);
CommonResp
<
UserInfoResp
>
queryUsersListNew
=
feignClientForFatools
.
queryUserInfoNew
(
StringUtils
.
isNotBlank
(
userId
)
?
userId
:
userIdMyself
);
...
@@ -227,7 +232,9 @@ public class HomePageManager {
...
@@ -227,7 +232,9 @@ public class HomePageManager {
public
void
addFollowRel
(
FollowRelReq
req
,
String
followerId
)
{
public
void
addFollowRel
(
FollowRelReq
req
,
String
followerId
)
{
if
(
OperationTypeEnum
.
CONFIRM
.
getCode
().
equals
(
req
.
getType
()))
{
if
(
OperationTypeEnum
.
CONFIRM
.
getCode
().
equals
(
req
.
getType
()))
{
followRelService
.
addFollowRel
(
req
.
getFollowUserId
(),
followerId
);
if
(
followRelService
.
addFollowRel
(
req
.
getFollowUserId
(),
followerId
)){
notificationService
.
insert
(
followerId
,
req
.
getFollowUserId
(),
NotificationTypeEnum
.
FOLLOW
,
req
.
getFollowUserId
(),
null
);
}
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()))
{
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()))
{
followRelService
.
deleteFollowRel
(
req
.
getFollowUserId
(),
followerId
);
followRelService
.
deleteFollowRel
(
req
.
getFollowUserId
(),
followerId
);
}
}
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
67864f98
...
@@ -135,9 +135,9 @@ public class ThemeManager {
...
@@ -135,9 +135,9 @@ public class ThemeManager {
@Resource
@Resource
private
RestTemplate
restTemplate
;
private
RestTemplate
restTemplate
;
@Autowired
@Autowired
private
NotificationService
notificationService
;
private
NotificationService
notificationService
;
@PostConstruct
@PostConstruct
public
void
init
()
throws
IOException
{
public
void
init
()
throws
IOException
{
File
f
=
new
File
(
tmpDir
);
File
f
=
new
File
(
tmpDir
);
...
...
community-service/src/main/java/com/tanpu/community/service/FollowRelService.java
View file @
67864f98
...
@@ -77,7 +77,7 @@ public class FollowRelService {
...
@@ -77,7 +77,7 @@ public class FollowRelService {
}
}
@Transactional
@Transactional
public
void
addFollowRel
(
String
idolId
,
String
followerId
)
{
public
boolean
addFollowRel
(
String
idolId
,
String
followerId
)
{
FollowRelEntity
searchResult
=
queryRecord
(
idolId
,
followerId
);
FollowRelEntity
searchResult
=
queryRecord
(
idolId
,
followerId
);
if
(
searchResult
==
null
)
{
if
(
searchResult
==
null
)
{
FollowRelEntity
entity
=
FollowRelEntity
.
builder
()
FollowRelEntity
entity
=
FollowRelEntity
.
builder
()
...
@@ -87,10 +87,12 @@ public class FollowRelService {
...
@@ -87,10 +87,12 @@ public class FollowRelService {
.
build
();
.
build
();
followRelMapper
.
insert
(
entity
);
followRelMapper
.
insert
(
entity
);
return
true
;
}
else
{
}
else
{
searchResult
.
setFollowTime
(
LocalDateTime
.
now
());
searchResult
.
setFollowTime
(
LocalDateTime
.
now
());
searchResult
.
setDeleteTag
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
searchResult
.
setDeleteTag
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
followRelMapper
.
updateById
(
searchResult
);
followRelMapper
.
updateById
(
searchResult
);
return
false
;
}
}
}
}
...
...
community-service/src/main/java/com/tanpu/community/service/NotificationService.java
View file @
67864f98
...
@@ -10,9 +10,11 @@ import com.tanpu.community.dao.entity.community.NotificationEntity;
...
@@ -10,9 +10,11 @@ import com.tanpu.community.dao.entity.community.NotificationEntity;
import
com.tanpu.community.dao.mapper.community.NotificationMapper
;
import
com.tanpu.community.dao.mapper.community.NotificationMapper
;
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.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.List
;
import
java.util.TreeSet
;
@Service
@Service
public
class
NotificationService
{
public
class
NotificationService
{
...
@@ -23,6 +25,7 @@ public class NotificationService {
...
@@ -23,6 +25,7 @@ public class NotificationService {
@Autowired
@Autowired
private
UuidGenHelper
uuidGenHelper
;
private
UuidGenHelper
uuidGenHelper
;
@Transactional
public
void
insert
(
String
operatorId
,
String
notifierId
,
NotificationTypeEnum
type
,
String
targetId
,
String
content
){
public
void
insert
(
String
operatorId
,
String
notifierId
,
NotificationTypeEnum
type
,
String
targetId
,
String
content
){
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
.
notificationId
(
uuidGenHelper
.
getUuidStr
())
.
notificationId
(
uuidGenHelper
.
getUuidStr
())
...
@@ -30,10 +33,9 @@ public class NotificationService {
...
@@ -30,10 +33,9 @@ public class NotificationService {
.
messageType
(
type
.
getCode
())
.
messageType
(
type
.
getCode
())
.
content
(
content
)
.
content
(
content
)
.
operatorId
(
targetId
).
build
();
.
operatorId
(
targetId
).
build
();
}
}
@Transactional
public
void
insertForward
(
String
operatorId
,
String
notifierId
,
String
themeId
,
String
topicId
,
String
text
){
public
void
insertForward
(
String
operatorId
,
String
notifierId
,
String
themeId
,
String
topicId
,
String
text
){
NotificationForwardDO
forwardDO
=
NotificationForwardDO
.
builder
().
topicId
(
topicId
).
content
(
text
).
build
();
NotificationForwardDO
forwardDO
=
NotificationForwardDO
.
builder
().
topicId
(
topicId
).
content
(
text
).
build
();
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
...
@@ -48,7 +50,7 @@ public class NotificationService {
...
@@ -48,7 +50,7 @@ public class NotificationService {
}
}
@Transactional
public
void
insertLike
(
String
operatorId
,
String
notifierId
,
String
targetId
){
public
void
insertLike
(
String
operatorId
,
String
notifierId
,
String
targetId
){
NotificationEntity
entity
=
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>()
NotificationEntity
entity
=
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>()
.
eq
(
NotificationEntity:
:
getMessageType
,
NotificationTypeEnum
.
LIKE
.
getCode
())
.
eq
(
NotificationEntity:
:
getMessageType
,
NotificationTypeEnum
.
LIKE
.
getCode
())
...
@@ -56,6 +58,7 @@ public class NotificationService {
...
@@ -56,6 +58,7 @@ public class NotificationService {
if
(
entity
!=
null
){
if
(
entity
!=
null
){
NotificationLikeDO
notificationLikeDO
=
JsonUtil
.
toBean
(
entity
.
getContent
(),
NotificationLikeDO
.
class
);
NotificationLikeDO
notificationLikeDO
=
JsonUtil
.
toBean
(
entity
.
getContent
(),
NotificationLikeDO
.
class
);
notificationLikeDO
.
addItem
(
operatorId
);
notificationLikeDO
.
addItem
(
operatorId
);
entity
.
setContent
(
JsonUtil
.
toJson
(
notificationLikeDO
));
entity
.
setContent
(
JsonUtil
.
toJson
(
notificationLikeDO
));
notificationMapper
.
updateById
(
entity
);
notificationMapper
.
updateById
(
entity
);
}
else
{
}
else
{
...
@@ -70,16 +73,10 @@ public class NotificationService {
...
@@ -70,16 +73,10 @@ public class NotificationService {
.
operatorId
(
operatorId
)
.
operatorId
(
operatorId
)
.
build
();
.
build
();
}
}
}
}
public
void
insert
(
NotificationEntity
entity
){
notificationMapper
.
insert
(
entity
);
}
public
NotificationEntity
queryById
(
String
notificationId
){
public
NotificationEntity
queryById
(
String
notificationId
){
return
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>()
return
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>()
...
...
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