use of io.github.ihongs.action.anno.Select in project HongsCORE by ihongs.
the class UserAction method getList.
@Action("list")
@Select(conf = "master", form = "user")
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) {
Dept depth = (Dept) DB.getInstance("master").getModel("dept");
String pid = Synt.declare(rd.get("dept_id"), "");
if (!"".equals(pid) && !"-".equals(pid)) {
Collection ids = depth.getChildIds(pid, true);
ids.add(pid);
rd.put("dept_id", ids);
}
}
rd = model.getList(rd);
List<Map> list = (List) rd.get("list");
if (list != null) {
// With all depts
if (wd == 1) {
Map<String, Map> maps = new HashMap();
for (Map info : list) {
info.put("depts", new HashSet());
maps.put(info.get("id").toString(), info);
}
List<Map> rows = model.db.getTable("dept_user").fetchCase().filter("user_id IN (?)", maps.keySet()).select("user_id, dept_id").getAll();
for (Map dept : rows) {
String uid = dept.remove("user_id").toString();
((Set) maps.get(uid).get("depts")).add(dept);
}
} else if (wd == 2) {
Map<String, Map> maps = new HashMap();
for (Map info : list) {
info.put("depts", new HashSet());
maps.put(info.get("id").toString(), info);
}
List<Map> rows = model.db.getTable("dept_user").fetchCase().join(model.db.getTable("dept").tableName, "dept", "dept_user.dept_id = dept.id").filter("user_id IN (?)", maps.keySet()).select("user_id, dept_id, dept.*").getAll();
for (Map dept : rows) {
String uid = dept.remove("user_id").toString();
((Set) maps.get(uid).get("depts")).add(dept);
}
}
// Remove the password field, don't show password in page
for (Map info : list) {
info.remove("password");
info.remove("passcode");
}
}
helper.reply(rd);
}
use of io.github.ihongs.action.anno.Select 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.Select in project HongsCORE by ihongs.
the class SearchAction method assort.
@Action("assort")
@Preset(conf = "", form = "")
@Select(conf = "", form = "")
public void assort(ActionHelper helper) throws HongsException {
SearchEntity sr = (SearchEntity) getEntity(helper);
StatisHelper sh = new StatisHelper(sr);
Map rd = helper.getRequestData();
rd = getReqMap(helper, sr, "assort", rd);
// 检查参数
acheck(sr, rd, 3);
int rn = Synt.declare(rd.get(Cnst.RN_KEY), 0);
int pn = Synt.declare(rd.get(Cnst.PN_KEY), 1);
Map sd = sh.assort(rd, rn, pn);
sd = getRspMap(helper, sr, "assort", sd);
helper.reply(sd);
}
use of io.github.ihongs.action.anno.Select in project HongsCORE by ihongs.
the class FormAction method getInfo.
@Action("info")
@Select(conf = "matrix", form = "form")
public void getInfo(ActionHelper helper) throws HongsException {
Map rd = helper.getRequestData();
Map sd = model.getInfo(rd);
helper.reply(sd);
}
use of io.github.ihongs.action.anno.Select in project HongsCORE by ihongs.
the class JAction method search.
@Override
@Action("search")
@Preset(conf = "", form = "")
@Select(conf = "", form = "")
public void search(ActionHelper helper) throws HongsException {
IEntity sr = getEntity(helper);
Map rd = helper.getRequestData();
rd = getReqMap(helper, sr, "search", rd);
Map sd = sr.search(rd);
sd = getRspMap(helper, sr, "search", sd);
helper.reply(sd);
}
Aggregations