<?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.CphScienceScoreMapper">
    
    <resultMap type="CphScienceScore" id="CphScienceScoreResult">
        <result property="id"    column="id"    />
        <result property="stuYearId"    column="stu_year_id"    />
        <result property="stuYearDm"    column="stu_year_dm"    />
        <result property="stuYearNr"    column="stu_year_nr"    />
        <result property="stuYear"    column="stu_year"    />
        <result property="stuNo"    column="stu_no"    />
        <result property="courseNo"    column="course_no"    />
        <result property="courseCredit"    column="course_credit"    />
        <result property="coursePiont"    column="course_piont"    />
        <result property="courseScore"    column="course_score"    />
        <result property="isPass"    column="is_pass"    />
    </resultMap>

    <sql id="selectCphScienceScoreVo">
        select id, stu_year_id, stu_year_dm, stu_year_nr, stu_year, stu_no, course_no, course_credit, course_piont, course_score, is_pass from cph_science_score
    </sql>

    <select id="selectCphScienceScoreList" parameterType="CphScienceScore" resultMap="CphScienceScoreResult">
        <include refid="selectCphScienceScoreVo"/>
        <where>  
            <if test="stuYearId != null "> and stu_year_id = #{stuYearId}</if>
            <if test="stuYearDm != null  and stuYearDm != ''"> and stu_year_dm = #{stuYearDm}</if>
            <if test="stuYearNr != null  and stuYearNr != ''"> and stu_year_nr = #{stuYearNr}</if>
            <if test="stuYear != null  and stuYear != ''"> and stu_year = #{stuYear}</if>
            <if test="stuNo != null  and stuNo != ''"> and stu_no = #{stuNo}</if>
            <if test="courseNo != null  and courseNo != ''"> and course_no = #{courseNo}</if>
            <if test="courseCredit != null "> and course_credit = #{courseCredit}</if>
            <if test="coursePiont != null "> and course_piont = #{coursePiont}</if>
            <if test="courseScore != null  and courseScore != ''"> and course_score = #{courseScore}</if>
            <if test="isPass != null "> and is_pass = #{isPass}</if>
        </where>
    </select>
    
    <select id="selectCphScienceScoreById" parameterType="Long" resultMap="CphScienceScoreResult">
        <include refid="selectCphScienceScoreVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCphScienceScore" parameterType="CphScienceScore" useGeneratedKeys="true" keyProperty="id">
        insert into cph_science_score
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stuYearId != null">stu_year_id,</if>
            <if test="stuYearDm != null">stu_year_dm,</if>
            <if test="stuYearNr != null">stu_year_nr,</if>
            <if test="stuYear != null">stu_year,</if>
            <if test="stuNo != null">stu_no,</if>
            <if test="courseNo != null">course_no,</if>
            <if test="courseCredit != null">course_credit,</if>
            <if test="coursePiont != null">course_piont,</if>
            <if test="courseScore != null and courseScore != ''">course_score,</if>
            <if test="isPass != null">is_pass,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stuYearId != null">#{stuYearId},</if>
            <if test="stuYearDm != null">#{stuYearDm},</if>
            <if test="stuYearNr != null">#{stuYearNr},</if>
            <if test="stuYear != null">#{stuYear},</if>
            <if test="stuNo != null">#{stuNo},</if>
            <if test="courseNo != null">#{courseNo},</if>
            <if test="courseCredit != null">#{courseCredit},</if>
            <if test="coursePiont != null">#{coursePiont},</if>
            <if test="courseScore != null and courseScore != ''">#{courseScore},</if>
            <if test="isPass != null">#{isPass},</if>
         </trim>
    </insert>

    <update id="updateCphScienceScore" parameterType="CphScienceScore">
        update cph_science_score
        <trim prefix="SET" suffixOverrides=",">
            <if test="stuYearId != null">stu_year_id = #{stuYearId},</if>
            <if test="stuYearDm != null">stu_year_dm = #{stuYearDm},</if>
            <if test="stuYearNr != null">stu_year_nr = #{stuYearNr},</if>
            <if test="stuYear != null">stu_year = #{stuYear},</if>
            <if test="stuNo != null">stu_no = #{stuNo},</if>
            <if test="courseNo != null">course_no = #{courseNo},</if>
            <if test="courseCredit != null">course_credit = #{courseCredit},</if>
            <if test="coursePiont != null">course_piont = #{coursePiont},</if>
            <if test="courseScore != null and courseScore != ''">course_score = #{courseScore},</if>
            <if test="isPass != null">is_pass = #{isPass},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCphScienceScoreById" parameterType="Long">
        delete from cph_science_score where id = #{id}
    </delete>

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