<?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.fastbee.rechargecard.mapper.NgInformationVillageKeeperMapper">

    <resultMap type="NgInformationVillageKeeper" id="NgInformationVillageKeeperResult">
        <result property="villageKeeperId"    column="village_keeper_id"    />
        <result property="officialId"    column="official_id"    />
        <result property="name"    column="name"    />
        <result property="position"    column="position"    />
        <result property="belongingRegion"    column="belonging_region"    />
        <result property="gender"    column="gender"    />
        <result property="age"    column="age"    />
        <result property="partyMembership"    column="party_membership"    />
        <result property="contactInformation"    column="contact_information"    />
        <result property="appointmentDate"    column="appointment_date"    />
        <result property="educationBackground"    column="education_background"    />
        <result property="workExperience"    column="work_experience"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectNgInformationVillageKeeperVo">
        select village_keeper_id, official_id, name, position, belonging_region, gender, age, party_membership, contact_information, appointment_date, education_background, work_experience, remark, create_time, update_time, create_by, update_by from ng_Information_village_keeper
    </sql>

    <select id="selectNgInformationVillageKeeperList" parameterType="NgInformationVillageKeeper" resultMap="NgInformationVillageKeeperResult">
        <include refid="selectNgInformationVillageKeeperVo"/>
        <where>
            <if test="villageKeeperId != null "> and village_keeper_id = #{villageKeeperId}</if>
            <if test="officialId != null  and officialId != ''"> and official_id = #{officialId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="position != null  and position != ''"> and position = #{position}</if>
            <if test="belongingRegion != null  and belongingRegion != ''"> and belonging_region = #{belongingRegion}</if>
            <if test="gender != null  and gender != ''"> and gender = #{gender}</if>
            <if test="age != null "> and age = #{age}</if>
            <if test="partyMembership != null  and partyMembership != ''"> and party_membership = #{partyMembership}</if>
            <if test="contactInformation != null  and contactInformation != ''"> and contact_information = #{contactInformation}</if>
            <if test="appointmentDate != null "> and appointment_date = #{appointmentDate}</if>
            <if test="educationBackground != null  and educationBackground != ''"> and education_background = #{educationBackground}</if>
            <if test="workExperience != null  and workExperience != ''"> and work_experience = #{workExperience}</if>
        </where>
    </select>

    <select id="selectNgInformationVillageKeeperByVillageKeeperId" parameterType="Long" resultMap="NgInformationVillageKeeperResult">
        <include refid="selectNgInformationVillageKeeperVo"/>
        where village_keeper_id = #{villageKeeperId}
    </select>

    <insert id="insertNgInformationVillageKeeper" parameterType="NgInformationVillageKeeper">
        insert into ng_Information_village_keeper
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="villageKeeperId != null">village_keeper_id,</if>
            <if test="officialId != null">official_id,</if>
            <if test="name != null">name,</if>
            <if test="position != null">position,</if>
            <if test="belongingRegion != null">belonging_region,</if>
            <if test="gender != null">gender,</if>
            <if test="age != null">age,</if>
            <if test="partyMembership != null">party_membership,</if>
            <if test="contactInformation != null">contact_information,</if>
            <if test="appointmentDate != null">appointment_date,</if>
            <if test="educationBackground != null">education_background,</if>
            <if test="workExperience != null">work_experience,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="villageKeeperId != null">#{villageKeeperId},</if>
            <if test="officialId != null">#{officialId},</if>
            <if test="name != null">#{name},</if>
            <if test="position != null">#{position},</if>
            <if test="belongingRegion != null">#{belongingRegion},</if>
            <if test="gender != null">#{gender},</if>
            <if test="age != null">#{age},</if>
            <if test="partyMembership != null">#{partyMembership},</if>
            <if test="contactInformation != null">#{contactInformation},</if>
            <if test="appointmentDate != null">#{appointmentDate},</if>
            <if test="educationBackground != null">#{educationBackground},</if>
            <if test="workExperience != null">#{workExperience},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
        </trim>
    </insert>

    <update id="updateNgInformationVillageKeeper" parameterType="NgInformationVillageKeeper">
        update ng_Information_village_keeper
        <trim prefix="SET" suffixOverrides=",">
            <if test="officialId != null">official_id = #{officialId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="position != null">position = #{position},</if>
            <if test="belongingRegion != null">belonging_region = #{belongingRegion},</if>
            <if test="gender != null">gender = #{gender},</if>
            <if test="age != null">age = #{age},</if>
            <if test="partyMembership != null">party_membership = #{partyMembership},</if>
            <if test="contactInformation != null">contact_information = #{contactInformation},</if>
            <if test="appointmentDate != null">appointment_date = #{appointmentDate},</if>
            <if test="educationBackground != null">education_background = #{educationBackground},</if>
            <if test="workExperience != null">work_experience = #{workExperience},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where village_keeper_id = #{villageKeeperId}
    </update>

    <delete id="deleteNgInformationVillageKeeperByVillageKeeperId" parameterType="Long">
        delete from ng_Information_village_keeper where village_keeper_id = #{villageKeeperId}
    </delete>

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