<?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.Emr_Fault_TypeMapper">
  <resultMap id="BaseResultMap" type="com.emr.entity.Emr_Fault_Type">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="archive_detail_id" jdbcType="NVARCHAR" property="archiveDetailId" />
    <result column="type_flag" jdbcType="NVARCHAR" property="typeFlag" />
    <result column="type_name" jdbcType="NVARCHAR" property="typeName" />
    <result column="type_sort" jdbcType="INTEGER" property="typeSort" />
    <result column="effective" jdbcType="INTEGER" property="effective" />
    <result column="price" jdbcType="DECIMAL" property="price"/>
    <result column="remark" jdbcType="NVARCHAR" property="remark" />
    <result column="creater" jdbcType="NVARCHAR" property="creater" />
    <result column="create_time" jdbcType="NCHAR" property="createTime" />
    <result column="updater" jdbcType="NVARCHAR" property="updater" />
    <result column="update_time" jdbcType="NCHAR" property="updateTime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, archive_detail_id, type_flag, type_name, type_sort, effective,price, remark, creater,
    create_time, updater, update_time
  </sql>
  <select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from emr_fault_type
    where id = #{id,jdbcType=INTEGER}
    order by type_sort
  </select>
  <select id="selectByColDesc"  resultMap="BaseResultMap">
    select
    top(1)
    <include refid="Base_Column_List" />
    from emr_fault_type
    where 1=1
    order by id desc
  </select>
  <select id="selectByCol" parameterType="com.emr.entity.Emr_Fault_Type" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from emr_fault_type
    where 1=1
    <if test="archiveDetailId != null">
      and archive_detail_id = #{archiveDetailId,jdbcType=NVARCHAR}
    </if>
    <if test="typeFlag != null">
      and type_flag = #{typeFlag,jdbcType=NVARCHAR}
    </if>
    <if test="typeName != null">
      and type_name = #{typeName,jdbcType=NVARCHAR}
    </if>
    <if test="typeSort != null">
      and type_sort = #{typeSort,jdbcType=INTEGER}
    </if>
    <if test="effective != null">
      and effective = #{effective,jdbcType=INTEGER}
    </if>
    <if test="remark != null">
      and remark = #{remark,jdbcType=NVARCHAR}
    </if>
    <if test="creater != null">
      and creater = #{creater,jdbcType=NVARCHAR}
    </if>
    <if test="createTime != null">
      and create_time = #{createTime,jdbcType=NCHAR}
    </if>
    <if test="updater != null">
      and updater = #{updater,jdbcType=NVARCHAR}
    </if>
    <if test="updateTime != null">
      and update_time = #{updateTime,jdbcType=NCHAR}
    </if>
    order by type_sort
  </select>
  <delete id="delById" parameterType="java.lang.Integer">
    delete from emr_fault_type
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.emr.entity.Emr_Fault_Type">
    insert into emr_fault_type (id, archive_detail_id, type_flag, 
      type_name, type_sort, effective, price,
      remark, creater, create_time, 
      updater, update_time)
    values (#{id,jdbcType=INTEGER}, #{archiveDetailId,jdbcType=NVARCHAR}, #{typeFlag,jdbcType=NVARCHAR},
      #{typeName,jdbcType=NVARCHAR}, #{typeSort,jdbcType=INTEGER}, #{effective,jdbcType=INTEGER}, #{price,jdbcType=DECIMAL},
      #{remark,jdbcType=NVARCHAR}, #{creater,jdbcType=NVARCHAR}, #{createTime,jdbcType=NCHAR}, 
      #{updater,jdbcType=NVARCHAR}, #{updateTime,jdbcType=NCHAR})
  </insert>
  <insert id="insertClo" parameterType="com.emr.entity.Emr_Fault_Type">
    insert into emr_fault_type
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="archiveDetailId != null">
        archive_detail_id,
      </if>
      <if test="typeFlag != null">
        type_flag,
      </if>
      <if test="typeName != null">
        type_name,
      </if>
      <if test="typeSort != null">
        type_sort,
      </if>
      <if test="effective != null">
        effective,
      </if>
      <if test="price!=null">
        price,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="creater != null">
        creater,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updater != null">
        updater,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="archiveDetailId != null">
        #{archiveDetailId,jdbcType=NVARCHAR},
      </if>
      <if test="typeFlag != null">
        #{typeFlag,jdbcType=NVARCHAR},
      </if>
      <if test="typeName != null">
        #{typeName,jdbcType=NVARCHAR},
      </if>
      <if test="typeSort != null">
        #{typeSort,jdbcType=INTEGER},
      </if>
      <if test="effective != null">
        #{effective,jdbcType=INTEGER},
      </if>
      <if test="price!=null">
        #{price,jdbcType=DECIMAL},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=NVARCHAR},
      </if>
      <if test="creater != null">
        #{creater,jdbcType=NVARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=NCHAR},
      </if>
      <if test="updater != null">
        #{updater,jdbcType=NVARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=NCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByClo" parameterType="com.emr.entity.Emr_Fault_Type">
    update emr_fault_type
    <set>
      <if test="archiveDetailId != null">
        archive_detail_id = #{archiveDetailId,jdbcType=NVARCHAR},
      </if>
      <if test="typeFlag != null">
        type_flag = #{typeFlag,jdbcType=NVARCHAR},
      </if>
      <if test="typeName != null">
        type_name = #{typeName,jdbcType=NVARCHAR},
      </if>
      <if test="typeSort != null">
        type_sort = #{typeSort,jdbcType=INTEGER},
      </if>
      <if test="effective != null">
        effective = #{effective,jdbcType=INTEGER},
      </if>
      <if test="price!=null">
        price=#{price,jdbcType=DECIMAL},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=NVARCHAR},
      </if>
      <if test="creater != null">
        creater = #{creater,jdbcType=NVARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=NCHAR},
      </if>
      <if test="updater != null">
        updater = #{updater,jdbcType=NVARCHAR},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=NCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.emr.entity.Emr_Fault_Type">
    update emr_fault_type
    set archive_detail_id = #{archiveDetailId,jdbcType=NVARCHAR},
      type_flag = #{typeFlag,jdbcType=NVARCHAR},
      type_name = #{typeName,jdbcType=NVARCHAR},
      type_sort = #{typeSort,jdbcType=INTEGER},
      effective = #{effective,jdbcType=INTEGER},
      price=#{score,jdbcType=DECIMAL},
      remark = #{remark,jdbcType=NVARCHAR},
      creater = #{creater,jdbcType=NVARCHAR},
      create_time = #{createTime,jdbcType=NCHAR},
      updater = #{updater,jdbcType=NVARCHAR},
      update_time = #{updateTime,jdbcType=NCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>