<?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.CphTotalScoreMapper">



    <resultMap type="CphTotalScore" id="CphTotalScoreResult">
        <result property="id"    column="id"    />
        <result property="stuNo"    column="stu_no"    />
        <result property="classCode"    column="class_code"    />
        <result property="stuYearId"    column="stu_year_id"    />
        <result property="sportScore"    column="sport_score"    />
        <result property="ceScore"    column="ce_score"    />
        <result property="iamScore"    column="iam_score"    />
        <result property="classtwoScore"    column="classtwo_score"    />
        <result property="stuScore"    column="stu_score"    />
        <result property="cphScore"    column="cph_score"    />
        <result property="majorRank"    column="major_rank"    />
        <result property="classRank"    column="class_rank"    />
        <result property="status"    column="status"    />
        <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="delFlag"    column="del_flag"    />
        <result property="majorId"    column="major_id"    />
        <result property="classId"    column="class_id"    />
    </resultMap>

    <sql id="selectCphTotalScoreVo">
        select id, stu_no, class_code, stu_year_id, sport_score, ce_score, iam_score, classtwo_score, stu_score, cph_score, major_rank, class_rank, status, create_time, create_by, update_time, update_by, del_flag, major_id, class_id from cph_total_score
    </sql>

    <select id="selectCphTotalScoreList" parameterType="CphTotalScore" resultMap="CphTotalScoreResult">
        <include refid="selectCphTotalScoreVo"/>
        <where>
            <if test="stuNo != null  and stuNo != ''"> and stu_no = #{stuNo}</if>
            <if test="classCode != null  and classCode != ''"> and class_code = #{classCode}</if>
            <if test="stuYearId != null "> and stu_year_id = #{stuYearId}</if>
            <if test="sportScore != null "> and sport_score = #{sportScore}</if>
            <if test="ceScore != null "> and ce_score = #{ceScore}</if>
            <if test="iamScore != null "> and iam_score = #{iamScore}</if>
            <if test="classtwoScore != null "> and classtwo_score = #{classtwoScore}</if>
            <if test="stuScore != null "> and stu_score = #{stuScore}</if>
            <if test="cphScore != null "> and cph_score = #{cphScore}</if>
            <if test="majorRank != null "> and major_rank = #{majorRank}</if>
            <if test="classRank != null "> and class_rank = #{classRank}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="majorId != null "> and major_id = #{majorId}</if>
            <if test="classId != null "> and class_id = #{classId}</if>
        </where>
    </select>

    <select id="testFor"  statementType="CALLABLE">
        {call test_for (#{in_stu_year_id,mode=IN,jdbcType=INTEGER})}
    </select>


    <select id="selectCphTotalScoreById" parameterType="Long" resultMap="CphTotalScoreResult">
        <include refid="selectCphTotalScoreVo"/>
        where id = #{id}
    </select>

    <insert id="insertCphTotalScore" parameterType="CphTotalScore" useGeneratedKeys="true" keyProperty="id">
        insert into cph_total_score
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stuNo != null">stu_no,</if>
            <if test="classCode != null">class_code,</if>
            <if test="stuYearId != null">stu_year_id,</if>
            <if test="sportScore != null">sport_score,</if>
            <if test="ceScore != null">ce_score,</if>
            <if test="iamScore != null">iam_score,</if>
            <if test="classtwoScore != null">classtwo_score,</if>
            <if test="stuScore != null">stu_score,</if>
            <if test="cphScore != null">cph_score,</if>
            <if test="majorRank != null">major_rank,</if>
            <if test="classRank != null">class_rank,</if>
            <if test="status != null">status,</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="delFlag != null">del_flag,</if>
            <if test="majorId != null">major_id,</if>
            <if test="classId != null">class_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stuNo != null">#{stuNo},</if>
            <if test="classCode != null">#{classCode},</if>
            <if test="stuYearId != null">#{stuYearId},</if>
            <if test="sportScore != null">#{sportScore},</if>
            <if test="ceScore != null">#{ceScore},</if>
            <if test="iamScore != null">#{iamScore},</if>
            <if test="classtwoScore != null">#{classtwoScore},</if>
            <if test="stuScore != null">#{stuScore},</if>
            <if test="cphScore != null">#{cphScore},</if>
            <if test="majorRank != null">#{majorRank},</if>
            <if test="classRank != null">#{classRank},</if>
            <if test="status != null">#{status},</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="delFlag != null">#{delFlag},</if>
            <if test="majorId != null">#{majorId},</if>
            <if test="classId != null">#{classId},</if>
        </trim>
    </insert>

    <update id="updateCphTotalScore" parameterType="CphTotalScore">
        update cph_total_score
        <trim prefix="SET" suffixOverrides=",">
            <if test="stuNo != null">stu_no = #{stuNo},</if>
            <if test="classCode != null">class_code = #{classCode},</if>
            <if test="stuYearId != null">stu_year_id = #{stuYearId},</if>
            <if test="sportScore != null">sport_score = #{sportScore},</if>
            <if test="ceScore != null">ce_score = #{ceScore},</if>
            <if test="iamScore != null">iam_score = #{iamScore},</if>
            <if test="classtwoScore != null">classtwo_score = #{classtwoScore},</if>
            <if test="stuScore != null">stu_score = #{stuScore},</if>
            <if test="cphScore != null">cph_score = #{cphScore},</if>
            <if test="majorRank != null">major_rank = #{majorRank},</if>
            <if test="classRank != null">class_rank = #{classRank},</if>
            <if test="status != null">status = #{status},</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="delFlag != null">del_flag = #{delFlag},</if>
            <if test="majorId != null">major_id = #{majorId},</if>
            <if test="classId != null">class_id = #{classId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCphTotalScoreById" parameterType="Long">
        delete from cph_total_score where id = #{id}
    </delete>

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

</mapper>