<?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.srs.stureg.mapper.SrsRegInfoMapper">

    <resultMap type="SrsRegInfo" id="SrsRegInfoResult">
        <result property="registerId"    column="register_id"    />
        <result property="userId"    column="user_id"    />
        <result property="userName"    column="user_name"    />
        <result property="sex"    column="sex"    />
        <result property="telphone"    column="telphone"    />
        <result property="identyNo"    column="identy_no"    />
        <result property="faceImage"    column="face_image"    />
        <result property="nation"    column="nation"    />
        <result property="politicsStatus"    column="politics_status"    />
        <result property="height"    column="height"    />
        <result property="weight"    column="weight"    />
        <result property="isOffnetCheck"    column="is_offnet_check"    />
        <result property="checkDate"    column="check_date"    />
        <result property="departments"    column="departments"    />
        <result property="graduateSchool"    column="graduate_school"    />
        <result property="schoolAddress"    column="school_address"    />
        <result property="familyContactName"    column="family_contact_name"    />
        <result property="relation"    column="relation"    />
        <result property="familyContactPhone"    column="family_contact_phone"    />
        <result property="domicileAddress"    column="domicile_address"    />
        <result property="homeAdress"    column="home_adress"    />
        <result property="isReg"    column="is_reg"    />
        <result property="status"    column="status"    />
        <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="selectSrsRegInfoVo">
        select register_id, user_id, user_name, sex, telphone, identy_no, face_image, nation, politics_status, height, weight, is_offnet_check, check_date, departments, graduate_school, school_address, family_contact_name, relation, family_contact_phone, domicile_address, home_adress, is_reg, status, create_by, create_time, update_by, update_time from srs_reg_info
    </sql>


    <select id="selectSrsRegInfoList" parameterType="SrsRegInfo" resultMap="SrsRegInfoResult">
        <include refid="selectSrsRegInfoVo"/>
        <where>
            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="sex != null  and sex != ''"> and sex = #{sex}</if>
            <if test="telphone != null  and telphone != ''"> and telphone = #{telphone}</if>
            <if test="identyNo != null  and identyNo != ''"> and identy_no = #{identyNo}</if>
            <if test="faceImage != null  and faceImage != ''"> and face_image = #{faceImage}</if>
            <if test="nation != null  and nation != ''"> and nation = #{nation}</if>
            <if test="politicsStatus != null  and politicsStatus != ''"> and politics_status = #{politicsStatus}</if>
            <if test="height != null "> and height = #{height}</if>
            <if test="weight != null "> and weight = #{weight}</if>
            <if test="isOffnetCheck != null  and isOffnetCheck != ''"> and is_offnet_check = #{isOffnetCheck}</if>
            <if test="checkDate != null "> and check_date = #{checkDate}</if>
            <if test="departments != null  and departments != ''"> and departments = #{departments}</if>
            <if test="graduateSchool != null  and graduateSchool != ''"> and graduate_school = #{graduateSchool}</if>
            <if test="schoolAddress != null  and schoolAddress != ''"> and school_address = #{schoolAddress}</if>
            <if test="familyContactName != null  and familyContactName != ''"> and family_contact_name like concat('%', #{familyContactName}, '%')</if>
            <if test="relation != null  and relation != ''"> and relation = #{relation}</if>
            <if test="familyContactPhone != null  and familyContactPhone != ''"> and family_contact_phone = #{familyContactPhone}</if>
            <if test="domicileAddress != null  and domicileAddress != ''"> and domicile_address = #{domicileAddress}</if>
            <if test="homeAdress != null  and homeAdress != ''"> and home_adress = #{homeAdress}</if>
            <if test="isReg != null "> and is_reg = #{isReg}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>

    <select id="selectSrsRegInfoByRegisterId" parameterType="Long" resultMap="SrsRegInfoResult">
        <include refid="selectSrsRegInfoVo"/>
        where register_id = #{registerId}
    </select>


    <insert id="insertSrsRegInfo" parameterType="SrsRegInfo" useGeneratedKeys="true" keyProperty="registerId">
        insert into srs_reg_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="userName != null">user_name,</if>
            <if test="sex != null">sex,</if>
            <if test="telphone != null">telphone,</if>
            <if test="identyNo != null">identy_no,</if>
            <if test="faceImage != null">face_image,</if>
            <if test="nation != null">nation,</if>
            <if test="politicsStatus != null">politics_status,</if>
            <if test="height != null">height,</if>
            <if test="weight != null">weight,</if>
            <if test="isOffnetCheck != null">is_offnet_check,</if>
            <if test="checkDate != null">check_date,</if>
            <if test="departments != null">departments,</if>
            <if test="graduateSchool != null">graduate_school,</if>
            <if test="schoolAddress != null">school_address,</if>
            <if test="familyContactName != null">family_contact_name,</if>
            <if test="relation != null">relation,</if>
            <if test="familyContactPhone != null">family_contact_phone,</if>
            <if test="domicileAddress != null">domicile_address,</if>
            <if test="homeAdress != null">home_adress,</if>
            <if test="isReg != null">is_reg,</if>
            <if test="status != null">status,</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="userId != null">#{userId},</if>
            <if test="userName != null">#{userName},</if>
            <if test="sex != null">#{sex},</if>
            <if test="telphone != null">#{telphone},</if>
            <if test="identyNo != null">#{identyNo},</if>
            <if test="faceImage != null">#{faceImage},</if>
            <if test="nation != null">#{nation},</if>
            <if test="politicsStatus != null">#{politicsStatus},</if>
            <if test="height != null">#{height},</if>
            <if test="weight != null">#{weight},</if>
            <if test="isOffnetCheck != null">#{isOffnetCheck},</if>
            <if test="checkDate != null">#{checkDate},</if>
            <if test="departments != null">#{departments},</if>
            <if test="graduateSchool != null">#{graduateSchool},</if>
            <if test="schoolAddress != null">#{schoolAddress},</if>
            <if test="familyContactName != null">#{familyContactName},</if>
            <if test="relation != null">#{relation},</if>
            <if test="familyContactPhone != null">#{familyContactPhone},</if>
            <if test="domicileAddress != null">#{domicileAddress},</if>
            <if test="homeAdress != null">#{homeAdress},</if>
            <if test="isReg != null">#{isReg},</if>
            <if test="status != null">#{status},</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="updateSrsRegInfo" parameterType="SrsRegInfo">
        update srs_reg_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="sex != null">sex = #{sex},</if>
            <if test="telphone != null">telphone = #{telphone},</if>
            <if test="identyNo != null">identy_no = #{identyNo},</if>
            <if test="faceImage != null">face_image = #{faceImage},</if>
            <if test="nation != null">nation = #{nation},</if>
            <if test="politicsStatus != null">politics_status = #{politicsStatus},</if>
            <if test="height != null">height = #{height},</if>
            <if test="weight != null">weight = #{weight},</if>
            <if test="isOffnetCheck != null">is_offnet_check = #{isOffnetCheck},</if>
            <if test="checkDate != null">check_date = #{checkDate},</if>
            <if test="departments != null">departments = #{departments},</if>
            <if test="graduateSchool != null">graduate_school = #{graduateSchool},</if>
            <if test="schoolAddress != null">school_address = #{schoolAddress},</if>
            <if test="familyContactName != null">family_contact_name = #{familyContactName},</if>
            <if test="relation != null">relation = #{relation},</if>
            <if test="familyContactPhone != null">family_contact_phone = #{familyContactPhone},</if>
            <if test="domicileAddress != null">domicile_address = #{domicileAddress},</if>
            <if test="homeAdress != null">home_adress = #{homeAdress},</if>
            <if test="isReg != null">is_reg = #{isReg},</if>
            <if test="status != null">status = #{status},</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 register_id = #{registerId}
    </update>

    <delete id="deleteSrsRegInfoByRegisterId" parameterType="Long">
        delete from srs_reg_info where register_id = #{registerId}
    </delete>

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