<?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.diagbot.mapper.MedRecordTypeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.diagbot.entity.MedRecordType">
        <id column="type_id" property="typeId" />
        <result column="hospital_id" property="hospitalId" />
        <result column="type_name" property="typeName" />
        <result column="parent_type_id" property="parentTypeId" />
        <result column="obj_name" property="objName" />
        <result column="spell" property="spell" />
        <result column="remark" property="remark" />
        <result column="is_deleted" property="isDeleted" />
        <result column="gmt_create" property="gmtCreate" />
        <result column="gmt_modified" property="gmtModified" />
        <result column="creator" property="creator" />
        <result column="modifier" property="modifier" />
    </resultMap>

    <update id="updateBatchByKey">
        <foreach collection="list" item="item"  separator=";">
            update med_record_type
            <set>
                <if test="item.typeName != null">
                    type_name = #{item.typeName},
                </if>
                <if test="item.parentTypeId != null">
                    parent_type_id = #{item.parentTypeId},
                </if>
                <if test="item.objName != null">
                    obj_name = #{item.objName},
                </if>
                <if test="item.spell != null">
                    spell = #{item.spell},
                </if>
                <if test="item.gmtModified != null">
                    gmt_modified = #{item.gmtModified},
                </if>
                <if test="item.modifier != null">
                    modifier = #{item.modifier},
                </if>
            </set>
            where type_id = #{item.typeId} and hospital_id = #{item.hospitalId}
        </foreach>
    </update>

</mapper>
