<?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="org.dromara.system.mapper.RegisterParentsStudentMapper">
    <resultMap type="org.dromara.system.domain.vo.RegisterParentsStudentVo" id="RegisterParentsStudentResult">
        <result property="id"    column="id"    />
        <result property="parentsId"    column="parents_id"    />

        <result property="parentsName"    column="parents_name"    />
        <result property="parentsPhone"    column="parents_phone"    />

        <result property="schoolId"    column="school_id"    />
        <result property="schoolName"    column="school_name"    />
        <result property="classId"    column="class_id"    />
        <result property="className"    column="class_name"    />
        <result property="period"    column="period"    />

        <result property="studentName"    column="student_name"    />
        <result property="studentNumber"    column="student_number"    />
        <result property="isPass"    column="is_pass"    />
        <result property="auditId"    column="audit_id"    />
        <result property="auditUser"    column="audit_user"    />
        <result property="opinion"    column="opinion"    />
        <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="selectRegisterParentsStudentVo">
        select id, parents_id,parents_name,parents_phone, school_id, school_name, class_id, class_name, period,student_name, student_number, is_pass,audit_id,audit_user,opinion, create_by, create_time, update_by, update_time, remark from register_parents_student
    </sql>
    <update id="updateMapperById">
        update register_parents_student
        <trim prefix="SET" suffixOverrides=",">
            <if test="parentsId != null">parents_id = #{parentsId},</if>
            <if test="parentsName != null "> parents_name = #{parentsName},</if>
            <if test="parentsPhone != null "> parents_phone = #{parentsPhone},</if>
            <if test="schoolId != null">school_id = #{schoolId},</if>
            <if test="schoolName != null">school_name = #{schoolName},</if>
            <if test="classId != null">class_id = #{classId},</if>
            <if test="className != null">class_name = #{className},</if>
            <if test="period != null">period = #{period},</if>
            <if test="studentName != null">student_name = #{studentName},</if>
            <if test="studentNumber != null">student_number = #{studentNumber},</if>
            <if test="isPass != null">is_pass = #{isPass},</if>
            <if test="auditId != null">audit_id= #{auditId},</if>
            <if test="auditUser != null">audit_user= #{auditUser},</if>
            <if test="opinion != null">opinion= #{opinion},</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="deleteRegisterParentsStudentByParentsId" parameterType="java.lang.Long">
        delete from register_parents_student where parents_id = #{parentsId} and is_pass = '3';
    </delete>
    <delete id="deleteByIdMapper">
        delete from register_parents_student where id = #{id}
    </delete>

    <select id="selectRegisterParentsStudentListByTime" resultMap="RegisterParentsStudentResult">
        <include refid="selectRegisterParentsStudentVo"/>
        where date_format(create_time,'%Y%m') = date_format(#{monthFirst},'%Y%m')
        <if test="period != null">period = #{period},</if>
        and class_id in
        <foreach collection="classIds" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>
    <select id="selectVoMapperList" resultMap="RegisterParentsStudentResult">
        <include refid="selectRegisterParentsStudentVo"/>
        ${ew.getCustomSqlSegment}
    </select>
    <select id="selectVoMapperPage" resultMap="RegisterParentsStudentResult">
        <include refid="selectRegisterParentsStudentVo"/>
        ${ew.getCustomSqlSegment}
    </select>
</mapper>
