<?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.familydoctor.mapper.EvaluateRecordMapper">

    <resultMap id="BaseResultMap" type="com.xinelu.familydoctor.entity.EvaluateRecord">
            <id property="id" column="id" jdbcType="BIGINT"/>
            <result property="userId" column="user_id" jdbcType="BIGINT"/>
            <result property="surveyId" column="survey_id" jdbcType="BIGINT"/>
            <result property="surveySubject" column="survey_subject" jdbcType="VARCHAR"/>
            <result property="evaluateResult" column="evaluate_result" jdbcType="VARCHAR"/>
            <result property="advice" column="advice" jdbcType="VARCHAR"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,user_id,survey_id,survey_subject,
        evaluate_result,advice,create_time
    </sql>

    <select id="getTimeline" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" /> from evaluate_record
        where user_id = #{userId}
        order by id desc
    </select>

    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xinelu.familydoctor.entity.EvaluateRecord" useGeneratedKeys="true">
        insert into evaluate_record
        (user_id,survey_id,survey_subject
        ,evaluate_result,advice,create_time
        )
        values (#{userId,jdbcType=BIGINT},#{surveyId,jdbcType=BIGINT},#{surveySubject,jdbcType=VARCHAR}
        ,#{evaluateResult,jdbcType=VARCHAR},#{advice,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP}
        )
    </insert>
</mapper>
