<?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.lantone.security.mapper.RegionMapper">
    <select id="getWard" resultType="com.lantone.security.dto.ViewRegionDTO">
        select t1.name,
        t1.hospital_name as hospitalName,
        t1.id,
        t1.liaison,
        t1.phone_number as phoneNumber,
        t1.order_no as orderNo,
        t1.station,
        t1.code,
        case t1.status
        when 1 then '启用'
        when 0 then '禁用'end as status,
        t1.gmt_create as gmtCreate
        from sys_region t1
        where
        t1.is_deleted = 'N'
        <if test='id != null and id != ""'>
            AND t1.id = #{id}
        </if>
        <if test='hospitalId != null and hospitalId != ""'>
            AND t1.hospital_id = #{hospitalId}
        </if>
        <if test='userId != null and userId != ""'>
            AND t1.creator = #{userId}
        </if>
        <if test='name != null and name != ""'>
            and t1.name like CONCAT('%',#{name},'%')
        </if>
        <if test='status != null'>
            and t1.status = #{status}
        </if>
        order by t1.order_no,t1.gmt_create desc
    </select>
</mapper>