<?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.mmc.iuav.user.dao.fdd.SealManageDao">
    <insert id="insertSealInfo">
        insert into seal_info (seal_name, signature_id, seal_url, union_id)
        values (#{sealName}, #{signatureId}, #{sealUrl}, #{unionId})
    </insert>
    <update id="updateSealStatusById">
        update seal_info set seal_status = 0
        where id in
        <foreach collection="list" separator="," index="index" item="item" open="(" close=")">
            #{item}
        </foreach>
    </update>
    <update id="updateSealStatusBySignatureId">
        update seal_info
        set seal_status = 1
        where signature_id = #{signatureId}
    </update>
    <update id="updateSealName">
        update seal_info
        set seal_name = #{sealName}
        where signature_id = #{signatureId}
          and union_id = #{unionId}
    </update>
    <delete id="deletedSealInfo">
        delete
        from seal_info
        where signature_id = #{signatureId}
    </delete>
    <select id="countSealInfo" resultType="java.lang.Integer">
        SELECT
        count(*)
        FROM seal_info
        <where>
            union_id = #{uId}
            <if test="startTime != null and startTime != '' ">
                and create_time &gt;= STR_TO_DATE(#{startTime},'%Y-%m-%d %H:%i:%s')
            </if>
            <if test="endTime != null and endTime != '' ">
                and create_time &lt;= STR_TO_DATE(#{endTime},'%Y-%m-%d %H:%i:%s')
            </if>
        </where>
    </select>
    <select id="getSealInfoList" resultType="com.mmc.iuav.user.entity.fdd.SealInfoDO">
        SELECT id,
        seal_name,
        signature_id,
        union_id,
        seal_status,
        seal_url,
        create_time
        FROM seal_info
        <where>
            union_id = #{uId}
            <if test="startTime != null and startTime != '' ">
                and create_time &gt;= STR_TO_DATE(#{startTime},'%Y-%m-%d %H:%i:%s')
            </if>
            <if test="endTime != null and endTime != '' ">
                and create_time &lt;= STR_TO_DATE(#{endTime},'%Y-%m-%d %H:%i:%s')
            </if>
        </where>
        ORDER BY seal_status desc ,create_time desc
        limit #{pageNo}, #{pageSize}
    </select>
    <select id="getSealInfoListByUnionId" resultType="com.mmc.iuav.user.entity.fdd.SealInfoDO">
        SELECT id,
               seal_name,
               signature_id,
               union_id,
               seal_status,
               seal_url,
               create_time
        FROM seal_info
        where union_id = #{uId}
    </select>
</mapper>