<?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.project.training.spec.mapper.TStSuccessorScoreMapper">

    <resultMap type="TStSuccessorScore" id="TStSuccessorScoreResult">
        <result property="id"    column="id"    />
        <result property="staffId"    column="staff_id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="quarterOne"    column="quarter_one"    />
        <result property="quarterTwo"    column="quarter_two"    />
        <result property="quarterThree"    column="quarter_three"    />
        <result property="quarterFour"    column="quarter_four"    />
        <result property="year"    column="year"    />
    </resultMap>

    <sql id="selectTStSuccessorScoreVo">
        select d.id, d.staff_id, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.quarter_one, d.quarter_two, d.quarter_three, d.quarter_four, d.year
        from t_st_successor_score d
    </sql>

    <select id="selectTStSuccessorScore" parameterType="TStSuccessorScore" resultMap="TStSuccessorScoreResult">
        <include refid="selectTStSuccessorScoreVo"/>
        <where>
            <if test="staffId != null  and staffId != ''"> and staff_id = #{staffId}</if>
            <if test="quarterOne != null  and quarterOne != ''"> and quarter_one = #{quarterOne}</if>
            <if test="quarterTwo != null  and quarterTwo != ''"> and quarter_two = #{quarterTwo}</if>
            <if test="quarterThree != null  and quarterThree != ''"> and quarter_three = #{quarterThree}</if>
            <if test="quarterFour != null  and quarterFour != ''"> and quarter_four = #{quarterFour}</if>
            <if test="year != null "> and year = #{year}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectTStSuccessorScoreList" parameterType="TStSuccessorScore" resultMap="TStSuccessorScoreResult">
        <include refid="selectTStSuccessorScoreVo"/>
        <where>
            <if test="staffId != null  and staffId != ''"> and staff_id = #{staffId}</if>
            <if test="createrCode != null  and createrCode != ''"> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null  and updaterCode != ''"> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="quarterOne != null  and quarterOne != ''"> and quarter_one = #{quarterOne}</if>
            <if test="quarterTwo != null  and quarterTwo != ''"> and quarter_two = #{quarterTwo}</if>
            <if test="quarterThree != null  and quarterThree != ''"> and quarter_three = #{quarterThree}</if>
            <if test="quarterFour != null  and quarterFour != ''"> and quarter_four = #{quarterFour}</if>
            <if test="year != null "> and year = #{year}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectTStSuccessorScoreById" parameterType="Long" resultMap="TStSuccessorScoreResult">
        <include refid="selectTStSuccessorScoreVo"/>
        where id = #{id}
    </select>

    <insert id="insertTStSuccessorScore" parameterType="TStSuccessorScore">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_st_successor_score.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_st_successor_score
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="staffId != null">staff_id,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createrCode != null">creater_code,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
            <if test="quarterOne != null">quarter_one,</if>
            <if test="quarterTwo != null">quarter_two,</if>
            <if test="quarterThree != null">quarter_three,</if>
            <if test="quarterFour != null">quarter_four,</if>
            <if test="year != null">year,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="staffId != null">#{staffId},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
            <if test="quarterOne != null">#{quarterOne},</if>
            <if test="quarterTwo != null">#{quarterTwo},</if>
            <if test="quarterThree != null">#{quarterThree},</if>
            <if test="quarterFour != null">#{quarterFour},</if>
            <if test="year != null">#{year},</if>
         </trim>
    </insert>

    <update id="updateTStSuccessorScore" parameterType="TStSuccessorScore">
        update t_st_successor_score
        <trim prefix="SET" suffixOverrides=",">
            <if test="staffId != null">staff_id = #{staffId},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createrCode != null">creater_code = #{createrCode},</if>
            <if test="createdate != null">createdate = #{createdate},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
            <if test="quarterOne != null">quarter_one = #{quarterOne},</if>
            <if test="quarterTwo != null">quarter_two = #{quarterTwo},</if>
            <if test="quarterThree != null">quarter_three = #{quarterThree},</if>
            <if test="quarterFour != null">quarter_four = #{quarterFour},</if>
            <if test="year != null">year = #{year},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="deleteTStSuccessorScoreById" parameterType="Long">
        update t_st_successor_score set del_flag = 2 where id = #{id}
    </update>

    <update id="deleteTStSuccessorScoreByIds" parameterType="String">
        update t_st_successor_score set del_flag = 2 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

</mapper>
