Search in sources :

Example 31 with Action

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

the class JAction method create.

@Override
@Action("create")
@Preset(conf = "", form = "", defs = { ":initial" })
@Verify(conf = "", form = "")
@CommitSuccess
public void create(ActionHelper helper) throws HongsException {
    IEntity sr = getEntity(helper);
    Map rd = helper.getRequestData();
    rd = getReqMap(helper, sr, "create", rd);
    String sn = sr.create(rd);
    String ss = getRspMsg(helper, sr, "create", 1);
    helper.reply(ss, sn);
}
Also used : Map(java.util.Map) Action(io.github.ihongs.action.anno.Action) CommitSuccess(io.github.ihongs.action.anno.CommitSuccess) Preset(io.github.ihongs.action.anno.Preset) Verify(io.github.ihongs.action.anno.Verify)

Example 32 with Action

use of io.github.ihongs.action.anno.Action 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)

Example 33 with Action

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

the class WXAction method inWap.

/**
 * 微信 WAP 登录回调
 * @param helper
 * @throws HongsException
 */
@Action("wap/create")
@CommitSuccess
public void inWap(ActionHelper helper) throws HongsException {
    CoreConfig cc = CoreConfig.getInstance("oauth2");
    String appId = cc.getProperty("oauth2.wx.wap.app.id");
    String appSk = cc.getProperty("oauth2.wx.wap.app.key");
    String code = helper.getParameter("code");
    if (appId == null || appSk == null) {
        helper.error(400, "Not support this mode");
        return;
    }
    try {
        Map info = getUserInfo(code, appId, appSk);
        String opnId = (String) info.get("opnid");
        String opuId = (String) info.get("opuid");
        String name = (String) info.get("name");
        String head = (String) info.get("head");
        Map back = AuthKit.openSign(helper, "wx", Synt.defoult(opuId, opnId), name, head);
        // 登记 openId
        if (opnId != null && opuId != null) {
            String usrId = (String) back.get(Cnst.UID_SES);
            setUserSign("wx.wap", opnId, usrId);
        }
        AuthKit.redirect(helper, back);
    } catch (HongsException ex) {
        AuthKit.redirect(helper, ex);
    }
}
Also used : CoreConfig(io.github.ihongs.CoreConfig) HongsException(io.github.ihongs.HongsException) HashMap(java.util.HashMap) Map(java.util.Map) Action(io.github.ihongs.action.anno.Action) CommitSuccess(io.github.ihongs.action.anno.CommitSuccess)

Example 34 with Action

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

the class WXAction method inWeb.

/**
 * 微信 Web 登录回调
 * @param helper
 * @throws HongsException
 */
@Action("web/create")
@CommitSuccess
public void inWeb(ActionHelper helper) throws HongsException {
    CoreConfig cc = CoreConfig.getInstance("oauth2");
    String appId = cc.getProperty("oauth2.wx.web.app.id");
    String appSk = cc.getProperty("oauth2.wx.web.app.key");
    String code = helper.getParameter("code");
    if (appId == null || appSk == null) {
        helper.error(400, "Not support this mode");
        return;
    }
    try {
        Map info = getUserInfo(code, appId, appSk);
        String opnId = (String) info.get("opnid");
        String opuId = (String) info.get("opuid");
        String name = (String) info.get("name");
        String head = (String) info.get("head");
        Map back = AuthKit.openSign(helper, "wx", Synt.defoult(opuId, opnId), name, head);
        // 登记 openId
        if (opnId != null && opuId != null) {
            String usrId = (String) back.get(Cnst.UID_SES);
            setUserSign("wx.web", opnId, usrId);
        }
        AuthKit.redirect(helper, back);
    } catch (HongsException ex) {
        AuthKit.redirect(helper, ex);
    }
}
Also used : CoreConfig(io.github.ihongs.CoreConfig) HongsException(io.github.ihongs.HongsException) HashMap(java.util.HashMap) Map(java.util.Map) Action(io.github.ihongs.action.anno.Action) CommitSuccess(io.github.ihongs.action.anno.CommitSuccess)

Example 35 with Action

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

the class SignAction method signUpdate.

/**
 * 更新
 * 此动作可维持会话不过期
 * @param ah
 * @throws HongsException
 */
@Action("update")
public void signUpdate(ActionHelper ah) throws HongsException {
    HttpSession ss = ah.getRequest().getSession(false);
    if (null == ss || null == ss.getAttribute(Cnst.UID_SES)) {
        ah.reply(AuthKit.getWrong(null, "core.sign.phase.invalid"));
        return;
    }
    // 登录超时
    String curr_exp_key = AuthFilter.class.getName() + ":expire";
    long exp = Synt.declare(ah.getAttribute(curr_exp_key), 0L);
    long ust = Synt.declare(ss.getAttribute(Cnst.UST_SES), 0L);
    long now = System.currentTimeMillis() / 1000;
    if (exp != 0 && exp <= now - ust) {
        ah.reply(AuthKit.getWrong(null, "core.sign.phase.invalid"));
        return;
    }
    // 重设时间
    if (exp != 0) {
        ss.setAttribute(Cnst.UST_SES, now);
    }
    ah.reply("");
}
Also used : HttpSession(javax.servlet.http.HttpSession) AuthFilter(io.github.ihongs.action.serv.AuthFilter) Action(io.github.ihongs.action.anno.Action)

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