<?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.TcNetworkVolunteerMapper">
    
    <resultMap type="TcNetworkVolunteer" id="TcNetworkVolunteerResult">
        <result property="id"    column="id"    />
        <result property="areaId"    column="area_id"    />
        <result property="type"    column="type"    />
        <result property="name"    column="name"    />
        <result property="age"    column="age"    />
        <result property="content"    column="content"    />
        <result property="unit"    column="unit"    />
        <result property="duty"    column="duty"    />
        <result property="phoneNum"    column="phone_num"    />
        <result property="createId"    column="create_id"    />
        <result property="createBy"    column="create_by"    />
        <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="selectTcNetworkVolunteerVo">
        select id, area_id, type, name, age, content, unit, duty, phone_num, create_id, create_by, update_id, update_by, update_time, remark from tc_network_volunteer
    </sql>

    <select id="selectTcNetworkVolunteerList" parameterType="TcNetworkVolunteer" resultMap="TcNetworkVolunteerResult">
        <include refid="selectTcNetworkVolunteerVo"/>
        <where>  
            <if test="areaId != null "> and area_id = #{areaId}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="age != null "> and age = #{age}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="unit != null  and unit != ''"> and unit = #{unit}</if>
            <if test="duty != null  and duty != ''"> and duty = #{duty}</if>
            <if test="phoneNum != null "> and phone_num = #{phoneNum}</if>
            <if test="createId != null "> and create_id = #{createId}</if>
            <if test="updateId != null "> and update_id = #{updateId}</if>
        </where>
    </select>
    
    <select id="selectTcNetworkVolunteerById" parameterType="Long" resultMap="TcNetworkVolunteerResult">
        <include refid="selectTcNetworkVolunteerVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcNetworkVolunteer" parameterType="TcNetworkVolunteer" useGeneratedKeys="true" keyProperty="id">
        insert into tc_network_volunteer
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaId != null">area_id,</if>
            <if test="type != null">type,</if>
            <if test="name != null">name,</if>
            <if test="age != null">age,</if>
            <if test="content != null">content,</if>
            <if test="unit != null">unit,</if>
            <if test="duty != null">duty,</if>
            <if test="phoneNum != null">phone_num,</if>
            <if test="createId != null">create_id,</if>
            <if test="createBy != null">create_by,</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="type != null">#{type},</if>
            <if test="name != null">#{name},</if>
            <if test="age != null">#{age},</if>
            <if test="content != null">#{content},</if>
            <if test="unit != null">#{unit},</if>
            <if test="duty != null">#{duty},</if>
            <if test="phoneNum != null">#{phoneNum},</if>
            <if test="createId != null">#{createId},</if>
            <if test="createBy != null">#{createBy},</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="updateTcNetworkVolunteer" parameterType="TcNetworkVolunteer">
        update tc_network_volunteer
        <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="age != null">age = #{age},</if>
            <if test="content != null">content = #{content},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="duty != null">duty = #{duty},</if>
            <if test="phoneNum != null">phone_num = #{phoneNum},</if>
            <if test="createId != null">create_id = #{createId},</if>
            <if test="createBy != null">create_by = #{createBy},</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="deleteTcNetworkVolunteerById" parameterType="Long">
        delete from tc_network_volunteer where id = #{id}
    </delete>

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