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);
}
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);
}
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);
}
}
}
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);
}
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);
}
Aggregations