🐛 修复文章被删除,消息中心残留未读消息问题(如文章被删除则清除相关未读消息通知)
This commit is contained in:
parent
f2cd5f82e5
commit
cc23959133
@ -58,4 +58,12 @@ public interface NotificationMapper extends Mapper<Notification> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer readAllNotification(@Param("idUser") Integer idUser);
|
Integer readAllNotification(@Param("idUser") Integer idUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除相关未读消息
|
||||||
|
* @param dataId
|
||||||
|
* @param dataType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer deleteUnreadNotification(@Param("dataId") Integer dataId, @Param("dataType") String dataType);
|
||||||
}
|
}
|
||||||
|
@ -58,4 +58,12 @@ public interface NotificationService extends Service<Notification> {
|
|||||||
* @throws BaseApiException
|
* @throws BaseApiException
|
||||||
*/
|
*/
|
||||||
Integer readAllNotification() throws BaseApiException;
|
Integer readAllNotification() throws BaseApiException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除相关未读消息
|
||||||
|
* @param dataId
|
||||||
|
* @param dataType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer deleteUnreadNotification(Integer dataId, String dataType);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import com.rymcu.forest.entity.User;
|
|||||||
import com.rymcu.forest.lucene.service.LuceneService;
|
import com.rymcu.forest.lucene.service.LuceneService;
|
||||||
import com.rymcu.forest.mapper.ArticleMapper;
|
import com.rymcu.forest.mapper.ArticleMapper;
|
||||||
import com.rymcu.forest.service.ArticleService;
|
import com.rymcu.forest.service.ArticleService;
|
||||||
|
import com.rymcu.forest.service.NotificationService;
|
||||||
import com.rymcu.forest.service.TagService;
|
import com.rymcu.forest.service.TagService;
|
||||||
import com.rymcu.forest.service.UserService;
|
import com.rymcu.forest.service.UserService;
|
||||||
import com.rymcu.forest.util.*;
|
import com.rymcu.forest.util.*;
|
||||||
@ -43,6 +44,8 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Resource
|
@Resource
|
||||||
private LuceneService luceneService;
|
private LuceneService luceneService;
|
||||||
|
@Resource
|
||||||
|
private NotificationService notificationService;
|
||||||
|
|
||||||
@Value("${resource.domain}")
|
@Value("${resource.domain}")
|
||||||
private String domain;
|
private String domain;
|
||||||
@ -257,6 +260,8 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
articleMapper.deleteTagArticle(id);
|
articleMapper.deleteTagArticle(id);
|
||||||
// 删除文章内容表
|
// 删除文章内容表
|
||||||
articleMapper.deleteArticleContent(id);
|
articleMapper.deleteArticleContent(id);
|
||||||
|
// 删除相关未读消息
|
||||||
|
notificationService.deleteUnreadNotification(id, NotificationConstant.PostArticle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,4 +77,9 @@ public class NotificationServiceImpl extends AbstractService<Notification> imple
|
|||||||
public Integer readAllNotification() throws BaseApiException {
|
public Integer readAllNotification() throws BaseApiException {
|
||||||
return notificationMapper.readAllNotification(Objects.requireNonNull(UserUtils.getCurrentUserByToken()).getIdUser());
|
return notificationMapper.readAllNotification(Objects.requireNonNull(UserUtils.getCurrentUserByToken()).getIdUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer deleteUnreadNotification(Integer dataId, String dataType) {
|
||||||
|
return notificationMapper.deleteUnreadNotification(dataId, dataType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,9 @@
|
|||||||
<update id="readAllNotification">
|
<update id="readAllNotification">
|
||||||
update forest_notification set has_read = '1' where id_user = #{idUser} and has_read = '0'
|
update forest_notification set has_read = '1' where id_user = #{idUser} and has_read = '0'
|
||||||
</update>
|
</update>
|
||||||
|
<delete id="deleteUnreadNotification">
|
||||||
|
delete from forest_notification where has_read = '0' and data_id = #{dataId} and data_type = #{dataType}
|
||||||
|
</delete>
|
||||||
<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>
|
||||||
|
Loading…
Reference in New Issue
Block a user