Search in sources :

Example 6 with NaviMap

use of io.github.ihongs.action.NaviMap in project HongsCORE by ihongs.

the class Form method filter.

@Override
protected void filter(FetchCase caze, Map rd) throws HongsException {
    super.filter(caze, rd);
    // 超级管理员不做限制
    ActionHelper helper = Core.getInstance(ActionHelper.class);
    String uid = (String) helper.getSessibute(Cnst.UID_SES);
    if (Cnst.ADM_UID.equals(uid)) {
        return;
    }
    String mm = caze.getOption("MODEL_START", "");
    if ("getList".equals(mm) || "getInfo".equals(mm)) {
        mm = "/search";
    } else if ("update".equals(mm) || "delete".equals(mm)) {
        mm = "/" + mm;
    } else {
        // 非常规动作不限制
        return;
    }
    // 从权限串中取表单ID
    NaviMap nm = NaviMap.getInstance(centra);
    String pm = centra + "/";
    Set<String> ra = nm.getRoleSet();
    Set<String> rs = new HashSet();
    for (String rn : ra) {
        if (rn.startsWith(pm) && rn.endsWith(mm)) {
            rs.add(rn.substring(pm.length(), rn.length() - mm.length()));
        }
    }
    // 限制为有权限的表单
    caze.filter("`" + table.name + "`.`id` IN (?)", rs);
}
Also used : ActionHelper(io.github.ihongs.action.ActionHelper) NaviMap(io.github.ihongs.action.NaviMap) HashSet(java.util.HashSet)

Example 7 with NaviMap

use of io.github.ihongs.action.NaviMap in project HongsCORE by ihongs.

the class MenuAction method menu.

@Action("__main__")
public void menu(ActionHelper helper) throws HongsException {
    // 配置名称
    String m = helper.getParameter("m");
    // 节点标识
    String n = helper.getParameter("n");
    // 附加标识(已废弃)
    String x = helper.getParameter("x");
    String u = MENU_ACT_URI;
    if (m == null || "".equals(m)) {
        m = "default";
    }
    u += "?m=" + m;
    if (n != null) {
        u += "&n=" + n;
    }
    if (x != null) {
        u += "&x=" + x;
    }
    NaviMap site = NaviMap.getInstance(m);
    Map menu = (Map) site.getMenu(u);
    if (menu != null) {
        Map mens = (Map) menu.get("menus");
        if (mens != null) {
            // 寻找其下有权限的菜单
            u = getRedirect(site, mens);
            if (u != null) {
                helper.ensue(Core.SERV_PATH + "/" + u);
                return;
            }
        }
        // 找不到则转入后备地址
        // 默认等同模块配置路径
        u = (String) menu.get("hrel");
        if (u != null) {
            helper.ensue(Core.SERV_PATH + "/" + u);
            return;
        } else {
            u = "default".equals(m) ? "" : m;
            helper.ensue(Core.SERV_PATH + "/" + u);
            return;
        }
    }
    throw new HongsException(404, "Can not find the menu " + m);
}
Also used : HongsException(io.github.ihongs.HongsException) NaviMap(io.github.ihongs.action.NaviMap) NaviMap(io.github.ihongs.action.NaviMap) Map(java.util.Map) HashMap(java.util.HashMap) Action(io.github.ihongs.action.anno.Action)

Aggregations

NaviMap (io.github.ihongs.action.NaviMap)7 HongsException (io.github.ihongs.HongsException)4 ActionHelper (io.github.ihongs.action.ActionHelper)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Map (java.util.Map)2 Core (io.github.ihongs.Core)1 CoreSerial (io.github.ihongs.CoreSerial)1 HongsExemption (io.github.ihongs.HongsExemption)1 Action (io.github.ihongs.action.anno.Action)1 JspException (javax.servlet.jsp.JspException)1