From eacb753e55ea769f05bcf83a8cd7f18d3b8b2313 Mon Sep 17 00:00:00 2001 From: ronger Date: Wed, 24 Feb 2021 09:08:56 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rymcu/forest/mapper/NotificationMapper.java | 3 ++- .../forest/service/impl/NotificationServiceImpl.java | 9 ++++----- src/main/java/mapper/NotificationMapper.xml | 11 ++++++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/rymcu/forest/mapper/NotificationMapper.java b/src/main/java/com/rymcu/forest/mapper/NotificationMapper.java index 8a3dd6f..2ae27ad 100644 --- a/src/main/java/com/rymcu/forest/mapper/NotificationMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/NotificationMapper.java @@ -1,6 +1,7 @@ package com.rymcu.forest.mapper; import com.rymcu.forest.core.mapper.Mapper; +import com.rymcu.forest.dto.NotificationDTO; import com.rymcu.forest.entity.Notification; import org.apache.ibatis.annotations.Param; @@ -23,7 +24,7 @@ public interface NotificationMapper extends Mapper { * @param idUser * @return */ - List selectNotifications(@Param("idUser") Integer idUser); + List selectNotifications(@Param("idUser") Integer idUser); /** * 获取消息数据 diff --git a/src/main/java/com/rymcu/forest/service/impl/NotificationServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/NotificationServiceImpl.java index 7aef442..4883182 100644 --- a/src/main/java/com/rymcu/forest/service/impl/NotificationServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/NotificationServiceImpl.java @@ -49,13 +49,12 @@ public class NotificationServiceImpl extends AbstractService imple @Override public List findNotifications(Integer idUser) { - List list = notificationMapper.selectNotifications(idUser); - List notifications = new ArrayList<>(); + List list = notificationMapper.selectNotifications(idUser); list.forEach(notification -> { NotificationDTO notificationDTO = genNotification(notification); // 判断关联数据是否已删除 if (Objects.nonNull(notificationDTO.getAuthor())) { - notifications.add(notificationDTO); + BeanCopierUtil.copy(notificationDTO, notification); } else { // 关联数据已删除,且未读 if (unRead.equals(notification.getHasRead())) { @@ -66,10 +65,10 @@ public class NotificationServiceImpl extends AbstractService imple dto.setDataType("-1"); dto.setHasRead("1"); dto.setCreatedTime(notification.getCreatedTime()); - notifications.add(dto); + BeanCopierUtil.copy(dto, notification); } }); - return notifications; + return list; } private NotificationDTO genNotification(Notification notification) { diff --git a/src/main/java/mapper/NotificationMapper.xml b/src/main/java/mapper/NotificationMapper.xml index 81fa9b0..80ef662 100644 --- a/src/main/java/mapper/NotificationMapper.xml +++ b/src/main/java/mapper/NotificationMapper.xml @@ -10,6 +10,15 @@ + + + + + + + + + insert into forest_notification (id_user, data_type, data_id, data_summary, created_time) values (#{idUser}, #{dataType}, #{dataId}, #{dataSummary}, sysdate()) @@ -19,7 +28,7 @@ - select * from forest_notification where id_user = #{idUser} order by created_time desc