Search in sources :

Example 26 with Action

use of app.hongs.action.anno.Action in project HongsCORE by ihongs.

the class DBAction method create.

@Action("create")
@Preset(conf = "", form = "", deft = { ":create" })
@Select(conf = "", form = "", mode = 2)
@Verify(conf = "", form = "")
@CommitSuccess
@Override
public void create(ActionHelper helper) throws HongsException {
    Model ett = getEntity(helper);
    Map req = helper.getRequestData();
    req = getReqMap(helper, ett, "create", req);
    Map rsp = ett.create(req);
    rsp = getRspMap(helper, ett, "create", rsp);
    String msg = getRspMsg(helper, ett, "create", 1);
    helper.reply(msg, rsp);
}
Also used : Map(java.util.Map) Action(app.hongs.action.anno.Action) IAction(app.hongs.dh.IAction) CommitSuccess(app.hongs.action.anno.CommitSuccess) Preset(app.hongs.action.anno.Preset) Select(app.hongs.action.anno.Select) Verify(app.hongs.action.anno.Verify)

Example 27 with Action

use of app.hongs.action.anno.Action in project HongsCORE by ihongs.

the class DBAction method isExists.

@Action("exists")
public void isExists(ActionHelper helper) throws HongsException {
    Model ett = getEntity(helper);
    Map req = helper.getRequestData();
    req = getReqMap(helper, ett, "exists", req);
    FetchCase c = new FetchCase();
    c.setOption("INCLUDE_REMOVED", Synt.declare(req.get("include-removed"), false));
    boolean val = ett.exists(req, c);
    helper.reply(null, val ? 1 : 0);
}
Also used : FetchCase(app.hongs.db.util.FetchCase) Map(java.util.Map) Action(app.hongs.action.anno.Action) IAction(app.hongs.dh.IAction)

Example 28 with Action

use of app.hongs.action.anno.Action in project HongsCORE by ihongs.

the class DBAction method update.

@Action("update")
@Preset(conf = "", form = "", deft = { ":update" })
@Verify(conf = "", form = "")
@CommitSuccess
@Override
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(app.hongs.action.anno.Action) IAction(app.hongs.dh.IAction) CommitSuccess(app.hongs.action.anno.CommitSuccess) Preset(app.hongs.action.anno.Preset) Verify(app.hongs.action.anno.Verify)

Example 29 with Action

use of app.hongs.action.anno.Action in project HongsCORE by ihongs.

the class SearchAction method search.

@Action("search")
@Preset(conf = "", form = "")
@Select(conf = "", form = "")
@Spread(conf = "", form = "")
@Override
public void search(ActionHelper helper) throws HongsException {
    /**
     * 有指定查询条件则按匹配度排序
     */
    Map rd = helper.getRequestData();
    Object wd = rd.get(Cnst.WD_KEY);
    if (null != wd && "".equals(wd)) {
        List ob = Synt.asList(rd.get(Cnst.OB_KEY));
        if (ob == null) {
            ob = new ArrayList();
            rd.put(Cnst.OB_KEY, ob);
            ob.add(0, "-");
        } else if (!ob.contains("-")) {
            ob.add(0, "-");
        }
    }
    super.search(helper);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) Action(app.hongs.action.anno.Action) LuceneAction(app.hongs.dh.lucene.LuceneAction) Spread(app.hongs.action.anno.Spread) Preset(app.hongs.action.anno.Preset) Select(app.hongs.action.anno.Select)

Example 30 with Action

use of app.hongs.action.anno.Action in project HongsCORE by ihongs.

the class FileAction method update.

@Override
@Action("update")
public void update(ActionHelper helper) throws HongsException {
    CoreLocale lang = CoreLocale.getInstance("manage");
    String path = helper.getParameter("path");
    String dist = helper.getParameter("dist");
    String text = helper.getParameter("text");
    File file;
    File dizt;
    if (dist != null && dist.equals(path)) {
        dist = null;
    }
    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 (isDenyFile(file)) {
        helper.fault(lang.translate("core.manage.file.interdicted"));
        return;
    }
    // 改名移动
    if (dist != null) {
        dist = realPath(dist);
        if (dist == null) {
            helper.fault(lang.translate("core.manage.file.path.is.error"));
            return;
        }
        dizt = new File(dist);
        if (dizt.exists()) {
            helper.fault(lang.translate("core.manage.file.dist.is.exist"));
            return;
        }
        if (isDenyFile(file)) {
            helper.fault(lang.translate("core.manage.file.interdicted"));
            return;
        }
        if (!file.renameTo(dizt)) {
            helper.fault(lang.translate("core.manage.file.rename.failed"));
            return;
        }
        if (text == null) {
            return;
        }
        file = dizt;
    }
    // 写入文件
    try {
        saveFile(file, text);
    } catch (Exception ex) {
        CoreLogger.error(ex);
        helper.fault(lang.translate("core.manage.file.update.failed"));
        return;
    }
    helper.reply("");
}
Also used : CoreLocale(app.hongs.CoreLocale) File(java.io.File) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) HongsException(app.hongs.HongsException) IAction(app.hongs.dh.IAction) Action(app.hongs.action.anno.Action)

Aggregations

Action (app.hongs.action.anno.Action)63 Map (java.util.Map)52 HashMap (java.util.HashMap)38 NaviMap (app.hongs.action.NaviMap)16 CommitSuccess (app.hongs.action.anno.CommitSuccess)14 CoreLocale (app.hongs.CoreLocale)12 Preset (app.hongs.action.anno.Preset)12 IAction (app.hongs.dh.IAction)10 RoleMap (app.hongs.serv.auth.RoleMap)10 Verify (app.hongs.action.anno.Verify)9 FetchCase (app.hongs.db.util.FetchCase)8 CoreConfig (app.hongs.CoreConfig)7 Select (app.hongs.action.anno.Select)7 Set (java.util.Set)6 File (java.io.File)5 List (java.util.List)5 HongsException (app.hongs.HongsException)4 ActionRunner (app.hongs.action.ActionRunner)4 LuceneAction (app.hongs.dh.lucene.LuceneAction)3 SearchAction (app.hongs.dh.search.SearchAction)3