<?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.ygtx.gxt.mapper.GxtOrderScoreDetailMapper">
    
    <resultMap type="GxtOrderScoreDetail" id="GxtOrderScoreDetailResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="nickName"    column="nick_name"    />
        <result property="orderType"    column="order_type"    />
        <result property="orderId"    column="order_id"    />
        <result property="orderCode"    column="order_code"    />
        <result property="scoreType"    column="score_type"    />
        <result property="score"    column="score"    />
        <result property="rateScore"    column="rate_score"    />
        <result property="runScore"    column="run_score"    />
        <result property="stopScore"    column="stop_score"    />
        <result property="status"    column="status"    />
        <result property="createTimeReal"    column="create_time_real"    />
        <result property="orderCodeRelate"    column="order_code_relate"    />
        <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="selectGxtOrderScoreDetailVo">
        select id, user_id, nick_name, order_type, order_id, order_code, score_type, score, rate_score, run_score, stop_score, status, create_time_real, order_code_relate, create_by, create_time, update_by, update_time, remark from gxt_order_score_detail
    </sql>

    <select id="selectGxtOrderScoreDetailList" parameterType="GxtOrderScoreDetail" resultMap="GxtOrderScoreDetailResult">
        <include refid="selectGxtOrderScoreDetailVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="nickName != null  and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
            <if test="orderType != null "> and order_type = #{orderType}</if>
            <if test="orderId != null "> and order_id = #{orderId}</if>
            <if test="orderCode != null  and orderCode != ''"> and order_code = #{orderCode}</if>
            <if test="scoreType != null "> and score_type = #{scoreType}</if>
            <if test="score != null "> and score = #{score}</if>
            <if test="rateScore != null "> and rate_score = #{rateScore}</if>
            <if test="runScore != null "> and run_score = #{runScore}</if>
            <if test="stopScore != null "> and stop_score = #{stopScore}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="createTimeReal != null "> and create_time_real = #{createTimeReal}</if>
            <if test="orderCodeRelate != null  and orderCodeRelate != ''"> and order_code_relate = #{orderCodeRelate}</if>
        </where>
    </select>
    
    <select id="selectGxtOrderScoreDetailById" parameterType="Long" resultMap="GxtOrderScoreDetailResult">
        <include refid="selectGxtOrderScoreDetailVo"/>
        where id = #{id}
    </select>

    <insert id="insertGxtOrderScoreDetail" parameterType="GxtOrderScoreDetail" useGeneratedKeys="true" keyProperty="id">
        insert into gxt_order_score_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="nickName != null">nick_name,</if>
            <if test="orderType != null">order_type,</if>
            <if test="orderId != null">order_id,</if>
            <if test="orderCode != null">order_code,</if>
            <if test="scoreType != null">score_type,</if>
            <if test="score != null">score,</if>
            <if test="rateScore != null">rate_score,</if>
            <if test="runScore != null">run_score,</if>
            <if test="stopScore != null">stop_score,</if>
            <if test="status != null">status,</if>
            <if test="createTimeReal != null">create_time_real,</if>
            <if test="orderCodeRelate != null">order_code_relate,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="nickName != null">#{nickName},</if>
            <if test="orderType != null">#{orderType},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="orderCode != null">#{orderCode},</if>
            <if test="scoreType != null">#{scoreType},</if>
            <if test="score != null">#{score},</if>
            <if test="rateScore != null">#{rateScore},</if>
            <if test="runScore != null">#{runScore},</if>
            <if test="stopScore != null">#{stopScore},</if>
            <if test="status != null">#{status},</if>
            <if test="createTimeReal != null">#{createTimeReal},</if>
            <if test="orderCodeRelate != null">#{orderCodeRelate},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateGxtOrderScoreDetail" parameterType="GxtOrderScoreDetail">
        update gxt_order_score_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="nickName != null">nick_name = #{nickName},</if>
            <if test="orderType != null">order_type = #{orderType},</if>
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="orderCode != null">order_code = #{orderCode},</if>
            <if test="scoreType != null">score_type = #{scoreType},</if>
            <if test="score != null">score = #{score},</if>
            <if test="rateScore != null">rate_score = #{rateScore},</if>
            <if test="runScore != null">run_score = #{runScore},</if>
            <if test="stopScore != null">stop_score = #{stopScore},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createTimeReal != null">create_time_real = #{createTimeReal},</if>
            <if test="orderCodeRelate != null">order_code_relate = #{orderCodeRelate},</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="deleteGxtOrderScoreDetailById" parameterType="Long">
        delete from gxt_order_score_detail where id = #{id}
    </delete>

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