<?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.recordType.Emr_Type_RelatedMapper" >
  <resultMap id="BaseResultMap" type="com.emr.entity.recordType.Emr_Type_Related" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="type_id" property="typeId" jdbcType="INTEGER" />
    <result column="assort_id" property="assortId" jdbcType="VARCHAR" />
    <result column="creater" property="creater" jdbcType="NVARCHAR" />
    <result column="create_time" property="createTime" jdbcType="NCHAR" />
    <result column="updater" property="updater" jdbcType="NVARCHAR" />
    <result column="update_time" property="updateTime" jdbcType="NCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, type_id, assort_id, creater, create_time, updater, update_time
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from emr_type_related
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from emr_type_related
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.emr.entity.recordType.Emr_Type_Related" >
    insert into emr_type_related (type_id, assort_id,
      creater, create_time, updater, 
      update_time)
    values (#{typeId,jdbcType=INTEGER}, #{assortId,jdbcType=VARCHAR},
      #{creater,jdbcType=NVARCHAR}, #{createTime,jdbcType=NCHAR}, #{updater,jdbcType=NVARCHAR}, 
      #{updateTime,jdbcType=NCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.emr.entity.recordType.Emr_Type_Related" >
    insert into emr_type_related
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="typeId != null" >
        type_id,
      </if>
      <if test="assortId != null" >
        assort_id,
      </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="typeId != null" >
        #{typeId,jdbcType=INTEGER},
      </if>
      <if test="assortId != null" >
        #{assortId,jdbcType=VARCHAR},
      </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="updateByPrimaryKeySelective" parameterType="com.emr.entity.recordType.Emr_Type_Related" >
    update emr_type_related
    <set >
      <if test="typeId != null" >
        type_id = #{typeId,jdbcType=INTEGER},
      </if>
      <if test="assortId != null" >
        assort_id = #{assortId,jdbcType=VARCHAR},
      </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.recordType.Emr_Type_Related" >
    update emr_type_related
    set type_id = #{typeId,jdbcType=INTEGER},
      assort_id = #{assortId,jdbcType=VARCHAR},
      creater = #{creater,jdbcType=NVARCHAR},
      create_time = #{createTime,jdbcType=NCHAR},
      updater = #{updater,jdbcType=NVARCHAR},
      update_time = #{updateTime,jdbcType=NCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <!--根据分类id查分段id集合-->
  <select id="selectAssortIdsByTypeId" resultMap="BaseResultMap" parameterType="java.lang.Integer">
      SELECT
          type_id,assort_id
      FROM
          emr_type_related
      WHERE
          type_id = #{typeId}
  </select>
  <!--根据分类Id删除集合-->
  <delete id="deleteByTypeId"  parameterType="java.lang.Integer">
    delete from emr_type_related
    where type_id = #{typeId,jdbcType=INTEGER}
  </delete>
  <!--批量插入-->
  <insert id="SimpleInsert" parameterType="java.util.List">
      INSERT INTO
        emr_type_related(
          type_id, assort_id, creater, create_time, updater, update_time
        )
      <foreach collection="list" item="item" separator="union">
        select
          #{item.typeId,jdbcType=INTEGER}, #{item.assortId,jdbcType=VARCHAR},
          #{item.creater,jdbcType=NVARCHAR}, #{item.createTime,jdbcType=NCHAR}, #{item.updater,jdbcType=NVARCHAR},
          #{item.updateTime,jdbcType=NCHAR}
      </foreach>
  </insert>
</mapper>