use of io.github.ihongs.action.anno.CommitSuccess in project HongsCORE by ihongs.
the class DataAction method revert.
// ** 恢复 **/
@Action("revert")
@CommitSuccess
public void revert(ActionHelper helper) throws HongsException {
Data ett = (Data) getEntity(helper);
Map req = helper.getRequestData();
// 默认的终端标识
String meno = Synt.asString(req.get("meno"));
if (meno == null || meno.isEmpty()) {
req.put("meno", "centra");
} else if (!meno.equals("centra") && !meno.startsWith("centra.")) {
req.put("meno", "centra." + meno);
}
helper.reply("", ett.revert(req));
}
use of io.github.ihongs.action.anno.CommitSuccess in project HongsCORE by ihongs.
the class MineAction method mineSave.
@Action("save")
@Preset(conf = "master", form = "mine")
@Verify(conf = "master", form = "mine", type = 1, trim = 1)
@CommitSuccess
public void mineSave(ActionHelper ah) throws HongsException {
Object id = ah.getSessibute(Cnst.UID_SES);
if (id == null || "".equals(id)) {
throw new HongsException(401, "");
}
Map rd = ah.getRequestData();
rd.put("id", id);
// 禁止危险修改, 其实校验已经做过限制了. 这是以防万一
rd.remove("depts");
rd.remove("roles");
rd.remove("state");
// 验证原始密码
Table ut = DB.getInstance("master").getTable("user");
String pw = (String) rd.get("password");
String po = (String) rd.get("passolde");
if (pw != null && !"".equals(pw)) {
Map xd = new HashMap();
Map ed = new HashMap();
xd.put("ok", false);
xd.put("errs", ed);
xd.put("msg", CoreLocale.getInstance().translate("fore.form.invalid"));
if (po != null && !"".equals(po)) {
Map row = ut.fetchCase().filter("id = ?", id).select("password , passcode").getOne();
String ps = (String) row.get("password");
String pc = (String) row.get("passcode");
if (pc != null)
po += pc;
po = AuthKit.getCrypt(po);
if (!po.equals(ps)) {
ed.put("passolde", "旧密码不正确");
ah.reply(xd);
return;
}
} else {
ed.put("passolde", "请填写旧密码");
ah.reply(xd);
return;
}
}
// 附加验证标识, 当要验证的字段值改变时, 重设为未验证
Map<String, Object> fs = ut.getFields();
Map<String, Object> fz = new HashMap();
for (String fn : fs.keySet()) {
String fx;
if (fn.endsWith("_checked")) {
fx = fn.substring(0, fn.length() - 8);
if (fs.containsKey(fx) && rd.containsKey(fx)) {
fz.put(fx, rd.get(fx));
}
}
}
if (!fz.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (String fn : fz.keySet()) {
sb.append(",`").append(fn).append("`");
}
Map ud = ut.fetchCase().filter("`id` = ?", id).select(sb.substring(1)).getOne();
for (Map.Entry<String, Object> et : fz.entrySet()) {
String fn = et.getKey();
Object fv = et.getValue();
Object fo = ud.get(fn);
if (fv == null || fv.equals("") || !fv.equals(fo)) {
rd.put(et.getKey() + "_checked", "0");
}
}
}
UserAction ua = new UserAction();
ua.doSave(ah);
}
use of io.github.ihongs.action.anno.CommitSuccess in project HongsCORE by ihongs.
the class DBAction method update.
@Override
@Action("update")
@Preset(conf = "", form = "", defs = { ":defence" })
@Verify(conf = "", form = "")
@CommitSuccess
public void update(ActionHelper helper) throws HongsException {
Model ett = getEntity(helper);
Map req = helper.getRequestData();
req = getReqMap(helper, ett, "update", req);
int num = ett.update(req);
String msg = getRspMsg(helper, ett, "update", num);
helper.reply(msg, num);
}
use of io.github.ihongs.action.anno.CommitSuccess 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.CommitSuccess 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