use of io.github.ihongs.action.anno.Action in project HongsCORE by ihongs.
the class FileAction method delete.
@Override
@Action("delete")
public void delete(ActionHelper helper) throws HongsException {
CoreLocale lang = CoreLocale.getInstance("manage");
Set<String> list = Synt.asSet(helper.getRequestData().get("path"));
if (list == null || list.isEmpty()) {
helper.fault(lang.translate("core.manage.file.path.required"));
return;
}
for (String path : list) {
File file;
if (path == null) {
helper.fault(lang.translate("core.manage.file.path.required"));
return;
}
path = realPath(path);
if (path == null) {
helper.fault(lang.translate("core.manage.file.path.is.error"));
return;
}
file = new File(path);
if (!file.exists()) {
helper.fault(lang.translate("core.manage.file.path.is.not.exist"));
return;
}
if (isDenyDire(file)) {
helper.fault(lang.translate("core.manage.file.path.is.not.empty"));
return;
}
if (isDenyFile(file)) {
helper.fault(lang.translate("core.manage.file.interdicted"));
return;
}
if (!file.delete()) {
helper.fault(lang.translate("core.manage.file.delete.failed"));
return;
}
}
helper.reply("");
}
use of io.github.ihongs.action.anno.Action in project HongsCORE by ihongs.
the class CaptAction method create.
@Action("create")
public void create(ActionHelper helper) throws HongsException, IOException {
int h = Synt.declare(helper.getParameter("h"), 40);
String b = Synt.declare(helper.getParameter("b"), "");
String f = Synt.declare(helper.getParameter("f"), "");
String e = Synt.declare(helper.getParameter("e"), "png");
Capts vc = Capts.captcha(h, b, f);
// 设置会话
String ss = CoreConfig.getInstance().getProperty("core.capt.session", "capt");
helper.setSessibute(ss + "_code", /**/
vc.getCode());
helper.setSessibute(ss + "_time", System.currentTimeMillis());
// 禁止缓存
helper.getResponse().setContentType("image/" + e);
helper.getResponse().setDateHeader("Expires", 0);
helper.getResponse().setHeader("Pragma", "no-cache");
helper.getResponse().setHeader("Cache-Control", "no-cache");
vc.write(e, helper.getResponse().getOutputStream());
}
use of io.github.ihongs.action.anno.Action in project HongsCORE by ihongs.
the class DBAction method isUnique.
@Action("unique")
public void isUnique(ActionHelper helper) throws HongsException {
Model ett = getEntity(helper);
Map req = helper.getRequestData();
req = getReqMap(helper, ett, "unique", req);
FetchCase c = new FetchCase();
c.setOption("INCLUDE_REMOVED", Synt.declare(req.get("include-removed"), false));
boolean val = ett.unique(req, c);
helper.reply(null, val ? 1 : 0);
}
use of io.github.ihongs.action.anno.Action in project HongsCORE by ihongs.
the class DBAction method search.
@Override
@Action("search")
@Preset(conf = "", form = "")
@Select(conf = "", form = "")
public void search(ActionHelper helper) throws HongsException {
Model ett = getEntity(helper);
Map req = helper.getRequestData();
req = getReqMap(helper, ett, "search", req);
Map rsp = ett.search(req);
rsp = getRspMap(helper, ett, "search", rsp);
helper.reply(rsp);
}
use of io.github.ihongs.action.anno.Action 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);
}
Aggregations