<?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.emr.dao.MedicalRecordHomepageCacheMapper">
  <resultMap id="BaseResultMap" type="com.emr.entity.MedicalRecordHomepageCache">
    <id column="master_id" jdbcType="VARCHAR" property="masterId" />
    <result column="content" jdbcType="NVARCHAR" property="content" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="remark" jdbcType="NVARCHAR" property="remark" />
    <result column="is_add" jdbcType="INTEGER" property="isAdd" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    master_id, content, create_time, remark, is_add
  </sql>
  <select id="selectByExample" parameterType="com.emr.entity.MedicalRecordHomepageCacheExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    'false' as QUERYID,
    <include refid="Base_Column_List" />
    from medical_record_homepage_cache
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from medical_record_homepage_cache
    where master_id = #{masterId,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from medical_record_homepage_cache
    where master_id = #{masterId,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.emr.entity.MedicalRecordHomepageCache">
    insert into medical_record_homepage_cache (master_id, content, create_time, 
      remark, is_add)
    values (#{masterId,jdbcType=VARCHAR}, #{content,jdbcType=NVARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
      #{remark,jdbcType=NVARCHAR}, #{isAdd,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.emr.entity.MedicalRecordHomepageCache">
    insert into medical_record_homepage_cache
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="masterId != null">
        master_id,
      </if>
      <if test="content != null">
        content,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="isAdd != null">
        is_add,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="masterId != null">
        #{masterId,jdbcType=VARCHAR},
      </if>
      <if test="content != null">
        #{content,jdbcType=NVARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=NVARCHAR},
      </if>
      <if test="isAdd != null">
        #{isAdd,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.emr.entity.MedicalRecordHomepageCache">
    update medical_record_homepage_cache
    <set>
      <if test="content != null">
        content = #{content,jdbcType=NVARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=NVARCHAR},
      </if>
      <if test="isAdd != null">
        is_add = #{isAdd,jdbcType=INTEGER},
      </if>
    </set>
    where master_id = #{masterId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.emr.entity.MedicalRecordHomepageCache">
    update medical_record_homepage_cache
    set content = #{content,jdbcType=NVARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      remark = #{remark,jdbcType=NVARCHAR},
      is_add = #{isAdd,jdbcType=INTEGER}
    where master_id = #{masterId,jdbcType=VARCHAR}
  </update>
</mapper>