use of app.hongs.action.anno.Action in project HongsCORE by ihongs.
the class UserAction method doSave.
@Action("save")
@Verify(conf = "master", form = "user")
@CommitSuccess
public void doSave(ActionHelper helper) throws HongsException {
Map rd = helper.getRequestData();
// Ignore empty password in update
if ("".equals(rd.get("password"))) {
rd.remove("password");
rd.remove("passcode");
}
String id = model.set(rd);
Map sd = new HashMap();
sd.put("id", id);
sd.put("name", rd.get("name"));
sd.put("head", rd.get("head"));
CoreLocale ln = CoreLocale.getInstance().clone();
ln.load("master");
String ms = ln.translate("core.save.user.success");
helper.reply(ms, sd);
}
use of app.hongs.action.anno.Action in project HongsCORE by ihongs.
the class WBAction method inWeb.
@Action("web/create")
public void inWeb(ActionHelper helper) throws HongsException {
CoreConfig cc = CoreConfig.getInstance("oauth2");
String appId = cc.getProperty("oauth2.wb.web.app.id");
String appSk = cc.getProperty("oauth2.wb.web.app.key");
String rurl = cc.getProperty("oauth2.wb.wap.bak.url");
String code = helper.getParameter("code");
if (appId == null || appSk == null) {
helper.error500("Not support this mode");
}
Map info = getUserInfo(code, appId, appSk, rurl);
String opnId = (String) info.get("opnid");
String name = (String) info.get("name");
String head = (String) info.get("head");
AuthKit.openSign(helper, "wb", appId, opnId, name, head, System.currentTimeMillis());
ConnKit.redirect(helper);
}
use of app.hongs.action.anno.Action in project HongsCORE by ihongs.
the class DataAction method export.
@Action("stream")
@Preset(conf = "", form = "")
@CustomReplies
public void export(ActionHelper helper) throws HongsException, IOException {
ActionRunner runner = (ActionRunner) helper.getAttribute(ActionRunner.class.getName());
String ent = runner.getEntity();
String mod = runner.getModule();
Data sr = (Data) getEntity(helper);
Map rd = helper.getRequestData();
rd = getReqMap(helper, sr, "export", rd);
int rn = Synt.declare(rd.get("rn"), 0);
int pn = Synt.declare(rd.get("pn"), 0);
Loop lp = sr.search(rd, pn, rn);
/**
* 逐行输出
*/
HttpServletResponse rs = helper.getResponse();
String csv = ent + "_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
rs.setHeader("Content-Disposition", "attachment;filename=" + csv + ".csv");
rs.setHeader("Content-Type", "application/octet-stream;charset=UTF-8");
rs.setHeader("Transfer-Encoding", "chunked");
Writer ot = rs.getWriter();
Map fs = sr.getFields();
Map es = new HashMap();
if (lp.hasNext()) {
Map<String, Object> ds = lp.next();
StringBuilder sf = new StringBuilder();
StringBuilder sb = new StringBuilder();
Map ts = FormSet.getInstance("default").getEnum("__types__");
for (Map.Entry<String, Object> et : ds.entrySet()) {
Object fv = et.getValue();
String fn = et.getKey();
Map mt = (Map) fs.get(fn);
Map ex = null;
String fx, ft;
fx = (String) mt.get("__text__");
ft = (String) mt.get("__type__");
ft = (String) ts.get(ft);
if ("enum".equals(ft)) {
String xonf = (String) mt.get("conf");
String xame = (String) mt.get("enum");
if (null == xonf || "".equals(xonf))
xonf = mod;
if (null == xame || "".equals(xame))
xame = fn;
ex = FormSet.getInstance(xonf).getEnum(xame);
es.put(fn, ex);
}
sf.append(",\"").append(escape(fx, null)).append("\"");
sb.append(",\"").append(escape(fv, ex)).append("\"");
}
ot.write(sf.append("\r\n").substring(1));
ot.write(sb.append("\r\n").substring(1));
ot.flush();
}
while (lp.hasNext()) {
Map<String, Object> ds = lp.next();
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, Object> et : ds.entrySet()) {
Object fv = et.getValue();
String fn = et.getKey();
Map ex = (Map) es.get(fn);
sb.append(",\"").append(escape(fv, ex)).append("\"");
}
ot.write(sb.append("\r\n").substring(1));
}
}
use of app.hongs.action.anno.Action in project HongsCORE by ihongs.
the class FormAction method doDelete.
@Action("delete")
@CommitSuccess
public void doDelete(ActionHelper helper) throws HongsException {
Map data = helper.getRequestData();
int rows = model.delete(data);
CoreLocale lang = CoreLocale.getInstance().clone();
lang.load("matrix");
String ms = lang.translate("core.delete.form.success", Integer.toString(rows));
helper.reply(ms, rows);
}
use of app.hongs.action.anno.Action in project HongsCORE by ihongs.
the class FormAction method getForkList.
@Action("fork/list")
public void getForkList(ActionHelper helper) throws HongsException {
Map data = new HashMap();
Map item;
List list;
// 增加预定列表
Map form = FormSet.getInstance("matrix").getFormTranslated("form_fork");
list = new ArrayList();
for (Map.Entry et : (Set<Map.Entry>) form.entrySet()) {
item = new HashMap();
item.put("__name__", et.getKey());
item.putAll((Map) et.getValue());
}
data.put("list", list);
// 获取全部表单
Table ft = model.table;
Table ut = model.db.getTable("unit");
list = new ArrayList();
getForkList(ft, ut, list, null, "");
data.put("roll", list);
helper.reply(data);
}
Aggregations