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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations