<?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.ClewMaterialMapper">

    <resultMap type="ClewMaterial" id="ClewMaterialResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="imgUrl"    column="img_url"    />
        <result property="videoImg"    column="video_img"    />
        <result property="labels"    column="labels"    />
        <result property="detail"    column="detail"    />
        <result property="applyNum"    column="apply_num"    />
        <result property="clewContent"    column="clew_content"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectClewMaterialVo">
        select id, title, img_url, video_img, labels, detail, apply_num, clew_content, create_by, create_time, update_by, update_time from clew_material
    </sql>

    <select id="selectClewMaterialList" parameterType="ClewMaterial" resultMap="ClewMaterialResult">
        <include refid="selectClewMaterialVo"/>
        <where>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="imgUrl != null  and imgUrl != ''"> and img_url = #{imgUrl}</if>
            <if test="videoImg != null  and videoImg != ''"> and video_img = #{videoImg}</if>
            <if test="labels != null  and labels != ''"> and labels = #{labels}</if>
            <if test="applyNum != null  and applyNum != ''"> and apply_num = #{applyNum}</if>
            <if test="clewContent != null  and clewContent != ''"> and clew_content = #{clewContent}</if>
        </where>
    </select>

    <select id="selectClewMaterialById" parameterType="Long" resultMap="ClewMaterialResult">
        <include refid="selectClewMaterialVo"/>
        where id = #{id}
    </select>

    <insert id="insertClewMaterial" parameterType="ClewMaterial" useGeneratedKeys="true" keyProperty="id">
        insert into clew_material
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,</if>
            <if test="imgUrl != null">img_url,</if>
            <if test="videoImg != null">video_img,</if>
            <if test="labels != null">labels,</if>
            <if test="detail != null">detail,</if>
            <if test="applyNum != null">apply_num,</if>
            <if test="clewContent != null">clew_content,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},</if>
            <if test="imgUrl != null">#{imgUrl},</if>
            <if test="videoImg != null">#{videoImg},</if>
            <if test="labels != null">#{labels},</if>
            <if test="detail != null">#{detail},</if>
            <if test="applyNum != null">#{applyNum},</if>
            <if test="clewContent != null">#{clewContent},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateClewMaterial" parameterType="ClewMaterial">
        update clew_material
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="imgUrl != null">img_url = #{imgUrl},</if>
            <if test="videoImg != null">video_img = #{videoImg},</if>
            <if test="labels != null">labels = #{labels},</if>
            <if test="detail != null">detail = #{detail},</if>
            <if test="applyNum != null">apply_num = #{applyNum},</if>
            <if test="clewContent != null">clew_content = #{clewContent},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteClewMaterialById" parameterType="Long">
        delete from clew_material where id = #{id}
    </delete>

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

</mapper>