Search in sources :

Example 1 with Select

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);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Collection(java.util.Collection) List(java.util.List) HashMap(java.util.HashMap) NaviMap(io.github.ihongs.action.NaviMap) Map(java.util.Map) HashSet(java.util.HashSet) Action(io.github.ihongs.action.anno.Action) Select(io.github.ihongs.action.anno.Select)

Example 2 with Select

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);
}
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 3 with Select

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

Example 4 with Select

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

Example 5 with Select

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

Aggregations

Action (io.github.ihongs.action.anno.Action)8 Select (io.github.ihongs.action.anno.Select)8 Map (java.util.Map)8 Preset (io.github.ihongs.action.anno.Preset)4 List (java.util.List)3 NaviMap (io.github.ihongs.action.NaviMap)2 JAction (io.github.ihongs.dh.JAction)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 FormSet (io.github.ihongs.action.FormSet)1 IAction (io.github.ihongs.dh.IAction)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1