<?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="org.diagbot.bigdata.dao.mapper.ResultMappingDiagMapper">
    <!-- 映射定义列-->
    <resultMap type="org.diagbot.bigdata.dao.model.ResultMappingDiag" id="resultMappingDiagMap">
        <id property="id" column="id"/>
        <result property="diagName" column="diag_name"/>
        <result property="deptName" column="dept_name"/>
    </resultMap>

    <!-- 映射定义列-->
    <resultMap type="org.diagbot.bigdata.dao.model.wrapper.ResultMappingDiagWrapper" id="resultMappingDiagWrapperMap">
        <id property="id" column="id"/>
        <result property="diagName" column="diag_name"/>
        <result property="deptName" column="dept_name"/>
    </resultMap>

    <!-- 通用查询结果列-->
    <sql id="Base_Column_List">
		 t.id,	 t.diag_name,	 t.dept_name
	</sql>

    <!-- 查询（根据主键ID查询） -->
    <select id="selectByPrimaryKey" resultMap="resultMappingDiagMap" parameterType="java.lang.Integer">
        SELECT
        <include refid="Base_Column_List"/>
        FROM doc_result_mapping_diag t
        WHERE t.id = #{id}
    </select>

    <!-- 查询（根据主键ID查询） -->
    <select id="selectWrapperByPrimaryKey" resultMap="resultMappingDiagWrapperMap" parameterType="java.lang.Integer">
        SELECT
        <include refid="Base_Column_List"/>
        FROM doc_result_mapping_diag t
        WHERE t.id = #{id}
    </select>

    <!-- 依据Map查询条件返回结果集-->
    <select id="selectList" resultMap="resultMappingDiagMap" parameterType="java.util.Map">
        select diag_name, group_concat(dept_name) dept_name from doc_result_mapping_diag  group by diag_name
    </select>

    <!-- 依据Map查询条件返回扩展属性结果集-->
    <select id="selectListWrapper" resultMap="resultMappingDiagWrapperMap" parameterType="java.util.Map">
        select diag_name, group_concat(dept_name) dept_name from doc_result_mapping_diag  group by diag_name
    </select>

    <!--删除：根据主键ID删除-->
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
		 DELETE FROM doc_result_mapping_diag
		 WHERE id = #{id}
	</delete>
</mapper>