<?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.ModelHospitalMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.diagbot.entity.ModelHospital">
        <id column="id" property="id"/>
        <result column="hospital_id" property="hospitalId"/>
        <result column="hospital_model_name" property="hospitalModelName"/>
        <result column="stand_model_id" property="standModelId"/>
        <result column="stand_model_name" property="standModelName"/>
        <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"/>
        <result column="remark" property="remark"/>
    </resultMap>
    <select id="getModelHospitalAll" parameterType="com.diagbot.vo.ModelHospitalAllVO"
            resultType="com.diagbot.dto.ModelHospitalAllDTO">
        select id as id ,
        hospital_id as hospitalId,
        hospital_model_name as hospitalModelName,
        stand_model_id as standModelId,
        stand_model_name as standModelName,
        gmt_create as gmtCreate ,
        gmt_modified as gmtModified,
        creator as creator,
        modifier as modifier,
        remark as remark
        from qc_model_hospital where is_deleted = "N"
        <if test="hospitalId != null and hospitalId != ''">
            AND hospital_id = #{hospitalId}
        </if>
        <if test="hospitalModelName != null and hospitalModelName != ''">
            AND UPPER(hospital_model_name) LIKE CONCAT('%', UPPER(trim(#{hospitalModelName})), '%')
        </if>
        <if test="standModelId != null and standModelId != ''">
            AND stand_model_id = #{standModelId}
        </if>
        <if test="standModelName != null and standModelName != ''">
            AND UPPER(stand_model_name) LIKE CONCAT('%', UPPER(trim(#{standModelName})), '%')
        </if>
    </select>

</mapper>
