本文整理汇总了Java中org.nutz.lang.util.NutMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java NutMap.put方法的具体用法?Java NutMap.put怎么用?Java NutMap.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.nutz.lang.util.NutMap
的用法示例。
在下文中一共展示了NutMap.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTemplateShareVars
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
/**
* 模板引擎共用的变量
*/
public static NutMap getTemplateShareVars() {
NutMap share = new NutMap();
Ioc ioc = Mvcs.getIoc();
share.put("ioc", ioc);
PropertiesProxy conf = ioc.get(PropertiesProxy.class, "conf");
share.put("conf", conf.toMap());
if (!conf.getBoolean("cdn.enable", false) || Strings.isBlank(conf.get("cdn.urlbase"))) {
share.put("cdnbase", "");
} else {
share.put("cdnbase", conf.get("cdn.urlbase"));
}
return share;
}
示例2: genJsSDKConfig
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
@Override
public NutMap genJsSDKConfig(String url, String... jsApiList) {
String jt = this.getJsapiTicket();
long timestamp = System.currentTimeMillis();
String nonceStr = R.UU64();
String str = String.format("jsapi_ticket=%s&noncestr=%s×tamp=%d&url=%s", jt, nonceStr, timestamp, url);
String signature = Lang.sha1(str);
NutMap map = new NutMap();
map.put("appId", appid);
map.put("timestamp", timestamp);
map.put("nonceStr", nonceStr);
map.put("signature", signature);
map.put("jsApiList", jsApiList);
return map;
}
示例3: kv2map
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
public static NutMap kv2map(String kv) {
NutMap re = new NutMap();
if (kv == null || kv.length() == 0 || !kv.contains("="))
return re;
String[] tmps = kv.split(",");
for (String tmp : tmps) {
if (!tmp.contains("="))
continue;
String[] tmps2 = tmp.split("=", 2);
re.put(tmps2[0], tmps2[1]);
}
return re;
}
示例4: createQR
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
@Override
public QRTicket createQR(Object sceneId, int expireSeconds) {
String url = mergeCgiBinUrl(createQRCodeURL + getAccessToken());
NutMap data = new NutMap();
NutMap scene;
// 临时二维码
if (expireSeconds > 0) {
data.put("action_name", "QR_SCENE");
data.put("expire_seconds", expireSeconds);
scene = Lang.map("scene_id", Castors.me().castTo(sceneId, Integer.class));
}
// 永久二维码
else if (sceneId instanceof Number) {
data.put("action_name", "QR_LIMIT_SCENE");
scene = Lang.map("scene_id", Castors.me().castTo(sceneId, Integer.class));
}
// 永久字符串二维码
else {
data.put("action_name", "QR_LIMIT_STR_SCENE");
scene = Lang.map("scene_str", sceneId.toString());
}
data.put("action_info", Lang.map("scene", scene));
APIResult ar = wechatServerResponse(url,
HTTP_POST,
Json.toJson(data, JsonFormat.compact()),
"创建公众号[%s]的[%s]场景二维码失败.");
return Json.fromJson(QRTicket.class, Json.toJson(ar.getContent()));
}
示例5: resp
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
public Object resp(Object ctx, String code, String msg) {
NutMap map = new NutMap();
map.put("ok", "true");
map.put("msg", msg);
list.add(map);
return null;
}
示例6: sendTemplateMsg
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
public String sendTemplateMsg(String touser, String template_id, String topcolor, Map<String, WxTemplateData> data) {
if (Strings.isBlank(topcolor))
topcolor = WxTemplateData.DFT_COLOR;
NutMap map = new NutMap();
map.put("touser", touser);
map.put("template_id", template_id);
map.put("topcolor", topcolor);
map.put("data", data);
return call("/message/template/send", METHOD.POST, Json.toJson(map)).get("msgid").toString();
}
示例7: qrconnect
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
@Override
public String qrconnect(String redirect_uri, String scope, String state) {
Request req = Request.create("https://open.weixin.qq.com/connect/qrconnect", METHOD.GET);
NutMap params = new NutMap();
params.put("appid", appid);
if (redirect_uri.startsWith("http"))
params.put("redirect_uri", redirect_uri);
else
params.put("redirect_uri", host + redirect_uri);
params.put("response_type", "code");
params.put("scope", Strings.sBlank(scope, "snsapi_login"));
req.setParams(params);
return req.getUrl().toString() + "#wechat_redirect";
}
示例8: authorize
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
@Override
public String authorize(String redirect_uri, String scope, String state) {
Request req = Request.create("https://open.weixin.qq.com/connect/oauth2/authorize", METHOD.GET);
NutMap params = new NutMap();
params.put("appid", appid);
if (redirect_uri.startsWith("http"))
params.put("redirect_uri", redirect_uri);
else
params.put("redirect_uri", host + redirect_uri);
params.put("response_type", "code");
params.put("scope", Strings.sBlank(scope, "snsapi_userinfo"));
req.setParams(params);
return req.getUrl().toString() + "#wechat_redirect";
}
示例9: access_token
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
@Override
public WxResp access_token(String code) {
Request req = Request.create("https://api.weixin.qq.com/sns/oauth2/access_token", METHOD.GET);
NutMap params = new NutMap();
params.put("appid", appid);
params.put("secret", appsecret);
params.put("code", code);
params.put("grant_type", "authorization_code");
req.setParams(params);
Response resp = Sender.create(req).send();
if (!resp.isOK()) {
return null;
}
return Json.fromJson(WxResp.class, resp.getReader("UTF-8"));
}
示例10: userinfo
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
@Override
public WxResp userinfo(String openid, String access_token) {
// https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID
Request req = Request.create("https://api.weixin.qq.com/sns/userinfo", METHOD.GET);
NutMap params = new NutMap();
params.put("access_token", access_token);
params.put("openid", openid);
req.setParams(params);
Response resp = Sender.create(req).send();
if (!resp.isOK()) {
return null;
}
return Json.fromJson(WxResp.class, resp.getReader("UTF-8"));
}
示例11: postJson
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
protected WxResp postJson(String uri, Object... args) {
NutMap body = new NutMap();
for (int i = 0; i < args.length; i += 2) {
body.put(args[i].toString(), args[i + 1]);
}
return postJson(uri, body);
}
示例12: sendTemplateMsg
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
public String sendTemplateMsg(String touser,
String template_id,
String topcolor,
Map<String, WxTemplateData> data) {
if (Strings.isBlank(topcolor))
topcolor = WxTemplateData.DFT_COLOR;
NutMap map = new NutMap();
map.put("touser", touser);
map.put("template_id", template_id);
map.put("topcolor", topcolor);
map.put("data", data);
return call("/message/template/send", METHOD.POST, Json.toJson(map)).get("msgid")
.toString();
}
示例13: mass_sendall
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
@Override
public WxResp mass_sendall(boolean is_to_all, String group_id, WxOutMsg msg) {
NutMap filter = new NutMap();
filter.put("is_to_all", is_to_all);
if (!is_to_all) {
filter.put("group_id", group_id);
}
return this._mass_send(filter, null, null, msg);
}
示例14: update
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
@Override
public WxResp update(int device_id, String comment) {
NutMap params = new NutMap();
params.put("device_identifier", new NutMap().setv("device_id", device_id));
params.put("comment", comment);
return postJson(ShakeUrlBase + "/device/update", params);
}
示例15: createQRTicket
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
@Override
public WxResp createQRTicket(long expire, Type type, String str) {
NutMap json = NutMap.NEW();
json.put("expire_seconds", expire);
json.put("action_name", type.getValue());
NutMap action = NutMap.NEW();
NutMap scene = NutMap.NEW();
scene.put("scene_str", str);
action.put("scene", scene);
json.put("action_info", action);
return postJson("/qrcode/create", json);
}