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
0112d403
Commit
0112d403
authored
Aug 16, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
消息通知初始化
parent
f1a6fd55
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
206 additions
and
32 deletions
+206
-32
NotificationController.java
...om/tanpu/community/controller/NotificationController.java
+12
-0
NotificationManager.java
...java/com/tanpu/community/manager/NotificationManager.java
+114
-27
CollectionService.java
...n/java/com/tanpu/community/service/CollectionService.java
+11
-5
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+6
-0
FollowRelService.java
...in/java/com/tanpu/community/service/FollowRelService.java
+6
-0
NotificationService.java
...java/com/tanpu/community/service/NotificationService.java
+50
-0
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+7
-0
No files found.
community-service/src/main/java/com/tanpu/community/controller/NotificationController.java
View file @
0112d403
...
...
@@ -55,4 +55,16 @@ public class NotificationController {
return
CommonResp
.
success
(
notificationQO
);
}
@AuthLogin
@GetMapping
(
"/init"
)
@ResponseBody
@ApiOperation
(
value
=
"初始化数据"
)
public
CommonResp
<
Void
>
initData
(){
if
(!
"admin"
.
equals
(
userHolder
.
getUserId
())){
return
CommonResp
.
failed
(
"权限不足"
);
}
notificationManager
.
init
();
return
CommonResp
.
success
();
}
}
community-service/src/main/java/com/tanpu/community/manager/NotificationManager.java
View file @
0112d403
This diff is collapsed.
Click to expand it.
community-service/src/main/java/com/tanpu/community/service/CollectionService.java
View file @
0112d403
...
...
@@ -27,8 +27,6 @@ public class CollectionService {
private
CollectionMapper
collectionMapper
;
// 若不存在则新增,若存在则修改deleteTag
@Transactional
public
boolean
saveOrUpdate
(
String
themeId
,
String
userId
,
CollectionTypeEnum
type
)
{
...
...
@@ -78,7 +76,7 @@ public class CollectionService {
//根据用户、主题、类型查询未删除对象
public
Set
<
String
>
getTargets
(
List
<
String
>
targetIds
,
String
userId
,
CollectionTypeEnum
type
)
{
if
(
CollectionUtils
.
isEmpty
(
targetIds
)){
if
(
CollectionUtils
.
isEmpty
(
targetIds
))
{
return
new
HashSet
<>();
}
LambdaQueryWrapper
<
CollectionEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CollectionEntity
>()
...
...
@@ -111,7 +109,7 @@ public class CollectionService {
}
// 根据用户id和行为type获取target_id列表
public
List
<
String
>
getListByUser
(
String
userId
,
CollectionTypeEnum
type
,
String
lastId
,
Integer
pageSize
)
{
public
List
<
String
>
getListByUser
(
String
userId
,
CollectionTypeEnum
type
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
CollectionEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getUserId
,
userId
)
.
eq
(
CollectionEntity:
:
getCollectionType
,
type
.
getCode
())
...
...
@@ -147,7 +145,7 @@ public class CollectionService {
}
LambdaQueryWrapper
<
CollectionEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getCollectionType
,
type
.
getCode
())
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
in
(
CollectionEntity:
:
getTargetId
,
targetIds
).
groupBy
(
CollectionEntity:
:
getTargetId
);
return
collectionMapper
.
selectCountByTargetIds
(
queryWrapper
).
stream
()
.
collect
(
Collectors
.
toMap
(
TimesCountEntity:
:
getId
,
TimesCountEntity:
:
getTimes
));
...
...
@@ -175,4 +173,12 @@ public class CollectionService {
return
;
}
}
public
List
<
CollectionEntity
>
queryALlLikeTheme
()
{
return
collectionMapper
.
selectList
(
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getCollectionType
,
CollectionTypeEnum
.
LIKE_THEME
.
getCode
())
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByAsc
(
CollectionEntity:
:
getCreateTime
));
}
}
community-service/src/main/java/com/tanpu/community/service/CommentService.java
View file @
0112d403
...
...
@@ -154,4 +154,10 @@ public class CommentService {
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
THEME_COMMENT_COUNT
,
themeId
));
}
public
List
<
CommentEntity
>
queryAll
()
{
return
commentMapper
.
selectList
(
new
LambdaQueryWrapper
<
CommentEntity
>()
.
eq
(
CommentEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByAsc
(
CommentEntity:
:
getCreateTime
));
}
}
community-service/src/main/java/com/tanpu/community/service/FollowRelService.java
View file @
0112d403
...
...
@@ -129,4 +129,10 @@ public class FollowRelService {
}
public
List
<
FollowRelEntity
>
queryAll
()
{
// todo 会丢失关注后 取消关注的情况,怎么选择?
return
followRelMapper
.
selectList
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByAsc
(
FollowRelEntity:
:
getUpdateTime
));
}
}
community-service/src/main/java/com/tanpu/community/service/NotificationService.java
View file @
0112d403
...
...
@@ -3,6 +3,7 @@ package com.tanpu.community.service;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.NotificationTypeEnum
;
import
com.tanpu.community.dao.entity.NotificationForwardDO
;
import
com.tanpu.community.dao.entity.NotificationLikeDO
;
...
...
@@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.List
;
@Service
...
...
@@ -38,6 +40,21 @@ public class NotificationService {
insert
(
entity
);
}
public
void
insert
(
String
operatorId
,
String
notifierId
,
NotificationTypeEnum
type
,
String
targetId
,
String
content
,
LocalDateTime
createTime
){
NotificationEntity
entity
=
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
.
notificationId
(
uuidGenHelper
.
getUuidStr
())
.
notifiedUserId
(
notifierId
)
.
messageType
(
type
.
getCode
())
.
content
(
content
)
.
operatorId
(
operatorId
)
.
targetId
(
targetId
)
.
createTime
(
createTime
)
.
updateTime
(
createTime
)
.
build
();
insert
(
entity
);
}
public
void
insertForward
(
String
operatorId
,
String
notifierId
,
String
themeId
,
String
topicId
,
String
text
){
NotificationForwardDO
forwardDO
=
NotificationForwardDO
.
builder
().
topicId
(
topicId
).
content
(
text
).
build
();
...
...
@@ -111,5 +128,38 @@ public class NotificationService {
}
public
void
truncate
()
{
notificationMapper
.
delete
(
new
LambdaQueryWrapper
<
NotificationEntity
>()
.
eq
(
NotificationEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()));
}
public
void
insertLike
(
String
operatorId
,
String
notifierId
,
String
targetId
,
LocalDateTime
updateTime
){
NotificationEntity
entity
=
notificationMapper
.
selectOne
(
new
LambdaQueryWrapper
<
NotificationEntity
>()
.
eq
(
NotificationEntity:
:
getMessageType
,
NotificationTypeEnum
.
LIKE
.
getCode
())
.
eq
(
NotificationEntity:
:
getTargetId
,
targetId
)
.
eq
(
NotificationEntity:
:
getNotifiedUserId
,
notifierId
));
if
(
entity
!=
null
){
NotificationLikeDO
notificationLikeDO
=
JsonUtil
.
toBean
(
entity
.
getContent
(),
NotificationLikeDO
.
class
);
notificationLikeDO
.
addItem
(
operatorId
);
entity
.
setContent
(
JsonUtil
.
toJson
(
notificationLikeDO
));
entity
.
setUpdateTime
(
updateTime
);
notificationMapper
.
updateById
(
entity
);
}
else
{
NotificationLikeDO
notificationLikeDO
=
new
NotificationLikeDO
();
notificationLikeDO
.
addItem
(
operatorId
);
NotificationEntity
build
=
NotificationEntity
.
builder
().
operatorId
(
operatorId
)
.
notificationId
(
uuidGenHelper
.
getUuidStr
())
.
messageType
(
NotificationTypeEnum
.
LIKE
.
getCode
())
.
notifiedUserId
(
notifierId
)
.
content
(
JsonUtil
.
toJson
(
notificationLikeDO
))
.
targetId
(
targetId
)
.
operatorId
(
operatorId
)
.
createTime
(
updateTime
)
.
updateTime
(
updateTime
)
.
build
();
insert
(
build
);
}
}
}
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
0112d403
...
...
@@ -7,6 +7,7 @@ import com.tanpu.common.exception.BizException;
import
com.tanpu.common.redis.RedisHelper
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.ThemeTypeEnum
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.TimesCountEntity
;
import
com.tanpu.community.dao.mapper.community.ThemeMapper
;
...
...
@@ -268,4 +269,10 @@ public class ThemeService {
.
collect
(
Collectors
.
toMap
(
TimesCountEntity:
:
getId
,
TimesCountEntity:
:
getTimes
));
}
public
List
<
ThemeEntity
>
queryAllForward
()
{
return
themeMapper
.
selectList
(
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getThemeType
,
ThemeTypeEnum
.
FORWARD
.
getCode
())
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByAsc
(
ThemeEntity:
:
getCreateTime
));
}
}
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