Commit 8efa7d41 authored by 刘基明's avatar 刘基明

圈子消息通知-fix

parent 67529872
...@@ -10,6 +10,7 @@ import com.tanpu.community.manager.NotificationManager; ...@@ -10,6 +10,7 @@ import com.tanpu.community.manager.NotificationManager;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -21,7 +22,7 @@ import java.util.List; ...@@ -21,7 +22,7 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/notification") @RequestMapping("/api/notification")
public class NotificationController { public class NotificationController {
@Autowired @Autowired
...@@ -32,7 +33,7 @@ public class NotificationController { ...@@ -32,7 +33,7 @@ public class NotificationController {
@AuthLogin @AuthLogin
@PostMapping("/query") @PostMapping("/query")
@ResponseBody @ResponseBody
public CommonResp<List<ThemeNotifyQo>> query(NotifyQueryReq req){ public CommonResp<List<ThemeNotifyQo>> query(@RequestBody NotifyQueryReq req){
List<ThemeNotifyQo> query = notificationManager.queryList(req, userHolder.getUserId()); List<ThemeNotifyQo> query = notificationManager.queryList(req, userHolder.getUserId());
return CommonResp.success(query); return CommonResp.success(query);
......
...@@ -8,6 +8,7 @@ import com.tanpu.community.dao.entity.NotificationForwardDO; ...@@ -8,6 +8,7 @@ import com.tanpu.community.dao.entity.NotificationForwardDO;
import com.tanpu.community.dao.entity.NotificationLikeDO; import com.tanpu.community.dao.entity.NotificationLikeDO;
import com.tanpu.community.dao.entity.community.NotificationEntity; 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.apache.commons.lang3.StringUtils;
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 org.springframework.transaction.annotation.Transactional;
...@@ -56,6 +57,7 @@ public class NotificationService { ...@@ -56,6 +57,7 @@ public class NotificationService {
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())
.eq(NotificationEntity::getTargetId,targetId)
.eq(NotificationEntity::getNotifiedUserId, notifierId)); .eq(NotificationEntity::getNotifiedUserId, notifierId));
if (entity!=null){ if (entity!=null){
NotificationLikeDO notificationLikeDO = JsonUtil.toBean(entity.getContent(), NotificationLikeDO.class); NotificationLikeDO notificationLikeDO = JsonUtil.toBean(entity.getContent(), NotificationLikeDO.class);
...@@ -92,14 +94,16 @@ public class NotificationService { ...@@ -92,14 +94,16 @@ public class NotificationService {
public List<NotificationEntity> query(String userId, Integer type, String lastId, Integer pageSize){ public List<NotificationEntity> query(String userId, Integer type, String lastId, Integer pageSize){
NotificationEntity lastOne = notificationMapper.selectOne(new LambdaQueryWrapper<NotificationEntity>()
.eq(NotificationEntity::getNotificationId, lastId));
LambdaQueryWrapper<NotificationEntity> queryWrapper = new LambdaQueryWrapper<NotificationEntity>() LambdaQueryWrapper<NotificationEntity> queryWrapper = new LambdaQueryWrapper<NotificationEntity>()
.eq(NotificationEntity::getNotifiedUserId, userId) .eq(NotificationEntity::getNotifiedUserId, userId)
.lt(NotificationEntity::getUpdateTime, lastOne.getCreateTime())
.last("limit " + pageSize); .last("limit " + pageSize);
if (StringUtils.isNotBlank(lastId)){
NotificationEntity lastOne = notificationMapper.selectOne(new LambdaQueryWrapper<NotificationEntity>()
.eq(NotificationEntity::getNotificationId, lastId));
queryWrapper.lt(NotificationEntity::getUpdateTime, lastOne.getCreateTime());
}
if (!NotificationTypeEnum.ALL.getCode().equals(type)){ if (!NotificationTypeEnum.ALL.getCode().equals(type)){
queryWrapper.eq(NotificationEntity::getMessageType,type); queryWrapper.eq(NotificationEntity::getMessageType,type);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment