本文整理汇总了Java中org.nutz.lang.util.NutMap.setv方法的典型用法代码示例。如果您正苦于以下问题:Java NutMap.setv方法的具体用法?Java NutMap.setv怎么用?Java NutMap.setv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.nutz.lang.util.NutMap
的用法示例。
在下文中一共展示了NutMap.setv方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyFriend
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
/**
* 申请添加好友
* @param me 我的id
* @param uid 对方id
* @param from_group 到哪个分组?
* @return
*/
@At
public Object applyFriend(@Attr("me") int me,@Param("uid")int uid,@Param("from_group")int from_group ,@Param("remark")String remark){
NutMap nm = new NutMap();
if(!isFirend(me,uid)) {
int i = userDao.applyFriend(uid, me, from_group, remark);
if (1 > 0){
SocketUtils.sendByUserId(String.valueOf(uid), SocketMsgUtils.madeWsResponse(Type.REQFRIEND, "1"));
nm.setv("ok", 1);
}else
nm.setv("ok", 0);
}else{
return Response.fail("对方已经是您的好友,不可重复添加哦!");
}
return nm;
}
示例2: genTagPages
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void genTagPages(Rendering ing) {
if (!Strings.isBlank(tagPath)) {
log.infof("make tags >> %s/*", tagPath);
// 得到文档模板对象
ZDocRule rule = getRule(tagPath);
if (null == rule) {
log.warnf("No rule for '%s' when genTagPages", tagPath);
return;
}
ZDocTemplate tmpl = ing.tfa().getTemplte(rule.key());
NutMap page = new NutMap();
page.setv("bpath", "../");
ing.context().setv("page", page);
Map<String, ZDocTag> tags = ing.context().getAs("tags", Map.class);
for (ZDocTag tag : tags.values()) {
_gen_tag_page(ing, tmpl, page, tag);
}
// 生成 others Tag
_gen_tag_page(ing, tmpl, page, othersTag);
} else {
log.info("! Ignore tags");
}
}
示例3: _gen_tag_page
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
private void _gen_tag_page(Rendering ing,
ZDocTemplate tmpl,
NutMap page,
ZDocTag tag) {
page.setv("title", tag.getText());
ing.context().setv("tag", tag.genItems());
// 在目标目录创建对应文件
ZFile destf = dest.createFileIfNoExists(tagPath
+ "/"
+ tag.getKey()
+ ".html");
// 准备渲染
Writer wr = Streams.utf8w(ing.io().openOutputStream(destf));
tmpl.outputTo(wr, ing.context());
Streams.safeClose(wr);
}
示例4: addFridend
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
/**
* 同意添加
* @param me 我的id
* @param uid 对方的id
* @param group 我要添加到的分组id
* @param from_group 对方要添加到的分组id
* @return
*/
@At
public Object addFridend(@Attr("me") int me,@Param("uid") int uid,@Param("group") int group,@Param("from_group") int from_group,@Param("msgid")int msgid){
NutMap nm = new NutMap();
//将对方添加成我的好友
int id = userDao.addFriend(me, uid, group);
//将我添加成对方的好友
int i = userDao.addFriend(uid, me, from_group);
System.out.println("加好友成功!");
//更新消息状态
userDao.updateMsg(msgid, 3); //更新状态为已同意
//给对方发送一个添加成功的消息
Message msg = new Message();
msg.setContent("成功添加对方为好友!");
msg.setUid(uid);
msg.setFrom(me);
msg.setFrom_group(from_group);;
msg.setType(3);
msg.setRead(1);
msg.setTime(new Date());
msg.setRemark("");
Message i2= dao.insert(msg);
User fetch = dao.fetch(User.class, me);
NutMap n = new NutMap();
n.setv("user",fetch);
n.setv("group",from_group);
SocketUtils.sendByUserId(String.valueOf(uid),SocketMsgUtils.madeWsResponse(Type.REQFRIENDSUCCESS,Json.toJson(n)));
nm.setv("code", 0);
return nm;
}
示例5: declineApply
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
/**
* 拒绝添加
* @param me
* @param msgid
* @return
*/
@At
public Object declineApply(@Attr("me") int me,@Param("msgid")int msgid,@Param("remark")String remark){
NutMap nm = new NutMap();
//更新消息状态
userDao.updateMsg(msgid, 2);
//给对方发一条拒绝通知
Message fetch = dao.fetch(Message.class, msgid);
Message msg = new Message();
msg.setType(2);
msg.setContent("对方拒绝了您的请求消息");
msg.setUid(fetch.getFrom());
msg.setFrom(me);
msg.setFrom_group(fetch.getFrom_group());
msg.setRemark(remark);
msg.setHref("");
msg.setRead(0);
msg.setTime(new Date());
dao.insert(msg);
//socket通知对方
SocketUtils.sendByUserId(String.valueOf(fetch.getFrom()), SocketMsgUtils.madeWsResponse(Type.REQFRIEND, "1"));
nm.setv("code", 0);
return nm;
}
示例6: test
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
@At
public Object test(){
NutMap nm = new NutMap();
String contextPath = Mvcs.getServletContext().getContextPath();
String realPath = Mvcs.getServletContext().getRealPath("/");
String parent = new File(realPath).getParent();
nm.setv("contextPath",contextPath);
nm.setv("realPath",realPath);
nm.setv("parent",parent);
return nm;
}
示例7: mapField
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public static void mapField(StringBuilder sb, Class<?> klass, Field field) {
sb.append("\r\n");
String fieldName = field.getName();
String className = klass.getSimpleName();
Mirror mirror = Mirror.me(field.getType());
String getterTmpl = "return (${fieldType})get(\"${fieldName}\")";
if (mirror.isPrimitiveNumber()) {
if (mirror.isBoolean()) {
getterTmpl = "return getBoolean(\"${fieldName}\", false)";
} else {
getterTmpl = "return get"
+ Strings.upperFirst(mirror.getType().getSimpleName())
+ "(\"${fieldName}\", 0)";
}
}
Tmpl tmpl = Tmpl.parse(" public ${className} set${upperFieldName}(${fieldType} ${fieldName}){\r\n"
+ " put(\"${fieldName}\", ${fieldName});\r\n"
+ " return this;\r\n"
+ " }\r\n"
+ "\r\n"
+ " public ${fieldType} get${upperFieldName}(){\r\n"
+ " "
+ getterTmpl
+ ";\r\n"
+ " }\r\n");
NutMap ctx = new NutMap().setv("className", className).setv("fieldName", fieldName);
ctx.setv("upperFieldName", Strings.upperFirst(fieldName));
ctx.setv("fieldType", field.getType().getSimpleName());
sb.append(tmpl.render(ctx));
}
示例8: toMap
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
public NutMap toMap() {
NutMap map = new NutMap();
map.setv("name", Strings.sBlank(name, "anonymity"));
if (!Strings.isBlank(email)) {
map.setv("email", email);
}
return map;
}
示例9: agreeGroup
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
/***
* 同意加群请求
* @param id 请求编号
* @param me 当前用户
* @return
*/
@At
@POST
public Object agreeGroup(@Param("msgId")int id,@Attr("me")int me){
Message fetch = dao.fetch(Message.class, id);
if(fetch == null){
return Response.fail("请求消息不存在!");
}
Flock group = dao.fetch(Flock.class, fetch.getFrom_group());
if(group == null){
return Response.fail("该群已解散或不存在!");
}
if(fetch.getUid() != me){
return Response.fail("您不是群主,操作失败!");
}
//加群
FlockRefUser fr = new FlockRefUser();
fr.setFid(fetch.getFrom_group());
fr.setUid(fetch.getFrom());
dao.clear(FlockRefUser.class,Cnd.where(FlockRefUser.UID,"=",fetch.getFrom()).and(FlockRefUser.FID,"=",fetch.getFrom_group()));
dao.insert(fr);
//消息已读
fetch.setRead(1);
fetch.setType(3);
dao.updateIgnoreNull(fetch);
//给请求人发个加群成功的消息
Message msg = new Message();
msg.setContent("您已加入 "+ group.getGroupname() +" 群!");
msg.setUid(fetch.getFrom());
msg.setFrom(me);
msg.setFrom_group(fetch.getFrom_group());;
msg.setType(3);
msg.setRead(0);
msg.setTime(new Date());
msg.setRemark("");
Message i2= dao.insert(msg);
//Socket通知对方
NutMap nm = new NutMap();
nm.setv("type","group");
nm.setv("avatar",group.getAvatar());
nm.setv("groupname",group.getGroupname());
nm.setv("id",group.getId());
SocketUtils.sendByUserId(String.valueOf(fetch.getFrom()), SocketMsgUtils.madeWsResponse(Type.JOIN_GROUP_REQ, Json.toJson(nm)));
return Response.ok();
}
示例10: genIndexPage
import org.nutz.lang.util.NutMap; //导入方法依赖的package包/类
private void genIndexPage(final Rendering ing, final ZDocIndex base) {
if (!Strings.isBlank(this.htmlIndexPath)) {
String oph = Strings.isBlank(base.rpath()) ? htmlIndexPath
: base.rpath()
+ "/"
+ htmlIndexPath;
log.infof("++++++++++++++++ make index : %s", oph);
final Tag tag = Tag.tag("ol", ".zdoc-index-container");
base.eachChild(new Each<ZDocIndex>() {
public void invoke(int index, ZDocIndex zi, int length) {
if (zi.file().name().startsWith("README."))
return;
joinIndexTag(tag, base, zi);
}
});
ing.context().remove("doc");
ing.context().put("siteIndexes", tag.toString());
// 创建页面
NutMap page = new NutMap();
page.setv("bpath", base.bpath());
page.setv("title", base.title());
page.setv("depth", base.depth());
ing.context().setv("page", page);
// 得到文档模板对象
ZDocRule rule = checkRule(htmlIndexPath);
ZDocTemplate tmpl = ing.tfa().getTemplte(rule.key());
// 在目标目录创建对应文件
ZFile destf = dest.createFileIfNoExists(oph);
// 准备渲染
Writer wr = Streams.utf8w(ing.io().openOutputStream(destf));
tmpl.outputTo(wr, ing.context());
Streams.safeClose(wr);
} else {
log.info("! Ignore index");
}
}