🐛 消息通知分页问题修复
This commit is contained in:
parent
b7437b01a1
commit
eacb753e55
@ -1,6 +1,7 @@
|
|||||||
package com.rymcu.forest.mapper;
|
package com.rymcu.forest.mapper;
|
||||||
|
|
||||||
import com.rymcu.forest.core.mapper.Mapper;
|
import com.rymcu.forest.core.mapper.Mapper;
|
||||||
|
import com.rymcu.forest.dto.NotificationDTO;
|
||||||
import com.rymcu.forest.entity.Notification;
|
import com.rymcu.forest.entity.Notification;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ public interface NotificationMapper extends Mapper<Notification> {
|
|||||||
* @param idUser
|
* @param idUser
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Notification> selectNotifications(@Param("idUser") Integer idUser);
|
List<NotificationDTO> selectNotifications(@Param("idUser") Integer idUser);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取消息数据
|
* 获取消息数据
|
||||||
|
@ -49,13 +49,12 @@ public class NotificationServiceImpl extends AbstractService<Notification> imple
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NotificationDTO> findNotifications(Integer idUser) {
|
public List<NotificationDTO> findNotifications(Integer idUser) {
|
||||||
List<Notification> list = notificationMapper.selectNotifications(idUser);
|
List<NotificationDTO> list = notificationMapper.selectNotifications(idUser);
|
||||||
List<NotificationDTO> notifications = new ArrayList<>();
|
|
||||||
list.forEach(notification -> {
|
list.forEach(notification -> {
|
||||||
NotificationDTO notificationDTO = genNotification(notification);
|
NotificationDTO notificationDTO = genNotification(notification);
|
||||||
// 判断关联数据是否已删除
|
// 判断关联数据是否已删除
|
||||||
if (Objects.nonNull(notificationDTO.getAuthor())) {
|
if (Objects.nonNull(notificationDTO.getAuthor())) {
|
||||||
notifications.add(notificationDTO);
|
BeanCopierUtil.copy(notificationDTO, notification);
|
||||||
} else {
|
} else {
|
||||||
// 关联数据已删除,且未读
|
// 关联数据已删除,且未读
|
||||||
if (unRead.equals(notification.getHasRead())) {
|
if (unRead.equals(notification.getHasRead())) {
|
||||||
@ -66,10 +65,10 @@ public class NotificationServiceImpl extends AbstractService<Notification> imple
|
|||||||
dto.setDataType("-1");
|
dto.setDataType("-1");
|
||||||
dto.setHasRead("1");
|
dto.setHasRead("1");
|
||||||
dto.setCreatedTime(notification.getCreatedTime());
|
dto.setCreatedTime(notification.getCreatedTime());
|
||||||
notifications.add(dto);
|
BeanCopierUtil.copy(dto, notification);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return notifications;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NotificationDTO genNotification(Notification notification) {
|
private NotificationDTO genNotification(Notification notification) {
|
||||||
|
@ -10,6 +10,15 @@
|
|||||||
<result column="has_read" property="hasRead"></result>
|
<result column="has_read" property="hasRead"></result>
|
||||||
<result column="created_time" property="createdTime"></result>
|
<result column="created_time" property="createdTime"></result>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
<resultMap id="DTOResultMapper" type="com.rymcu.forest.dto.NotificationDTO">
|
||||||
|
<id column="id" property="idNotification"></id>
|
||||||
|
<result column="id_user" property="idUser"></result>
|
||||||
|
<result column="data_type" property="dataType"></result>
|
||||||
|
<result column="data_id" property="dataId"></result>
|
||||||
|
<result column="data_summary" property="dataSummary"></result>
|
||||||
|
<result column="has_read" property="hasRead"></result>
|
||||||
|
<result column="created_time" property="createdTime"></result>
|
||||||
|
</resultMap>
|
||||||
<insert id="insertNotification">
|
<insert id="insertNotification">
|
||||||
insert into forest_notification (id_user, data_type, data_id, data_summary, created_time) values (#{idUser}, #{dataType}, #{dataId}, #{dataSummary}, sysdate())
|
insert into forest_notification (id_user, data_type, data_id, data_summary, created_time) values (#{idUser}, #{dataType}, #{dataId}, #{dataSummary}, sysdate())
|
||||||
</insert>
|
</insert>
|
||||||
@ -19,7 +28,7 @@
|
|||||||
<select id="selectUnreadNotifications" resultMap="BaseResultMapper">
|
<select id="selectUnreadNotifications" resultMap="BaseResultMapper">
|
||||||
select * from forest_notification where has_read = '0' and id_user = #{idUser} order by created_time desc
|
select * from forest_notification where has_read = '0' and id_user = #{idUser} order by created_time desc
|
||||||
</select>
|
</select>
|
||||||
<select id="selectNotifications" resultMap="BaseResultMapper">
|
<select id="selectNotifications" resultMap="DTOResultMapper">
|
||||||
select * from forest_notification where id_user = #{idUser} order by created_time desc
|
select * from forest_notification where id_user = #{idUser} order by created_time desc
|
||||||
</select>
|
</select>
|
||||||
<select id="selectNotification" resultMap="BaseResultMapper">
|
<select id="selectNotification" resultMap="BaseResultMapper">
|
||||||
|
Loading…
Reference in New Issue
Block a user