Search in sources :

Example 41 with Action

use of app.hongs.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("navi-conf");
    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 = !Cnst.ADM_UID.equals(ud) ? new RoleMap(NaviMap.getInstance(nc)).getRoleTranslated() : new RoleMap(NaviMap.getInstance(nc)).getRoleTranslates();
        Dict.put(rd, rs, "enum", "roles..role");
    }
    helper.reply(rd);
}
Also used : HashMap(java.util.HashMap) List(java.util.List) HashMap(java.util.HashMap) NaviMap(app.hongs.action.NaviMap) Map(java.util.Map) RoleMap(app.hongs.serv.auth.RoleMap) RoleMap(app.hongs.serv.auth.RoleMap) Action(app.hongs.action.anno.Action)

Example 42 with Action

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

the class UserAction method getInfo.

@Action("info")
public void getInfo(ActionHelper helper) throws HongsException {
    Map rd = helper.getRequestData();
    String id = helper.getParameter("id");
    String nc = helper.getParameter("navi-conf");
    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 = !Cnst.ADM_UID.equals(ud) ? new RoleMap(NaviMap.getInstance(nc)).getRoleTranslated() : new RoleMap(NaviMap.getInstance(nc)).getRoleTranslates();
        Dict.put(rd, rs, "enum", "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(app.hongs.action.NaviMap) Map(java.util.Map) RoleMap(app.hongs.serv.auth.RoleMap) RoleMap(app.hongs.serv.auth.RoleMap) Action(app.hongs.action.anno.Action)

Example 43 with Action

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

the class UserAction method doDelete.

@Action("delete")
@CommitSuccess
public void doDelete(ActionHelper helper) throws HongsException {
    Map rd = helper.getRequestData();
    FetchCase fc = model.fetchCase();
    fc.setOption("INCLUDE_REMOVED", Synt.declare(rd.get("include-removed"), false));
    // 不能删除自己和超级管理员
    Set rs = Synt.asSet(rd.get(model.table.primaryKey));
    if (rs != null) {
        if (rs.contains(helper.getSessibute(Cnst.UID_SES))) {
            helper.fault("不能删除当前登录用户");
            return;
        }
        if (rs.contains(Cnst.ADM_UID)) {
            helper.fault("不能删除超级管理账号");
            return;
        }
    }
    int rn = model.delete(rd, fc);
    CoreLocale ln = CoreLocale.getInstance().clone();
    ln.load("master");
    String ms = ln.translate("core.delete.user.success", Integer.toString(rn));
    helper.reply(ms, rn);
}
Also used : CoreLocale(app.hongs.CoreLocale) FetchCase(app.hongs.db.util.FetchCase) Set(java.util.Set) HashMap(java.util.HashMap) NaviMap(app.hongs.action.NaviMap) Map(java.util.Map) RoleMap(app.hongs.serv.auth.RoleMap) Action(app.hongs.action.anno.Action) CommitSuccess(app.hongs.action.anno.CommitSuccess)

Example 44 with Action

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

the class UserAction 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(app.hongs.db.util.FetchCase) HashMap(java.util.HashMap) NaviMap(app.hongs.action.NaviMap) Map(java.util.Map) RoleMap(app.hongs.serv.auth.RoleMap) Action(app.hongs.action.anno.Action)

Example 45 with Action

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

the class UserAction method getList.

@Action("list")
public void getList(ActionHelper helper) throws HongsException {
    Map rd = helper.getRequestData();
    FetchCase fc = model.fetchCase();
    fc.setOption("INCLUDE_REMOVED", Synt.declare(rd.get("include-removed"), false));
    fc.setOption("INCLUDE_PARENTS", Synt.declare(rd.get("include-parents"), false));
    rd = model.getList(rd, fc);
    // Remove the password field, don't show password in page
    List<Map> list = (List) rd.get("list");
    for (Map info : list) {
        info.remove("password");
        info.remove("passcode");
    }
    helper.reply(rd);
}
Also used : FetchCase(app.hongs.db.util.FetchCase) List(java.util.List) HashMap(java.util.HashMap) NaviMap(app.hongs.action.NaviMap) Map(java.util.Map) RoleMap(app.hongs.serv.auth.RoleMap) 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