<?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.repair.mapper.RepairArticleTypeMapper">
    <!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.repair.model.vo.RepairWorkTypeVo" id="repairArticleTypeMap">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
    </resultMap>

    <select id="queryArticleTypeList" resultType="com.repair.model.vo.RepairWorkTypeVo" resultMap="repairArticleTypeMap">
       select id,name from repair_article_type
        <where>
            and deleted = 0 and parent_id = 0
            <if test="schoolId != null and schoolId != ''">
                and school_id = #{schoolId}
            </if>
        </where>
    </select>


    <resultMap type="com.repair.model.vo.RepairArticleChildVo" id="repairArticleChildMap">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="childId" column="child_id"/>
    </resultMap>

    <select id="queryArticleChildList" resultType="com.repair.model.vo.RepairArticleChildVo" resultMap="repairArticleChildMap">
        SELECT CONCAT_WS(',', GROUP_CONCAT(rt.id separator','), rat.id) as child_id,rat.id,rat.`name` FROM repair_article_type rat
        left join repair_article_type rt on rt.deleted = 0 and rt.parent_id = rat.id
        where rat.deleted = 0 and rat.parent_id = 0 and rat.school_id = #{schoolId}
        group by rat.id

    </select>
    <!--order by locate(#{keyWord},rat.name) desc 按关键字模糊查询排序-->

</mapper>
