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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.diagbot.entity.Part">
        <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="parent_id" property="parentId"/>
        <result column="remark" property="remark"/>
    </resultMap>

    <!-- 通用查询映射结果 -->
    <resultMap id="PartSymptomDTO" type="com.diagbot.dto.PartSymptomDTO">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="parent_id" property="parentId"/>
    </resultMap>

    <!-- 通用查询映射结果 -->
    <resultMap id="PartDTO" type="com.diagbot.dto.PartDTO">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="parent_id" property="parentId"/>
    </resultMap>

    <select id="getByPartId" parameterType="java.util.Map" resultMap="PartSymptomDTO">
        SELECT * FROM `triage_part` where is_deleted = 'N'
        and id in
        <foreach collection="ids" item="id" open="(" separator="," close=")">
             #{id}
        </foreach>
    </select>


    <select id="getByParentId" parameterType="java.util.Map" resultMap="PartDTO">
        SELECT * FROM `triage_part` where is_deleted = 'N'
        and parent_id in
        <foreach collection="ids" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        order by parent_id, order_no
    </select>



</mapper>
