<?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.springblade.system.custommenu.mapper.CustomMenuMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="customMenuResultMap" type="org.springblade.system.custommenu.entity.CustomMenu">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="menu_id" property="menuId"/>
        <result column="menu_name" property="menuName"/>
    </resultMap>

    <resultMap id="customMenuVOResultMap" type="org.springblade.system.custommenu.vo.CustomMenuVO" extends="customMenuResultMap">
        <result column="sys_menu_id" property="sysMenuId"/>
        <result column="sys_parent_id" property="sysParentId"/>
        <result column="sys_menu_name" property="sysMenuName"/>
    </resultMap>

    <select id="selectCustomMenuPage" resultMap="customMenuResultMap">
        SELECT menu.id as sys_menu_id, menu.parent_id as sys_parent_id, menu.name as sys_menu_name,
        custom_menu.id, custom_menu.menu_name FROM blade_menu menu
        left join system_custom_menu custom_menu on menu.id = custom_menu.menu_id
        WHERE menu.is_deleted = 0
    </select>

    <select id="getAllList" resultMap="customMenuVOResultMap">
        SELECT menu.id as sys_menu_id, menu.parent_id as sys_parent_id, menu.name as sys_menu_name,
        custom_menu.id, custom_menu.menu_name FROM blade_menu menu
        left join system_custom_menu custom_menu on menu.id = custom_menu.menu_id
        WHERE menu.is_deleted = 0
    </select>

    <select id="getByParentId" resultMap="customMenuVOResultMap">
        SELECT menu.id as sys_menu_id, menu.parent_id as sys_parent_id, menu.name as sys_menu_name,
        custom_menu.id, custom_menu.menu_name FROM blade_menu menu
        left join system_custom_menu custom_menu on menu.id = custom_menu.menu_id
        WHERE menu.is_deleted = 0 and menu.parent_id = #{parentId}
    </select>

</mapper>
