<?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="agCommon">
    <!-- 查询所有容器-->
    <select id="listcontainer" resultType="map" parameterType="Map">
        select p.*,a.IMAGE_ID,b.name networkname from D_CONTAINER_INFO p,
        d_image_info a,d_network_info b where p.type=a.id(+) and p.NETWORK_NAME=b.id(+)
    </select>
    <!-- 修改容器id-->
    <update id="updatecontainer" parameterType="map">
        update d_container_info set cid=#{cid,jdbcType=VARCHAR}
        where  id = #{id,jdbcType=VARCHAR}
    </update>

    <!--插入容器监控信息-->
    <insert id="insertdockerlog" parameterType="map">
        insert into d_monitor_info(id,c_id,memory,cpu,createdate)
        values(SEQ_D_MONITOR_INFO.nextVal,#{containerid,jdbcType=VARCHAR},#{memory,jdbcType=VARCHAR},#{cpuprecnt,jdbcType=VARCHAR},sysdate)
    </insert>
    <!-- 查询所有容器-->
    <select id="getcontainerinfo" resultType="map" parameterType="Map">
        select to_char(createdate,'yyyy-MM-dd HH24:mi:ss') createdate,memory,cpu from d_monitor_info where c_id=#{cid,jdbcType=VARCHAR} order by createdate
    </select>

    <!-- 查询子系统-->
    <select id="selectRole" resultType="map" parameterType="Map">
        SELECT *
        FROM wb_menu
        WHERE menu_id IN
        (SELECT DISTINCT parent_menu
        FROM wb_menu wm, wb_role_resource wrr
        WHERE     wm.menu_id = wrr.menu_id
        AND wrr.role_id = #{roleId,jdbcType=VARCHAR}
        AND wm.parent_menu IN
        (SELECT menu_id
        FROM wb_menu
        WHERE parent_menu =#{menuida,jdbcType=VARCHAR}AND menu_type = '0'))
        ORDER BY order_index
    </select>
    <!-- 基础查询子系统-->
    <select id="selectRole1" resultType="map" parameterType="Map">
        select wm.*,role_id from wb_menu wm,wb_role_resource wrr where wm.menu_id=wrr.menu_id
        and wm.parent_menu = #{menuId,jdbcType=VARCHAR} and wrr.role_id= #{roleId,jdbcType=VARCHAR}
        order by order_index
    </select>
    <!-- -->
    <select id="selectRoleA" resultType="map" parameterType="Map">
        SELECT *
        FROM wb_menu
        WHERE menu_id IN
        (SELECT DISTINCT parent_menu
        FROM wb_menu wm, wb_role_resource wrr
        WHERE     wm.menu_id = wrr.menu_id
        AND wrr.role_id IN (SELECT role_id
        FROM wb_user_role
        WHERE user_id = #{userId,jdbcType=VARCHAR})
        AND wm.parent_menu IN
        (SELECT menu_id
        FROM wb_menu
        WHERE     parent_menu = #{menuida,jdbcType=VARCHAR}
        AND menu_type = '0'))
        ORDER BY order_index
    </select>
    <select id="selectRoleA1" resultType="map" parameterType="Map">
        SELECT *
        FROM wb_menu
        WHERE     parent_menu = #{menuId,jdbcType=VARCHAR}
        AND menu_id IN
        (SELECT menu_id
        FROM wb_user_role, wb_role_resource
        WHERE     wb_user_role.role_id = wb_role_resource.role_id
        AND user_id =  #{userId,jdbcType=VARCHAR})
        ORDER BY order_index
    </select>

    <!-- 查询菜单位置-->
    <select id="selectWbMenu" parameterType="map" resultType="map">
        select * from wb_menu where parent_menu =
        (select distinct parent_menu from wb_menu where menu_id=#{menuId,jdbcType=VARCHAR} and tenancy_id= #{tenancyId,jdbcType=VARCHAR})
        order by order_index
    </select>

</mapper>
