Files
aida_back/src/main/resources/mapper/primary/NotificationMapper.xml

69 lines
1.9 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ai.da.mapper.primary.NotificationMapper">
<select id="getTypeCount" resultType="java.util.Map">
SELECT type, count(id) as count
FROM `t_notification`
WHERE receiver_id = #{receiverId}
AND is_read = 0
AND is_deleted = 0
GROUP BY type
</select>
<select id="getUniqueLikeAndFollow" resultType="com.ai.da.mapper.primary.entity.Notification">
SELECT *
FROM `t_notification`
WHERE type = #{type}
AND sender_id = #{senderId}
AND receiver_id = #{receiverId}
<if test="type == 'like'">
AND portfolio_id = #{portfolioId}
</if>
LIMIT 1
</select>
<update id="updateUniqueLikeAndFollow" >
UPDATE `t_notification`
SET
is_read = 0,
create_time = #{time},
update_time = #{time},
is_deleted = 0
WHERE id = #{id}
</update>
<update id="deleteNotification" >
UPDATE `t_notification`
SET
update_time = #{time},
is_deleted = 1
WHERE id = #{id}
</update>
<update id="setPersonalNotificationAllRead">
update `t_notification`
SET
is_read = 1,
update_time = #{time}
WHERE type = #{type}
AND receiver_id = #{receiverId}
AND is_read = 0
AND is_deleted = 0
</update>
<select id="getUnreadSysNotification" resultType="Long">
SELECT id
FROM `t_notification`
WHERE type = 'system'
AND id NOT IN (
SELECT system_notification_id
FROM `t_sys_notification_read_status`
WHERE account_id = #{accountId}
)
AND create_time > #{createTime}
</select>
</mapper>