<?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.TcZhongdianWorkMapper">
    
    <resultMap type="TcZhongdianWork" id="TcZhongdianWorkResult">
        <result property="id"    column="id"    />
        <result property="areaId"    column="area_id"    />
        <result property="unitName"    column="unit_name"    />
        <result property="projectName"    column="project_name"    />
        <result property="projectContent"    column="project_content"    />
        <result property="projectType"    column="project_type"    />
        <result property="projectLinkMan"    column="project_link_man"    />
        <result property="phoneNum"    column="phone_num"    />
        <result property="linkManDuty"    column="link_man_duty"    />
        <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"    />
    </resultMap>

    <sql id="selectTcZhongdianWorkVo">
        select id, area_id, unit_name, project_name, project_content, project_type, project_link_man, phone_num, link_man_duty, create_id, create_by, create_time, update_id, update_by, update_time, remark from tc_zhongdian_work
    </sql>

    <select id="selectTcZhongdianWorkList" parameterType="TcZhongdianWork" resultMap="TcZhongdianWorkResult">
        <include refid="selectTcZhongdianWorkVo"/>
        <where>  
            <if test="areaId != null "> and area_id = #{areaId}</if>
            <if test="unitName != null  and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
            <if test="projectName != null  and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
            <if test="projectContent != null  and projectContent != ''"> and project_content = #{projectContent}</if>
            <if test="projectType != null "> and project_type = #{projectType}</if>
            <if test="projectLinkMan != null  and projectLinkMan != ''"> and project_link_man = #{projectLinkMan}</if>
            <if test="phoneNum != null  and phoneNum != ''"> and phone_num = #{phoneNum}</if>
            <if test="linkManDuty != null  and linkManDuty != ''"> and link_man_duty = #{linkManDuty}</if>
            <if test="createId != null "> and create_id = #{createId}</if>
            <if test="updateId != null "> and update_id = #{updateId}</if>
        </where>
    </select>
    
    <select id="selectTcZhongdianWorkById" parameterType="Long" resultMap="TcZhongdianWorkResult">
        <include refid="selectTcZhongdianWorkVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcZhongdianWork" parameterType="TcZhongdianWork" useGeneratedKeys="true" keyProperty="id">
        insert into tc_zhongdian_work
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaId != null">area_id,</if>
            <if test="unitName != null">unit_name,</if>
            <if test="projectName != null">project_name,</if>
            <if test="projectContent != null">project_content,</if>
            <if test="projectType != null">project_type,</if>
            <if test="projectLinkMan != null">project_link_man,</if>
            <if test="phoneNum != null">phone_num,</if>
            <if test="linkManDuty != null">link_man_duty,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="areaId != null">#{areaId},</if>
            <if test="unitName != null">#{unitName},</if>
            <if test="projectName != null">#{projectName},</if>
            <if test="projectContent != null">#{projectContent},</if>
            <if test="projectType != null">#{projectType},</if>
            <if test="projectLinkMan != null">#{projectLinkMan},</if>
            <if test="phoneNum != null">#{phoneNum},</if>
            <if test="linkManDuty != null">#{linkManDuty},</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>
         </trim>
    </insert>

    <update id="updateTcZhongdianWork" parameterType="TcZhongdianWork">
        update tc_zhongdian_work
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="unitName != null">unit_name = #{unitName},</if>
            <if test="projectName != null">project_name = #{projectName},</if>
            <if test="projectContent != null">project_content = #{projectContent},</if>
            <if test="projectType != null">project_type = #{projectType},</if>
            <if test="projectLinkMan != null">project_link_man = #{projectLinkMan},</if>
            <if test="phoneNum != null">phone_num = #{phoneNum},</if>
            <if test="linkManDuty != null">link_man_duty = #{linkManDuty},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTcZhongdianWorkById" parameterType="Long">
        delete from tc_zhongdian_work where id = #{id}
    </delete>

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