<?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">
<!--suppress SqlDialectInspection -->
<mapper namespace="com.xhpc.charging.station.mapper.XhpcImgMapper">

    <insert id="insert">
        INSERT INTO xhpc_img(url, terminal_id)
        VALUES (#{imgUrl}, #{terminalId})
    </insert>
    <update id="updateDelFlagByTerminalId">
        UPDATE xhpc_img
        SET del_flag = 2
        WHERE terminal_id = #{terminalId}
    </update>

    <select id="selectImgUrlByTerminal_id" resultType="map">
        SELECT url,terminal_id as terminalId
        FROM xhpc_img
        where 1=1
        <if test="list!=null">
            and terminal_id in
            <foreach collection="list" item="terminalId" open="(" close=")" separator=",">
                #{terminalId}
            </foreach>
        </if>
    </select>
    <select id="selectByTerminalId" resultType="com.xhpc.charging.station.pojo.XhpcImg">
        select
        img_id id,
        url url,
        status status,
        del_flag delFlag,
        create_time createTime,
        create_by createBy,
        update_time updateTime,
        update_by updateBy,
        remark remark,
        terminal_id terminalId
        from xhpc_img
        where
        del_flag = 0
        and terminal_id in
        <foreach collection="list" separator="," item="terminalId" open="(" close=")">
            #{terminalId}
        </foreach>
    </select>

</mapper>
