<?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.zongzhi.mapper.TcWorkDongtaiMapper">
    
    <resultMap type="TcWorkDongtai" id="TcWorkDongtaiResult">
        <result property="id"    column="id"    />
        <result property="areaId"    column="area_id"    />
        <result property="type"    column="type"    />
        <result property="name"    column="name"    />
        <result property="materialsName"    column="materials_name"    />
        <result property="fabuTime"    column="fabu_time"    />
        <result property="materialsFileName"    column="materials_file_name"    />
        <result property="materialsFileUrl"    column="materials_file_url"    />
        <result property="createId"    column="create_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateId"    column="update_id"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="isStatus"    column="is_status"    />
    </resultMap>

    <sql id="selectTcWorkDongtaiVo">
        select id, area_id, type,is_status, materials_name, name,fabu_time, materials_file_name, materials_file_url, create_id, create_by, create_time, update_id, update_by, update_time, remark from tc_work_dongtai
    </sql>

    <select id="selectTcWorkDongtaiList" parameterType="TcWorkDongtai" resultMap="TcWorkDongtaiResult">
        <include refid="selectTcWorkDongtaiVo"/>
        <where>  
            <if test="areaId != null "> and area_id = #{areaId}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="name != null  and name != ''"> and name = #{name}</if>
            <if test="materialsName != null  and materialsName != ''"> and materials_name like concat('%', #{materialsName}, '%')</if>
            <if test="fabuTime != null "> and fabu_time = #{fabuTime}</if>
            <if test="materialsFileName != null  and materialsFileName != ''"> and materials_file_name like concat('%', #{materialsFileName}, '%')</if>
            <if test="materialsFileUrl != null  and materialsFileUrl != ''"> and materials_file_url = #{materialsFileUrl}</if>
            <if test="createId != null "> and create_id = #{createId}</if>
            <if test="updateId != null "> and update_id = #{updateId}</if>
            <if test="isStatus != null "> and is_status = #{isStatus}</if>
        </where>
    </select>
    
    <select id="selectTcWorkDongtaiById" parameterType="Long" resultMap="TcWorkDongtaiResult">
        <include refid="selectTcWorkDongtaiVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcWorkDongtai" parameterType="TcWorkDongtai">
        insert into tc_work_dongtai
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="areaId != null">area_id,</if>
            <if test="type != null">type,</if>
            <if test="name != null">name,</if>
            <if test="materialsName != null">materials_name,</if>
            <if test="fabuTime != null">fabu_time,</if>
            <if test="materialsFileName != null">materials_file_name,</if>
            <if test="materialsFileUrl != null">materials_file_url,</if>
            <if test="createId != null">create_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateId != null">update_id,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="isStatus != null">is_status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="areaId != null">#{areaId},</if>
            <if test="type != null">#{type},</if>
            <if test="name != null">#{name},</if>
            <if test="materialsName != null">#{materialsName},</if>
            <if test="fabuTime != null">#{fabuTime},</if>
            <if test="materialsFileName != null">#{materialsFileName},</if>
            <if test="materialsFileUrl != null">#{materialsFileUrl},</if>
            <if test="createId != null">#{createId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateId != null">#{updateId},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="isStatus != null">#{isStatus},</if>
         </trim>
    </insert>

    <update id="updateTcWorkDongtai" parameterType="TcWorkDongtai">
        update tc_work_dongtai
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="type != null">type = #{type},</if>
            <if test="name != null">name = #{name},</if>
            <if test="materialsName != null">materials_name = #{materialsName},</if>
            <if test="fabuTime != null">fabu_time = #{fabuTime},</if>
            <if test="materialsFileName != null">materials_file_name = #{materialsFileName},</if>
            <if test="materialsFileUrl != null">materials_file_url = #{materialsFileUrl},</if>
            <if test="createId != null">create_id = #{createId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateId != null">update_id = #{updateId},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="isStatus != null">is_status=#{isStatus},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTcWorkDongtaiById" parameterType="Long">
        delete from tc_work_dongtai where id = #{id}
    </delete>

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