Search in sources :

Example 61 with Action

use of io.github.ihongs.action.anno.Action 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)

Example 62 with Action

use of io.github.ihongs.action.anno.Action in project HongsCORE by ihongs.

the class DBAction method isExists.

@Action("exists")
public void isExists(ActionHelper helper) throws HongsException {
    Model ett = getEntity(helper);
    Map req = helper.getRequestData();
    req = getReqMap(helper, ett, "exists", req);
    FetchCase c = new FetchCase();
    c.setOption("INCLUDE_REMOVED", Synt.declare(req.get("include-removed"), false));
    boolean val = ett.exists(req, c);
    helper.reply(null, val ? 1 : 0);
}
Also used : FetchCase(io.github.ihongs.db.util.FetchCase) Map(java.util.Map) Action(io.github.ihongs.action.anno.Action) IAction(io.github.ihongs.dh.IAction)

Example 63 with Action

use of io.github.ihongs.action.anno.Action in project HongsCORE by ihongs.

the class DBAction method delete.

@Override
@Action("delete")
@Preset(conf = "", form = "", defs = { ":defence" })
@CommitSuccess
public void delete(ActionHelper helper) throws HongsException {
    Model ett = getEntity(helper);
    Map req = helper.getRequestData();
    req = getReqMap(helper, ett, "delete", req);
    int num = ett.delete(req);
    String msg = getRspMsg(helper, ett, "delete", num);
    helper.reply(msg, num);
}
Also used : Map(java.util.Map) Action(io.github.ihongs.action.anno.Action) IAction(io.github.ihongs.dh.IAction) CommitSuccess(io.github.ihongs.action.anno.CommitSuccess) Preset(io.github.ihongs.action.anno.Preset)

Example 64 with Action

use of io.github.ihongs.action.anno.Action in project HongsCORE by ihongs.

the class DBAction method create.

@Override
@Action("create")
@Preset(conf = "", form = "", defs = { ":initial" })
@Verify(conf = "", form = "")
@CommitSuccess
public void create(ActionHelper helper) throws HongsException {
    Model ett = getEntity(helper);
    Map req = helper.getRequestData();
    req = getReqMap(helper, ett, "create", req);
    String nid = ett.create(req);
    String msg = getRspMsg(helper, ett, "create", 1);
    helper.reply(msg, nid);
}
Also used : Map(java.util.Map) Action(io.github.ihongs.action.anno.Action) IAction(io.github.ihongs.dh.IAction) CommitSuccess(io.github.ihongs.action.anno.CommitSuccess) Preset(io.github.ihongs.action.anno.Preset) Verify(io.github.ihongs.action.anno.Verify)

Aggregations

Action (io.github.ihongs.action.anno.Action)64 Map (java.util.Map)53 HashMap (java.util.HashMap)26 CommitSuccess (io.github.ihongs.action.anno.CommitSuccess)22 Preset (io.github.ihongs.action.anno.Preset)15 HongsException (io.github.ihongs.HongsException)14 CoreLocale (io.github.ihongs.CoreLocale)12 NaviMap (io.github.ihongs.action.NaviMap)12 Verify (io.github.ihongs.action.anno.Verify)10 IAction (io.github.ihongs.dh.IAction)10 CoreConfig (io.github.ihongs.CoreConfig)9 Select (io.github.ihongs.action.anno.Select)8 Set (java.util.Set)8 List (java.util.List)7 File (java.io.File)6 HashSet (java.util.HashSet)6 FetchCase (io.github.ihongs.db.util.FetchCase)5 JAction (io.github.ihongs.dh.JAction)4 UserAction (io.github.ihongs.serv.master.UserAction)3 ArrayList (java.util.ArrayList)3