37 lines
2.2 KiB
XML
37 lines
2.2 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.rymcu.forest.mapper.NotificationMapper">
|
|
<resultMap id="BaseResultMapper" type="com.rymcu.forest.entity.Notification">
|
|
<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>
|
|
<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 into forest_notification (id_user, data_type, data_id, data_summary, created_time) values (#{idUser}, #{dataType}, #{dataId}, #{dataSummary}, sysdate())
|
|
</insert>
|
|
<update id="readNotification">
|
|
update forest_notification set has_read = '1' where id = #{id}
|
|
</update>
|
|
<select id="selectUnreadNotifications" resultMap="BaseResultMapper">
|
|
select * from forest_notification where has_read = '0' and id_user = #{idUser} order by created_time desc
|
|
</select>
|
|
<select id="selectNotifications" resultMap="DTOResultMapper">
|
|
select * from forest_notification where id_user = #{idUser} order by has_read,created_time desc
|
|
</select>
|
|
<select id="selectNotification" resultMap="BaseResultMapper">
|
|
select * from forest_notification where id_user = #{idUser} and data_id = #{dataId} and data_type = #{dataType}
|
|
</select>
|
|
</mapper> |