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