<?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.comprehensive.mapper.KnzzZsgApplyMapper">

    <resultMap type="KnzzZsgApply" id="KnzzZsgApplyResult">
        <result property="id"    column="id"    />
        <result property="stuName"    column="stu_name"    />
        <result property="gender"    column="gender"    />
        <result property="birthMonth"    column="birth_month"    />
        <result property="mz"    column="mz"    />
        <result property="zzmm"    column="zzmm"    />
        <result property="inTime"    column="in_time"    />
        <result property="idCard"    column="idCard"    />
        <result property="stuPhone"    column="stu_phone"    />
        <result property="bankCard"    column="bank_card"    />
        <result property="bankAddr"    column="bank_addr"    />
        <result property="zzxx"    column="zzxx"    />
        <result property="deptName"    column="dept_name"    />
        <result property="majorName"    column="major_name"    />
        <result property="className"    column="class_name"    />
        <result property="jthk"    column="jthk"    />
        <result property="familyNum"    column="family_num"    />
        <result property="monthMoney"    column="month_money"    />
        <result property="perMoney"    column="per_money"    />
        <result property="moneySrc"    column="money_src"    />
        <result property="homeAddr"    column="home_addr"    />
        <result property="postCode"    column="post_code"    />
        <result property="familyMemberList"    column="family_member_list"    />
        <result property="applyReasonNum"    column="apply_reason_num"    />
        <result property="applyReason"    column="apply_reason"    />
        <result property="applyReason1"    column="apply_reason1"    />
        <result property="applyExtraReason"    column="apply_extra_reason"    />
        <result property="applySign"    column="apply_sign"    />
        <result property="applyDate"    column="apply_date"    />
        <result property="fdyCmt"    column="fdy_cmt"    />
        <result property="fdySign"    column="fdy_sign"    />
        <result property="fdyZz"    column="fdy_zz"    />
        <result property="fdyDate"    column="fdy_date"    />
        <result property="fdyNo"    column="fdy_no"    />
        <result property="xwCmt"    column="xw_cmt"    />
        <result property="xwSign"    column="xw_sign"    />
        <result property="xwDate"    column="xw_date"    />
        <result property="xwNo"    column="xw_no"    />
        <result property="xgCmt"    column="xg_cmt"    />
        <result property="xgSign"    column="xg_sign"    />
        <result property="xgDate"    column="xg_date"    />
        <result property="xgNo"    column="xg_no"    />
        <result property="applyStatus"    column="apply_status"    />
        <result property="applyFile"    column="apply_file"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="stuYearId"    column="stu_year_id"    />
        <result property="diplomaCertificate" column="diploma_certificate"/>

    </resultMap>

    <sql id="selectKnzzZsgApplyVo">
        select id, stu_name, gender, birth_month, mz, zzmm, in_time, idCard, stu_phone, bank_card, bank_addr, zzxx, dept_name, major_name, class_name, jthk, family_num, month_money, per_money, money_src, home_addr, post_code, family_member_list, apply_reason_num, apply_reason, apply_reason1, apply_extra_reason, apply_sign, apply_date, fdy_cmt, fdy_sign, fdy_zz, fdy_date, fdy_no, xw_cmt, xw_sign, xw_date, xw_no, xg_cmt, xg_sign, xg_date, xg_no, apply_status, apply_file, create_time, create_by, update_time, update_by, stu_year_id from knzz_zsg_apply
    </sql>

    <select id="selectKnzzZsgApplyList" parameterType="KnzzZsgApply" resultMap="KnzzZsgApplyResult">
        <include refid="selectKnzzZsgApplyVo"/>
        <where>
            <if test="stuName != null  and stuName != ''"> and stu_name like concat('%', #{stuName}, '%')</if>
            <if test="gender != null  and gender != ''"> and gender = #{gender}</if>
            <if test="birthMonth != null  and birthMonth != ''"> and birth_month = #{birthMonth}</if>
            <if test="mz != null  and mz != ''"> and mz = #{mz}</if>
            <if test="zzmm != null  and zzmm != ''"> and zzmm = #{zzmm}</if>
            <if test="inTime != null  and inTime != ''"> and in_time = #{inTime}</if>
            <if test="idCard != null  and idCard != ''"> and idCard = #{idCard}</if>
            <if test="stuPhone != null  and stuPhone != ''"> and stu_phone = #{stuPhone}</if>
            <if test="bankCard != null  and bankCard != ''"> and bank_card = #{bankCard}</if>
            <if test="bankAddr != null  and bankAddr != ''"> and bank_addr = #{bankAddr}</if>
            <if test="zzxx != null  and zzxx != ''"> and zzxx = #{zzxx}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <if test="majorName != null  and majorName != ''"> and major_name like concat('%', #{majorName}, '%')</if>
            <if test="className != null  and className != ''"> and class_name like concat('%', #{className}, '%')</if>
            <if test="jthk != null  and jthk != ''"> and jthk = #{jthk}</if>
            <if test="familyNum != null  and familyNum != ''"> and family_num = #{familyNum}</if>
            <if test="monthMoney != null  and monthMoney != ''"> and month_money = #{monthMoney}</if>
            <if test="perMoney != null  and perMoney != ''"> and per_money = #{perMoney}</if>
            <if test="moneySrc != null  and moneySrc != ''"> and money_src = #{moneySrc}</if>
            <if test="homeAddr != null  and homeAddr != ''"> and home_addr = #{homeAddr}</if>
            <if test="postCode != null  and postCode != ''"> and post_code = #{postCode}</if>
            <if test="familyMemberList != null  and familyMemberList != ''"> and family_member_list = #{familyMemberList}</if>
            <if test="applyReasonNum != null  and applyReasonNum != ''"> and apply_reason_num = #{applyReasonNum}</if>
            <if test="applyReason != null  and applyReason != ''"> and apply_reason = #{applyReason}</if>
            <if test="applyReason1 != null  and applyReason1 != ''"> and apply_reason1 = #{applyReason1}</if>
            <if test="applyExtraReason != null  and applyExtraReason != ''"> and apply_extra_reason = #{applyExtraReason}</if>
            <if test="applySign != null  and applySign != ''"> and apply_sign = #{applySign}</if>
            <if test="applyDate != null "> and apply_date = #{applyDate}</if>
            <if test="fdyCmt != null  and fdyCmt != ''"> and fdy_cmt = #{fdyCmt}</if>
            <if test="fdySign != null  and fdySign != ''"> and fdy_sign = #{fdySign}</if>
            <if test="fdyZz != null  and fdyZz != ''"> and fdy_zz = #{fdyZz}</if>
            <if test="fdyDate != null "> and fdy_date = #{fdyDate}</if>
            <if test="fdyNo != null  and fdyNo != ''"> and fdy_no = #{fdyNo}</if>
            <if test="xwCmt != null  and xwCmt != ''"> and xw_cmt = #{xwCmt}</if>
            <if test="xwSign != null  and xwSign != ''"> and xw_sign = #{xwSign}</if>
            <if test="xwDate != null "> and xw_date = #{xwDate}</if>
            <if test="xwNo != null  and xwNo != ''"> and xw_no = #{xwNo}</if>
            <if test="xgCmt != null  and xgCmt != ''"> and xg_cmt = #{xgCmt}</if>
            <if test="xgSign != null  and xgSign != ''"> and xg_sign = #{xgSign}</if>
            <if test="xgDate != null "> and xg_date = #{xgDate}</if>
            <if test="xgNo != null  and xgNo != ''"> and xg_no = #{xgNo}</if>
            <if test="applyStatus != null  and applyStatus != ''"> and apply_status = #{applyStatus}</if>
            <if test="applyFile != null  and applyFile != ''"> and apply_file = #{applyFile}</if>
            <if test="stuYearId != null "> and stu_year_id = #{stuYearId}</if>
        </where>
        order by id desc
    </select>

    <select id="selectKnzzZsgApplyById" parameterType="Long" resultMap="KnzzZsgApplyResult">
        <include refid="selectKnzzZsgApplyVo"/>
        where id = #{id}
    </select>

    <insert id="insertKnzzZsgApply" parameterType="KnzzZsgApply" useGeneratedKeys="true" keyProperty="id">
        insert into knzz_zsg_apply
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stuName != null">stu_name,</if>
            <if test="gender != null">gender,</if>
            <if test="birthMonth != null">birth_month,</if>
            <if test="mz != null">mz,</if>
            <if test="zzmm != null">zzmm,</if>
            <if test="inTime != null">in_time,</if>
            <if test="idCard != null">idCard,</if>
            <if test="stuPhone != null">stu_phone,</if>
            <if test="bankCard != null">bank_card,</if>
            <if test="bankAddr != null">bank_addr,</if>
            <if test="zzxx != null">zzxx,</if>
            <if test="deptName != null">dept_name,</if>
            <if test="majorName != null">major_name,</if>
            <if test="className != null">class_name,</if>
            <if test="jthk != null">jthk,</if>
            <if test="familyNum != null">family_num,</if>
            <if test="monthMoney != null">month_money,</if>
            <if test="perMoney != null">per_money,</if>
            <if test="moneySrc != null">money_src,</if>
            <if test="homeAddr != null">home_addr,</if>
            <if test="postCode != null">post_code,</if>
            <if test="familyMemberList != null">family_member_list,</if>
            <if test="applyReasonNum != null">apply_reason_num,</if>
            <if test="applyReason != null">apply_reason,</if>
            <if test="applyReason1 != null">apply_reason1,</if>
            <if test="applyExtraReason != null">apply_extra_reason,</if>
            <if test="applySign != null">apply_sign,</if>
            <if test="applyDate != null">apply_date,</if>
            <if test="fdyCmt != null">fdy_cmt,</if>
            <if test="fdySign != null">fdy_sign,</if>
            <if test="fdyZz != null">fdy_zz,</if>
            <if test="fdyDate != null">fdy_date,</if>
            <if test="fdyNo != null">fdy_no,</if>
            <if test="xwCmt != null">xw_cmt,</if>
            <if test="xwSign != null">xw_sign,</if>
            <if test="xwDate != null">xw_date,</if>
            <if test="xwNo != null">xw_no,</if>
            <if test="xgCmt != null">xg_cmt,</if>
            <if test="xgSign != null">xg_sign,</if>
            <if test="xgDate != null">xg_date,</if>
            <if test="xgNo != null">xg_no,</if>
            <if test="applyStatus != null">apply_status,</if>
            <if test="applyFile != null">apply_file,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="stuYearId != null">stu_year_id,</if>
            <if test="diplomaCertificate != null">diploma_certificate,</if>

        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stuName != null">#{stuName},</if>
            <if test="gender != null">#{gender},</if>
            <if test="birthMonth != null">#{birthMonth},</if>
            <if test="mz != null">#{mz},</if>
            <if test="zzmm != null">#{zzmm},</if>
            <if test="inTime != null">#{inTime},</if>
            <if test="idCard != null">#{idCard},</if>
            <if test="stuPhone != null">#{stuPhone},</if>
            <if test="bankCard != null">#{bankCard},</if>
            <if test="bankAddr != null">#{bankAddr},</if>
            <if test="zzxx != null">#{zzxx},</if>
            <if test="deptName != null">#{deptName},</if>
            <if test="majorName != null">#{majorName},</if>
            <if test="className != null">#{className},</if>
            <if test="jthk != null">#{jthk},</if>
            <if test="familyNum != null">#{familyNum},</if>
            <if test="monthMoney != null">#{monthMoney},</if>
            <if test="perMoney != null">#{perMoney},</if>
            <if test="moneySrc != null">#{moneySrc},</if>
            <if test="homeAddr != null">#{homeAddr},</if>
            <if test="postCode != null">#{postCode},</if>
            <if test="familyMemberList != null">#{familyMemberList},</if>
            <if test="applyReasonNum != null">#{applyReasonNum},</if>
            <if test="applyReason != null">#{applyReason},</if>
            <if test="applyReason1 != null">#{applyReason1},</if>
            <if test="applyExtraReason != null">#{applyExtraReason},</if>
            <if test="applySign != null">#{applySign},</if>
            <if test="applyDate != null">#{applyDate},</if>
            <if test="fdyCmt != null">#{fdyCmt},</if>
            <if test="fdySign != null">#{fdySign},</if>
            <if test="fdyZz != null">#{fdyZz},</if>
            <if test="fdyDate != null">#{fdyDate},</if>
            <if test="fdyNo != null">#{fdyNo},</if>
            <if test="xwCmt != null">#{xwCmt},</if>
            <if test="xwSign != null">#{xwSign},</if>
            <if test="xwDate != null">#{xwDate},</if>
            <if test="xwNo != null">#{xwNo},</if>
            <if test="xgCmt != null">#{xgCmt},</if>
            <if test="xgSign != null">#{xgSign},</if>
            <if test="xgDate != null">#{xgDate},</if>
            <if test="xgNo != null">#{xgNo},</if>
            <if test="applyStatus != null">#{applyStatus},</if>
            <if test="applyFile != null">#{applyFile},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="stuYearId != null">#{stuYearId},</if>
            <if test="diplomaCertificate != null">#{diplomaCertificate},</if>

        </trim>
    </insert>

    <update id="updateKnzzZsgApply" parameterType="KnzzZsgApply">
        update knzz_zsg_apply
        <trim prefix="SET" suffixOverrides=",">
            <if test="stuName != null">stu_name = #{stuName},</if>
            <if test="gender != null">gender = #{gender},</if>
            <if test="birthMonth != null">birth_month = #{birthMonth},</if>
            <if test="mz != null">mz = #{mz},</if>
            <if test="zzmm != null">zzmm = #{zzmm},</if>
            <if test="inTime != null">in_time = #{inTime},</if>
            <if test="idCard != null">idCard = #{idCard},</if>
            <if test="stuPhone != null">stu_phone = #{stuPhone},</if>
            <if test="bankCard != null">bank_card = #{bankCard},</if>
            <if test="bankAddr != null">bank_addr = #{bankAddr},</if>
            <if test="zzxx != null">zzxx = #{zzxx},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="majorName != null">major_name = #{majorName},</if>
            <if test="className != null">class_name = #{className},</if>
            <if test="jthk != null">jthk = #{jthk},</if>
            <if test="familyNum != null">family_num = #{familyNum},</if>
            <if test="monthMoney != null">month_money = #{monthMoney},</if>
            <if test="perMoney != null">per_money = #{perMoney},</if>
            <if test="moneySrc != null">money_src = #{moneySrc},</if>
            <if test="homeAddr != null">home_addr = #{homeAddr},</if>
            <if test="postCode != null">post_code = #{postCode},</if>
            <if test="familyMemberList != null">family_member_list = #{familyMemberList},</if>
            <if test="applyReasonNum != null">apply_reason_num = #{applyReasonNum},</if>
            <if test="applyReason != null">apply_reason = #{applyReason},</if>
            <if test="applyReason1 != null">apply_reason1 = #{applyReason1},</if>
            <if test="applyExtraReason != null">apply_extra_reason = #{applyExtraReason},</if>
            <if test="applySign != null">apply_sign = #{applySign},</if>
            <if test="applyDate != null">apply_date = #{applyDate},</if>
            <if test="fdyCmt != null">fdy_cmt = #{fdyCmt},</if>
            <if test="fdySign != null">fdy_sign = #{fdySign},</if>
            <if test="fdyZz != null">fdy_zz = #{fdyZz},</if>
            <if test="fdyDate != null">fdy_date = #{fdyDate},</if>
            <if test="fdyNo != null">fdy_no = #{fdyNo},</if>
            <if test="xwCmt != null">xw_cmt = #{xwCmt},</if>
            <if test="xwSign != null">xw_sign = #{xwSign},</if>
            <if test="xwDate != null">xw_date = #{xwDate},</if>
            <if test="xwNo != null">xw_no = #{xwNo},</if>
            <if test="xgCmt != null">xg_cmt = #{xgCmt},</if>
            <if test="xgSign != null">xg_sign = #{xgSign},</if>
            <if test="xgDate != null">xg_date = #{xgDate},</if>
            <if test="xgNo != null">xg_no = #{xgNo},</if>
            <if test="applyStatus != null">apply_status = #{applyStatus},</if>
            <if test="applyFile != null">apply_file = #{applyFile},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="stuYearId != null">stu_year_id = #{stuYearId},</if>
            <if test="diplomaCertificate != null">diploma_certificate = #{diplomaCertificate},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteKnzzZsgApplyById" parameterType="Long">
        delete from knzz_zsg_apply where id = #{id}
    </delete>

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

    <select id="listView" parameterType="knzzZsgApply" resultType="knzzZsgApply">
        select a.*,c.stu_year_name,d.`name` as fdy_name,e.`name` as xw_name,f.`name` as xg_name
        from knzz_zsg_apply as a
        left join view_stu_info as b on a.stu_no = b.stu_no
        left join srs_stu_year as c on a.stu_year_id = c.id
        left join cph_teacher as d on a.fdy_no = d.employee_id
        left join qgzx_teacher as e on a.xw_no = d.employee_id
        left join qgzx_teacher as f on a.xg_no = f.employee_id
        <where>
            <if test="stuNo != null  and stuNo != ''"> and a.stu_no = #{stuNo}</if>
            <if test="applyStatus != null  and applyStatus != ''"> and a.apply_status = #{applyStatus}</if>
            <if test="fdyNo != null  and fdyNo != ''"> and b.t_no = #{fdyNo}</if>
            <if test="deptId != null "> and b.dept_id = #{deptId}</if>
            <if test="stuYearId != null "> and a.stu_year_id = #{stuYearId}</if>
            <if test="deptName != null  and deptName != ''"> and b.dept_name like concat('%',#{ deptName},'%')</if>
            <if test="stuName != null  and stuName != ''"> and b.stu_name like concat('%',#{stuName},'%')</if>
            <if test="className != null  and className != ''"> and b.class_name like concat('%',#{className},'%')</if>
        </where>
        order by a.id desc
    </select>


</mapper>
