rtos-mini-service4/mapper/target/classes/mappers/base/MessageMapper.xml

144 lines
4.3 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.haitongauto.mapper.base.MessageMapper">
<!--添加数据-->
<select id="insert" parameterType="com.haitongauto.models.pojo.Message" resultType="String">
insert into applet_message
(
id,
type,
type_content,
biz_id,
prc_id,
truck_number,
is_read,
create_time,
update_time,
is_del
)
values
(
#{id},
#{type},
#{type_content},
#{biz_id},
#{prc_id},
#{truck_number},
0,
current_timestamp,
current_timestamp,
0
)
returning id
</select>
<!--软删除-->
<update id="logicDel" parameterType="String">
update applet_message set is_del=1 where id=#{id}
</update>
<!--硬删除-->
<delete id="delete" parameterType="String">
delete from applet_message where id=#{id}
</delete>
<!--数据更新-->
<update id="update" parameterType="com.haitongauto.models.pojo.Message">
update applet_message
<set>
<if test="id != null and id != ''">
id = #{id},
</if>
<if test="type != null">
type = #{type},
</if>
<if test="type_content != null and type_content != ''">
type_content = #{type_content},
</if>
<if test="biz_id != null and biz_id != ''">
biz_id = #{biz_id},
</if>
<if test="prc_id != null and prc_id != ''">
prc_id = #{prc_id},
</if>
<if test="truck_number != null and truck_number != ''">
truck_number = #{truck_number},
</if>
<if test="is_read != null">
is_read = #{is_read},
</if>
<if test="create_time != null and create_time != ''">
create_time = #{create_time}::timestamp,
</if>
<if test="is_del != null">
is_del = #{is_del},
</if>
update_time = current_timestamp,
</set>
where id=#{id}
<!-- where type = #{type}-->
<!-- and biz_id = #{biz_id}-->
</update>
<!--指定Id的记录-->
<select id="getById" parameterType="String" resultType="com.haitongauto.models.pojo.Message">
select *
from applet_message
where id=#{id} and is_del=0
</select>
<!--数据列表-->
<select id="getList" resultType="com.haitongauto.models.pojo.Message">
select
id,
type,
biz_id,
truck_number,
is_read,
create_time,
update_time,
is_del
from applet_message
where is_del=0
order by create_time desc
</select>
<select id="getLastMessageByTypeAndBizId" resultType="com.haitongauto.models.pojo.Message">
select *
from applet_message
where type=#{type}
and biz_id=#{biz_id}
limit 1
</select>
<select id="getMessageListByTruckNumber" resultType="com.haitongauto.models.pojo.Message">
select *
from applet_message
where is_del=0 and
truck_number IN
<foreach item="truck_number" collection="list" open="(" separator="," close=")">
#{truck_number}
</foreach>
order by create_time desc
</select>
<select id="getUnReadMessageListByTruckNumber" resultType="com.haitongauto.models.pojo.Message">
select *
from applet_message
where is_del=0 and is_read=0
and truck_number IN
<foreach item="truck_number" collection="list" open="(" separator="," close=")">
#{truck_number}
</foreach>
order by create_time desc
</select>
<select id="sumUnread" resultType="java.lang.Integer">
select count(*)
from applet_message
where is_del=0 and is_read=0 and
truck_number IN
<foreach item="truck_number" collection="list" open="(" separator="," close=")">
#{truck_number}
</foreach>
</select>
</mapper>