<?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.bonus.sgzb.app.mapper.AppMenuMapper">
    <insert id="addMenuById">
        insert into app_menu_user
            (menu_id,user_id)
        VALUES
            (#{appMenuId},#{userId})
    </insert>
    <delete id="delMenuById">
        delete
        from app_menu_user
        where menu_id = #{appMenuId} and user_id = #{userId}
    </delete>

    <select id="getAllMenu" resultType="com.bonus.sgzb.app.domain.AppMenu">
        select id,
               icon_name as iconName,
               icon_mark as iconMark,
               p_id as pId,
               type as type,
               status as status,
               order_num as orderNum
        from app_menu
        where status = '1' and p_id != 0
    </select>
    <select id="getMenuById" resultType="com.bonus.sgzb.app.domain.AppMenu">
        select amu.id,
               amu.menu_id as menuId,
               am.icon_name as iconName,
               am.icon_mark as iconMark
        from app_menu_user amu
        left join app_menu am on am.id = amu.menu_id
        where user_id = #{userId}
    </select>
</mapper>
