Search in sources :

Example 26 with Action

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

the class FormAction method doSave.

@Action("save")
public void doSave(ActionHelper helper) throws HongsException {
    Map rd = helper.getRequestData();
    String id = model.set(rd);
    CoreLocale ln = CoreLocale.getInstance().clone();
    ln.load("matrix");
    String ms = ln.translate("core.save.form.success");
    helper.reply(ms, id);
}
Also used : CoreLocale(io.github.ihongs.CoreLocale) Map(java.util.Map) Action(io.github.ihongs.action.anno.Action)

Example 27 with Action

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

the class UnitAction method getInfo.

@Action("info")
public void getInfo(ActionHelper helper) throws HongsException {
    Map rd = helper.getRequestData();
    Map sd = model.getInfo(rd);
    helper.reply(sd);
}
Also used : Map(java.util.Map) Action(io.github.ihongs.action.anno.Action)

Example 28 with Action

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

the class CoreRoster method addActs.

private static void addActs(Map<String, Mathod> acts, Action anno, String clsn, Class clso) {
    String actn = anno.value();
    if (actn == null || actn.length() == 0) {
        actn = clsn.replace('.', '/');
    }
    Method[] mtds = clso.getMethods();
    for (Method mtdo : mtds) {
        String mtdn = mtdo.getName();
        // 从注解提取动作名
        Action annx = (Action) mtdo.getAnnotation(Action.class);
        if (annx == null) {
            continue;
        }
        String actx = annx.value();
        if (actx == null || actx.length() == 0) {
            actx = mtdn;
        }
        // 检查方法是否合法
        Class[] prms = mtdo.getParameterTypes();
        if (prms == null || prms.length != 1 || !ActionHelper.class.isAssignableFrom(prms[0])) {
            throw new HongsExemption(832, "Can not find action method '" + clsn + "." + mtdn + "(ActionHelper)'.");
        }
        Mathod mtdx = new Mathod();
        mtdx.method = mtdo;
        mtdx.mclass = clso;
        if ("__main__".equals(actx)) {
            acts.put(actn, /*__main__*/
            mtdx);
        } else {
            acts.put(actn + "/" + actx, mtdx);
        }
    }
}
Also used : Action(io.github.ihongs.action.anno.Action) Method(java.lang.reflect.Method)

Example 29 with Action

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

the class JAction method delete.

@Override
@Action("delete")
@Preset(conf = "", form = "", defs = { ":defence" })
@CommitSuccess
public void delete(ActionHelper helper) throws HongsException {
    IEntity sr = getEntity(helper);
    Map rd = helper.getRequestData();
    rd = getReqMap(helper, sr, "delete", rd);
    int sn = sr.delete(rd);
    String ss = getRspMsg(helper, sr, "delete", sn);
    helper.reply(ss, sn);
}
Also used : Map(java.util.Map) Action(io.github.ihongs.action.anno.Action) CommitSuccess(io.github.ihongs.action.anno.CommitSuccess) Preset(io.github.ihongs.action.anno.Preset)

Example 30 with Action

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

the class JAction method update.

@Override
@Action("update")
@Preset(conf = "", form = "", defs = { ":defence" })
@Verify(conf = "", form = "")
@CommitSuccess
public void update(ActionHelper helper) throws HongsException {
    IEntity sr = getEntity(helper);
    Map rd = helper.getRequestData();
    rd = getReqMap(helper, sr, "update", rd);
    int sn = sr.update(rd);
    String ss = getRspMsg(helper, sr, "update", sn);
    helper.reply(ss, sn);
}
Also used : Map(java.util.Map) Action(io.github.ihongs.action.anno.Action) 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