<?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.CphProRankingAllMapper">
    
    <resultMap type="CphProRankingAll" id="CphProRankingAllResult">
        <result property="id"    column="id"    />
        <result property="stuNo"    column="stu_no"    />
        <result property="classId"    column="class_id"    />
        <result property="classCode"    column="class_code"    />
        <result property="courseCredit"    column="course_credit"    />
        <result property="totalCredit"    column="total_credit"    />
        <result property="totalScore"    column="total_score"    />
        <result property="courseNum"    column="course_num"    />
        <result property="avgScore"    column="avg_score"    />
        <result property="avgCredit"    column="avg_credit"    />
        <result property="ranking"    column="ranking"    />
        <result property="nopass"    column="nopass"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createDate"    column="create_date"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateDate"    column="update_date"    />
    </resultMap>

    <sql id="selectCphProRankingAllVo">
        select id, stu_no, class_id, class_code, course_credit, total_credit, total_score, course_num, avg_score, avg_credit, ranking, nopass, status, create_by, create_date, update_by, update_date from cph_pro_ranking_all
    </sql>

    <select id="selectCphProRankingAllList" parameterType="CphProRankingAll" resultMap="CphProRankingAllResult">
        <include refid="selectCphProRankingAllVo"/>
        <where>  
            <if test="stuNo != null  and stuNo != ''"> and stu_no = #{stuNo}</if>
            <if test="classId != null "> and class_id = #{classId}</if>
            <if test="classCode != null  and classCode != ''"> and class_code = #{classCode}</if>
            <if test="courseCredit != null "> and course_credit = #{courseCredit}</if>
            <if test="totalCredit != null "> and total_credit = #{totalCredit}</if>
            <if test="totalScore != null "> and total_score = #{totalScore}</if>
            <if test="courseNum != null "> and course_num = #{courseNum}</if>
            <if test="avgScore != null "> and avg_score = #{avgScore}</if>
            <if test="avgCredit != null "> and avg_credit = #{avgCredit}</if>
            <if test="ranking != null "> and ranking = #{ranking}</if>
            <if test="nopass != null "> and nopass = #{nopass}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="createDate != null "> and create_date = #{createDate}</if>
            <if test="updateDate != null "> and update_date = #{updateDate}</if>
        </where>
    </select>
    
    <select id="selectCphProRankingAllById" parameterType="Long" resultMap="CphProRankingAllResult">
        <include refid="selectCphProRankingAllVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCphProRankingAll" parameterType="CphProRankingAll" useGeneratedKeys="true" keyProperty="id">
        insert into cph_pro_ranking_all
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stuNo != null">stu_no,</if>
            <if test="classId != null">class_id,</if>
            <if test="classCode != null">class_code,</if>
            <if test="courseCredit != null">course_credit,</if>
            <if test="totalCredit != null">total_credit,</if>
            <if test="totalScore != null">total_score,</if>
            <if test="courseNum != null">course_num,</if>
            <if test="avgScore != null">avg_score,</if>
            <if test="avgCredit != null">avg_credit,</if>
            <if test="ranking != null">ranking,</if>
            <if test="nopass != null">nopass,</if>
            <if test="status != null">status,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createDate != null">create_date,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateDate != null">update_date,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stuNo != null">#{stuNo},</if>
            <if test="classId != null">#{classId},</if>
            <if test="classCode != null">#{classCode},</if>
            <if test="courseCredit != null">#{courseCredit},</if>
            <if test="totalCredit != null">#{totalCredit},</if>
            <if test="totalScore != null">#{totalScore},</if>
            <if test="courseNum != null">#{courseNum},</if>
            <if test="avgScore != null">#{avgScore},</if>
            <if test="avgCredit != null">#{avgCredit},</if>
            <if test="ranking != null">#{ranking},</if>
            <if test="nopass != null">#{nopass},</if>
            <if test="status != null">#{status},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createDate != null">#{createDate},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateDate != null">#{updateDate},</if>
         </trim>
    </insert>

    <update id="updateCphProRankingAll" parameterType="CphProRankingAll">
        update cph_pro_ranking_all
        <trim prefix="SET" suffixOverrides=",">
            <if test="stuNo != null">stu_no = #{stuNo},</if>
            <if test="classId != null">class_id = #{classId},</if>
            <if test="classCode != null">class_code = #{classCode},</if>
            <if test="courseCredit != null">course_credit = #{courseCredit},</if>
            <if test="totalCredit != null">total_credit = #{totalCredit},</if>
            <if test="totalScore != null">total_score = #{totalScore},</if>
            <if test="courseNum != null">course_num = #{courseNum},</if>
            <if test="avgScore != null">avg_score = #{avgScore},</if>
            <if test="avgCredit != null">avg_credit = #{avgCredit},</if>
            <if test="ranking != null">ranking = #{ranking},</if>
            <if test="nopass != null">nopass = #{nopass},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createDate != null">create_date = #{createDate},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateDate != null">update_date = #{updateDate},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCphProRankingAllById" parameterType="Long">
        delete from cph_pro_ranking_all where id = #{id}
    </delete>

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