Search in sources :

Example 41 with Action

use of io.github.ihongs.action.anno.Action in project HongsCORE by ihongs.

the class DeptAction method getList.

@Action("list")
public void getList(ActionHelper helper) throws HongsException {
    Map rd = helper.getRequestData();
    byte wd = Synt.declare(rd.get("with-depts"), (byte) 0);
    boolean fd = Synt.declare(rd.get("find-depth"), false);
    // With sub depts
    if (fd) {
        String pid = Synt.declare(rd.get("pid"), "");
        if (!"".equals(pid) && !"-".equals(pid)) {
            Collection ids = model.getChildIds(pid, true);
            ids.add(pid);
            rd.put("pid", ids);
        }
    }
    rd = model.getList(rd);
    List<Map> list = (List) rd.get("list");
    if (list != null) {
        // With all depts
        if (wd == 1) {
            for (Map info : list) {
                String id = info.get("id").toString();
                info.put("depts", model.getParentIds(id));
            }
        } else if (wd == 2) {
            for (Map info : list) {
                String id = info.get("id").toString();
                info.put("depts", model.getParents(id));
            }
        }
    }
    helper.reply(rd);
}
Also used : Collection(java.util.Collection) List(java.util.List) HashMap(java.util.HashMap) NaviMap(io.github.ihongs.action.NaviMap) Map(java.util.Map) Action(io.github.ihongs.action.anno.Action)

Example 42 with Action

use of io.github.ihongs.action.anno.Action in project HongsCORE by ihongs.

the class DeptAction method isUnique.

@Action("unique")
public void isUnique(ActionHelper helper) throws HongsException {
    Map rd = helper.getRequestData();
    FetchCase fc = model.fetchCase();
    fc.setOption("INCLUDE_REMOVED", Synt.declare(rd.get("include-removed"), false));
    boolean rv = model.unique(rd, fc);
    helper.reply(null, rv ? 1 : 0);
}
Also used : FetchCase(io.github.ihongs.db.util.FetchCase) HashMap(java.util.HashMap) NaviMap(io.github.ihongs.action.NaviMap) Map(java.util.Map) Action(io.github.ihongs.action.anno.Action)

Example 43 with Action

use of io.github.ihongs.action.anno.Action in project HongsCORE by ihongs.

the class DeptAction method getInfo.

@Action("info")
public void getInfo(ActionHelper helper) throws HongsException {
    Map rd = helper.getRequestData();
    String id = helper.getParameter("id");
    String nc = helper.getParameter("with-roles");
    String ud = (String) helper.getSessibute(Cnst.UID_SES);
    if (id != null && id.length() != 0) {
        rd = model.getInfo(rd);
    } else {
        rd = new HashMap();
    }
    // With all roles
    if (nc != null && nc.length() != 0) {
        List rs = NaviMap.getInstance(nc).getRoleTranslated(0, !Cnst.ADM_UID.equals(ud) ? AuthKit.getUserRoles(ud) : null);
        Dict.put(rd, rs, "enfo", "roles..role");
    }
    helper.reply(rd);
}
Also used : HashMap(java.util.HashMap) List(java.util.List) HashMap(java.util.HashMap) NaviMap(io.github.ihongs.action.NaviMap) Map(java.util.Map) Action(io.github.ihongs.action.anno.Action)

Example 44 with Action

use of io.github.ihongs.action.anno.Action in project HongsCORE by ihongs.

the class DeptAction method doDelete.

@Action("delete")
@CommitSuccess
public void doDelete(ActionHelper helper) throws HongsException {
    Map rd = helper.getRequestData();
    int rn = model.delete(rd);
    CoreLocale ln = CoreLocale.getInstance().clone();
    ln.load("master");
    String ms = ln.translate("core.delete.dept.success", null, Integer.toString(rn));
    helper.reply(ms, rn);
}
Also used : CoreLocale(io.github.ihongs.CoreLocale) HashMap(java.util.HashMap) NaviMap(io.github.ihongs.action.NaviMap) Map(java.util.Map) Action(io.github.ihongs.action.anno.Action) CommitSuccess(io.github.ihongs.action.anno.CommitSuccess)

Example 45 with Action

use of io.github.ihongs.action.anno.Action in project HongsCORE by ihongs.

the class UserAction method getInfo.

@Action("info")
@Select(conf = "master", form = "user")
public void getInfo(ActionHelper helper) throws HongsException {
    Map rd = helper.getRequestData();
    String id = helper.getParameter("id");
    String nc = helper.getParameter("with-roles");
    String ud = (String) helper.getSessibute(Cnst.UID_SES);
    if (id != null && id.length() != 0) {
        rd = model.getInfo(rd);
    } else {
        rd = new HashMap();
    }
    // With all roles
    if (nc != null && nc.length() != 0) {
        List rs = NaviMap.getInstance(nc).getRoleTranslated(0, !Cnst.ADM_UID.equals(ud) ? AuthKit.getUserRoles(ud) : null);
        Dict.put(rd, rs, "enfo", "roles..role");
    }
    // Remove the password field, don't show password in page
    Map info = (Map) rd.get("info");
    if (info != null) {
        info.remove("password");
        info.remove("passcode");
    }
    helper.reply(rd);
}
Also used : HashMap(java.util.HashMap) List(java.util.List) HashMap(java.util.HashMap) NaviMap(io.github.ihongs.action.NaviMap) Map(java.util.Map) Action(io.github.ihongs.action.anno.Action) Select(io.github.ihongs.action.anno.Select)

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