Search in sources :

Example 16 with Action

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("");
}
Also used : CoreLocale(io.github.ihongs.CoreLocale) File(java.io.File) Action(io.github.ihongs.action.anno.Action) IAction(io.github.ihongs.dh.IAction)

Example 17 with Action

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());
}
Also used : Capts(io.github.ihongs.util.sketch.Capts) Action(io.github.ihongs.action.anno.Action)

Example 18 with Action

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);
}
Also used : FetchCase(io.github.ihongs.db.util.FetchCase) Map(java.util.Map) Action(io.github.ihongs.action.anno.Action) IAction(io.github.ihongs.dh.IAction)

Example 19 with Action

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);
}
Also used : Map(java.util.Map) Action(io.github.ihongs.action.anno.Action) IAction(io.github.ihongs.dh.IAction) Preset(io.github.ihongs.action.anno.Preset) Select(io.github.ihongs.action.anno.Select)

Example 20 with Action

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);
}
Also used : Map(java.util.Map) Action(io.github.ihongs.action.anno.Action) IAction(io.github.ihongs.dh.IAction) CommitSuccess(io.github.ihongs.action.anno.CommitSuccess) Preset(io.github.ihongs.action.anno.Preset) Verify(io.github.ihongs.action.anno.Verify)

Aggregations

Action (io.github.ihongs.action.anno.Action)64 Map (java.util.Map)53 HashMap (java.util.HashMap)26 CommitSuccess (io.github.ihongs.action.anno.CommitSuccess)22 Preset (io.github.ihongs.action.anno.Preset)15 HongsException (io.github.ihongs.HongsException)14 CoreLocale (io.github.ihongs.CoreLocale)12 NaviMap (io.github.ihongs.action.NaviMap)12 Verify (io.github.ihongs.action.anno.Verify)10 IAction (io.github.ihongs.dh.IAction)10 CoreConfig (io.github.ihongs.CoreConfig)9 Select (io.github.ihongs.action.anno.Select)8 Set (java.util.Set)8 List (java.util.List)7 File (java.io.File)6 HashSet (java.util.HashSet)6 FetchCase (io.github.ihongs.db.util.FetchCase)5 JAction (io.github.ihongs.dh.JAction)4 UserAction (io.github.ihongs.serv.master.UserAction)3 ArrayList (java.util.ArrayList)3