<?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.system.mapper.TeacherInfoMapper">
    
    <resultMap type="TeacherInfo" id="TeacherInfoResult">
        <result property="id"    column="id"    />
        <result property="teacherId"    column="teacher_id"    />
        <result property="name"    column="name"    />
        <result property="sex"    column="sex"    />
        <result property="age"    column="age"    />
        <result property="phone"    column="phone"    />
        <result property="professional"    column="professional"    />
        <result property="idCard"    column="id_card"    />
        <result property="height"    column="height"    />
        <result property="weight"    column="weight"    />
        <result property="bloodType"    column="blood_type"    />
        <result property="politicalStatus"    column="political_status"    />
        <result property="graduationPhoto"    column="graduation_photo"    />
        <result property="degreePhoto"    column="degree_photo"    />
        <result property="teachingPhoto"    column="teaching_photo"    />
        <result property="professionalPhoto"    column="professional_photo"    />
        <result property="identificationPhoto"    column="identification_photo"    />
        <result property="entrancePermit"    column="entrance_permit"    />
        <result property="address"    column="address"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTeacherInfoVo">
        select id, teacher_id, name, sex, age, phone, professional, id_card, height, weight, blood_type, political_status, graduation_photo, degree_photo, teaching_photo, professional_photo, identification_photo, entrance_permit, address, create_by, create_time, update_by, update_time, remark from teacher_info
    </sql>

    <select id="selectTeacherInfoList" parameterType="TeacherInfo" resultMap="TeacherInfoResult">
        <include refid="selectTeacherInfoVo"/>
        <where>  
            <if test="teacherId != null "> and teacher_id = #{teacherId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="sex != null  and sex != ''"> and sex = #{sex}</if>
            <if test="age != null  and age != ''"> and age = #{age}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="professional != null  and professional != ''"> and professional = #{professional}</if>
            <if test="idCard != null  and idCard != ''"> and id_card = #{idCard}</if>
            <if test="height != null  and height != ''"> and height = #{height}</if>
            <if test="weight != null  and weight != ''"> and weight = #{weight}</if>
            <if test="bloodType != null  and bloodType != ''"> and blood_type = #{bloodType}</if>
            <if test="politicalStatus != null  and politicalStatus != ''"> and political_status = #{politicalStatus}</if>
            <if test="graduationPhoto != null  and graduationPhoto != ''"> and graduation_photo = #{graduationPhoto}</if>
            <if test="degreePhoto != null  and degreePhoto != ''"> and degree_photo = #{degreePhoto}</if>
            <if test="teachingPhoto != null  and teachingPhoto != ''"> and teaching_photo = #{teachingPhoto}</if>
            <if test="professionalPhoto != null  and professionalPhoto != ''"> and professional_photo = #{professionalPhoto}</if>
            <if test="identificationPhoto != null  and identificationPhoto != ''"> and identification_photo = #{identificationPhoto}</if>
            <if test="entrancePermit != null  and entrancePermit != ''"> and entrance_permit = #{entrancePermit}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
        </where>
    </select>
    
    <select id="selectTeacherInfoById" parameterType="Long" resultMap="TeacherInfoResult">
        <include refid="selectTeacherInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTeacherInfo" parameterType="TeacherInfo" useGeneratedKeys="true" keyProperty="id">
        insert into teacher_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="teacherId != null">teacher_id,</if>
            <if test="name != null">name,</if>
            <if test="sex != null">sex,</if>
            <if test="age != null">age,</if>
            <if test="phone != null">phone,</if>
            <if test="professional != null">professional,</if>
            <if test="idCard != null">id_card,</if>
            <if test="height != null">height,</if>
            <if test="weight != null">weight,</if>
            <if test="bloodType != null">blood_type,</if>
            <if test="politicalStatus != null">political_status,</if>
            <if test="graduationPhoto != null">graduation_photo,</if>
            <if test="degreePhoto != null">degree_photo,</if>
            <if test="teachingPhoto != null">teaching_photo,</if>
            <if test="professionalPhoto != null">professional_photo,</if>
            <if test="identificationPhoto != null">identification_photo,</if>
            <if test="entrancePermit != null">entrance_permit,</if>
            <if test="address != null">address,</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>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="teacherId != null">#{teacherId},</if>
            <if test="name != null">#{name},</if>
            <if test="sex != null">#{sex},</if>
            <if test="age != null">#{age},</if>
            <if test="phone != null">#{phone},</if>
            <if test="professional != null">#{professional},</if>
            <if test="idCard != null">#{idCard},</if>
            <if test="height != null">#{height},</if>
            <if test="weight != null">#{weight},</if>
            <if test="bloodType != null">#{bloodType},</if>
            <if test="politicalStatus != null">#{politicalStatus},</if>
            <if test="graduationPhoto != null">#{graduationPhoto},</if>
            <if test="degreePhoto != null">#{degreePhoto},</if>
            <if test="teachingPhoto != null">#{teachingPhoto},</if>
            <if test="professionalPhoto != null">#{professionalPhoto},</if>
            <if test="identificationPhoto != null">#{identificationPhoto},</if>
            <if test="entrancePermit != null">#{entrancePermit},</if>
            <if test="address != null">#{address},</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>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTeacherInfo" parameterType="TeacherInfo">
        update teacher_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="teacherId != null">teacher_id = #{teacherId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="sex != null">sex = #{sex},</if>
            <if test="age != null">age = #{age},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="professional != null">professional = #{professional},</if>
            <if test="idCard != null">id_card = #{idCard},</if>
            <if test="height != null">height = #{height},</if>
            <if test="weight != null">weight = #{weight},</if>
            <if test="bloodType != null">blood_type = #{bloodType},</if>
            <if test="politicalStatus != null">political_status = #{politicalStatus},</if>
            <if test="graduationPhoto != null">graduation_photo = #{graduationPhoto},</if>
            <if test="degreePhoto != null">degree_photo = #{degreePhoto},</if>
            <if test="teachingPhoto != null">teaching_photo = #{teachingPhoto},</if>
            <if test="professionalPhoto != null">professional_photo = #{professionalPhoto},</if>
            <if test="identificationPhoto != null">identification_photo = #{identificationPhoto},</if>
            <if test="entrancePermit != null">entrance_permit = #{entrancePermit},</if>
            <if test="address != null">address = #{address},</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>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTeacherInfoById" parameterType="Long">
        delete from teacher_info where id = #{id}
    </delete>

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