<?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.xinelu.manage.mapper.orderevaluateinfo.OrderEvaluateInfoMapper">

    <resultMap type="OrderEvaluateInfo" id="OrderEvaluateInfoResult">
        <result property="id" column="id"/>
        <result property="patientId" column="patient_id"/>
        <result property="openid" column="openid"/>
        <result property="unionid" column="unionid"/>
        <result property="orderNo" column="order_no"/>
        <result property="evaluateContent" column="evaluate_content"/>
        <result property="evaluateChannel" column="evaluate_channel"/>
        <result property="evaluateSatisfaction" column="evaluate_satisfaction"/>
        <result property="compositeScore" column="composite_score"/>
        <result property="orderSource" column="order_source"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectOrderEvaluateInfoVo">
        select id,
               patient_id,
               openid,
               unionid,
               order_no,
               evaluate_content,
               evaluate_channel,
               evaluate_satisfaction,
               composite_score,
               order_source,
               create_by,
               create_time,
               update_by,
               update_time
        from order_evaluate_info
    </sql>

    <select id="selectOrderEvaluateInfoList" parameterType="OrderEvaluateInfo" resultMap="OrderEvaluateInfoResult">
        <include refid="selectOrderEvaluateInfoVo"/>
        <where>
            <if test="patientId != null ">
                and patient_id = #{patientId}
            </if>
            <if test="openid != null  and openid != ''">
                and openid = #{openid}
            </if>
            <if test="unionid != null  and unionid != ''">
                and unionid = #{unionid}
            </if>
            <if test="orderNo != null  and orderNo != ''">
                and order_no = #{orderNo}
            </if>
            <if test="evaluateContent != null  and evaluateContent != ''">
                and evaluate_content = #{evaluateContent}
            </if>
            <if test="evaluateChannel != null  and evaluateChannel != ''">
                and evaluate_channel = #{evaluateChannel}
            </if>
            <if test="evaluateSatisfaction != null  and evaluateSatisfaction != ''">
                and evaluate_satisfaction = #{evaluateSatisfaction}
            </if>
            <if test="compositeScore != null ">
                and composite_score = #{compositeScore}
            </if>
            <if test="orderSource != null  and orderSource != ''">
                and order_source = #{orderSource}
            </if>
        </where>
    </select>

    <select id="selectOrderEvaluateInfoById" resultMap="OrderEvaluateInfoResult">
        <include refid="selectOrderEvaluateInfoVo"/>
        <where>
            <if test="id != null">id = #{id}
            </if>
            <if test="orderNo != null  and orderNo != ''">
                and order_no = #{orderNo}
            </if>
        </where>
    </select>

    <!-- 根据服务编号查询服务评价列表 -->
    <select id="selectOrderEvaluateByServiceNos" resultType="com.xinelu.manage.domain.orderevaluateinfo.OrderEvaluateInfo">
        <include refid="selectOrderEvaluateInfoVo"/>
        where order_no in
        <foreach collection="orderNoList" item="no" open="(" separator="," close=")">#{no}</foreach>
        <if test="orderSource != null and orderSource != ''">
            and order_source = #{orderSource}
        </if>
    </select>

    <insert id="insertOrderEvaluateInfo" parameterType="OrderEvaluateInfo" useGeneratedKeys="true"
            keyProperty="id">
        insert into order_evaluate_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,
            </if>
            <if test="patientId != null">patient_id,
            </if>
            <if test="openid != null">openid,
            </if>
            <if test="unionid != null">unionid,
            </if>
            <if test="orderNo != null">order_no,
            </if>
            <if test="evaluateContent != null">evaluate_content,
            </if>
            <if test="evaluateChannel != null">evaluate_channel,
            </if>
            <if test="evaluateSatisfaction != null">evaluate_satisfaction,
            </if>
            <if test="compositeScore != null">composite_score,
            </if>
            <if test="orderSource != null">order_source,
            </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>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},
            </if>
            <if test="patientId != null">#{patientId},
            </if>
            <if test="openid != null">#{openid},
            </if>
            <if test="unionid != null">#{unionid},
            </if>
            <if test="orderNo != null">#{orderNo},
            </if>
            <if test="evaluateContent != null">#{evaluateContent},
            </if>
            <if test="evaluateChannel != null">#{evaluateChannel},
            </if>
            <if test="evaluateSatisfaction != null">#{evaluateSatisfaction},
            </if>
            <if test="compositeScore != null">#{compositeScore},
            </if>
            <if test="orderSource != null">#{orderSource},
            </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>
        </trim>
    </insert>

    <update id="updateOrderEvaluateInfo" parameterType="OrderEvaluateInfo">
        update order_evaluate_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="patientId != null">patient_id =
                #{patientId},
            </if>
            <if test="openid != null">openid =
                #{openid},
            </if>
            <if test="unionid != null">unionid =
                #{unionid},
            </if>
            <if test="orderNo != null">order_no =
                #{orderNo},
            </if>
            <if test="evaluateContent != null">evaluate_content =
                #{evaluateContent},
            </if>
            <if test="evaluateChannel != null">evaluate_channel =
                #{evaluateChannel},
            </if>
            <if test="evaluateSatisfaction != null">evaluate_satisfaction =
                #{evaluateSatisfaction},
            </if>
            <if test="compositeScore != null">composite_score =
                #{compositeScore},
            </if>
            <if test="orderSource != null">order_source =
                #{orderSource},
            </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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderEvaluateInfoById" parameterType="Long">
        delete
        from order_evaluate_info
        where id = #{id}
    </delete>

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