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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.diagbot.entity.DeptVital">
        <id column="id" property="id" />
        <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="dept_id" property="deptId" />
        <result column="vital_id" property="vitalId" />
        <result column="order_no" property="orderNo" />
        <result column="remark" property="remark" />
    </resultMap>

    <!-- 通用查询映射结果 -->
    <resultMap id="DeptVitalDTOMap" type="com.diagbot.dto.DeptVitalDTO">
        <id column="id" property="id" />
        <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="name" property="name" />
        <result column="remark" property="remark" />
        <result column="operator" property="operator" />
        <result column="gmtOperate" property="gmt_operate" />
    </resultMap>

    <!--查询已有模板分页-->
    <select id="getDeptVitalPage" resultMap="DeptVitalDTOMap">
        SELECT DISTINCT a.*, b.modifier AS operator,b.gmt_modified AS gmt_operate
        FROM icss_dept_info a,icss_dept_vital b
        WHERE a.id = b.dept_id
          AND a.is_deleted = 'N'
          AND b.is_deleted = 'N'
          <if test="deptVitalPageVO.deptName!=null and deptVitalPageVO.deptName!=''">
              AND a.name like CONCAT("%",#{deptVitalPageVO.deptName},"%")
          </if>
        order by gmt_modified desc
    </select>

</mapper>
