<?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.yonge.cooleshow.admin.dao.PmsProductCategoryDao">
    <resultMap id="listWithChildrenMap" type="com.yonge.cooleshow.admin.dto.PmsProductCategoryWithChildrenItem"
               extends="com.yonge.cooleshow.mbg.mapper.PmsProductCategoryMapper.BaseResultMap">
        <collection property="children" resultMap="com.yonge.cooleshow.mbg.mapper.PmsProductCategoryMapper.BaseResultMap"
                    columnPrefix="child_"></collection>
    </resultMap>
    <select id="listWithChildren" resultMap="listWithChildrenMap">
        select
            c1.id,
            c1.name,
            c2.id   child_id,
            c2.name child_name
        from pms_product_category c1 left join pms_product_category c2 on c1.id = c2.parent_id
        where c1.parent_id = 0
    </select>
</mapper>