<?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.ruoyi.system.mapper.ClewImgMapper">

    <resultMap type="ClewImg" id="ClewImgResult">
        <result property="id"    column="id"    />
        <result property="imgUrl"    column="img_url"    />
        <result property="sourceApp"    column="source_app"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectClewImgVo">
        select id, img_url, source_app, create_time, create_by, update_time, update_by, remark from clew_img
    </sql>

    <select id="selectClewImgList" parameterType="ClewImg" resultMap="ClewImgResult">
        <include refid="selectClewImgVo"/>
        <where>
            <if test="imgUrl != null  and imgUrl != ''"> and img_url = #{imgUrl}</if>
            <if test="sourceApp != null"> and source_app = #{sourceApp}</if>
        </where>
    </select>

    <select id="selectClewImgById" parameterType="Long" resultMap="ClewImgResult">
        <include refid="selectClewImgVo"/>
        where id = #{id}
    </select>

    <insert id="insertClewImg" parameterType="ClewImg" useGeneratedKeys="true" keyProperty="id">
        insert into clew_img
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="imgUrl != null">img_url,</if>
            <if test="sourceApp != null">source_app,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="imgUrl != null">#{imgUrl},</if>
            <if test="sourceApp != null">#{sourceApp},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateClewImg" parameterType="ClewImg">
        update clew_img
        <trim prefix="SET" suffixOverrides=",">
            <if test="imgUrl != null">img_url = #{imgUrl},</if>
            <if test="sourceApp != null">source_app = #{sourceApp},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteClewImgById" parameterType="Long">
        delete from clew_img where id = #{id}
    </delete>

    <delete id="deleteClewImgByIds" parameterType="String">
        delete from clew_img where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>