-- 菜单命名空间
#namespace("menu")

  -- 查询菜单的ids
  #sql("selectMenuForIds")
    select t1.menu_id,t1.menu_name,t1.parent_id,t1.sort_id,t1.url,t1.memo,t1.create_time,t1.update_ts,t1.level_id,
       (select count(1) from t_base_menu as t2 where t1.menu_id=t2.parent_id) as is_leaf
    from t_base_menu as t1 where t1.menu_id in
                             (
                                 #for(x:ids)
                                     #(for.index == 0 ? "" : ",")  #para(x)
                #end
                                 ) order by t1.sort_id
  #end

    -- 人员根据职务+分管工作可见的菜单
    #sql("selectMenuByPersonId")
        select distinct menu_id from t_base_principalship_menu as t1 inner join t_person_duty_charge as t2 on t1.duties_id=t2.`duties_id`
            and t1.in_charge_id=t2.`in_charge_id` where  t2.person_id=? and t2.b_use=1
    #end
#end