use of app.hongs.action.SpreadHelper in project HongsCORE by ihongs.
the class DataAction method list.
@Action("revert/search")
public void list(ActionHelper helper) throws HongsException {
ActionRunner runner = (ActionRunner) helper.getAttribute(ActionRunner.class.getName());
String ent = runner.getEntity();
String mod = runner.getModule();
Data sr = (Data) getEntity(helper);
Model mo = sr.getModel();
Map rd = helper.getRequestData();
rd.remove("user_id");
rd.put("form_id", sr.getFormId());
Map sd = mo.search(rd);
// 详情数据转换
if (sd.containsKey("info")) {
Map df = (Map) sd.remove("info");
Map dt = (Map) app.hongs.util.Data.toObject((String) df.remove("data"));
sd.put("logs", df);
sd.put("info", dt);
// 补充枚举和关联
Set ab = Synt.toTerms(rd.get(Cnst.AB_KEY));
if (ab != null) {
byte md = 0;
if (ab.contains("_enum")) {
md += 2;
}
if (ab.contains("_time")) {
md += 4;
}
if (ab.contains("_link")) {
md += 8;
}
if (md != 0) {
new SelectHelper().addItemsByForm(mod, ent).select(sd, md);
}
if (ab.contains("_fork")) {
new SpreadHelper().addItemsByForm(mod, ent).spread(sd);
}
}
}
helper.reply(sd);
}
use of app.hongs.action.SpreadHelper in project HongsCORE by ihongs.
the class SpreadInvoker method invoke.
@Override
public void invoke(ActionHelper helper, ActionRunner chains, Annotation anno) throws HongsException {
Spread ann = (Spread) anno;
String conf = ann.conf();
String form = ann.form();
byte mode = ann.mode();
if (mode == -1) {
Set ab = Synt.toTerms(helper.getRequestData().get(Cnst.AB_KEY));
if (ab != null) {
if (ab.contains("_fork")) {
mode = 1;
}
}
}
// 执行动作
chains.doAction();
Map rsp = helper.getResponseData();
if (01 != mode) {
return;
}
// 识别路径
if (form.length() == 0) {
form = chains.getEntity();
}
if (conf.length() == 0) {
conf = chains.getModule();
// 照顾 Module Action 的配置规则
if (FormSet.hasConfFile(conf + "/" + form)) {
conf = conf + "/" + form;
}
}
// 填充数据
try {
Map data = (Map) helper.getAttribute("form:" + conf + "." + form);
if (data == null) {
data = FormSet.getInstance(conf).getForm(form);
}
SpreadHelper sup;
sup = new SpreadHelper().addItemsByForm(conf, data);
sup.spread(rsp);
} catch (HongsException ex) {
int ec = ex.getErrno();
if (ec != 0x10e8 && ec != 0x10e9 && ec != 0x10ea) {
throw ex;
}
}
// 返回数据
helper.reply(rsp);
}
Aggregations