本文整理汇总了Java中org.nutz.mvc.annotation.Ok类的典型用法代码示例。如果您正苦于以下问题:Java Ok类的具体用法?Java Ok怎么用?Java Ok使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ok类属于org.nutz.mvc.annotation包,在下文中一共展示了Ok类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: updateCaptcha
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
@At("/captcha/update")
@Ok("raw:image/png")
public BufferedImage updateCaptcha(HttpSession session, @Param("w") int w, @Param("h") int h) {
if (w * h == 0) { //长或宽为0?重置为默认长宽.
w = 200;
h = 60;
}
Captcha captcha = new Captcha.Builder(w, h)
.addText().addBackground(new GradiatedBackgroundProducer())
// .addNoise(new StraightLineNoiseProducer()).addBorder()
.gimp(new FishEyeGimpyRenderer())
.build();
String text = captcha.getAnswer();
session.setAttribute(Toolkit.captcha_attr, text);
return captcha.getImage();
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:17,代码来源:ToolkitModule.java
示例2: readMedia
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
@GET
@At("/media/?/?")
@Ok("raw")
@Fail("http:404")
public InputStream readMedia(String openid, String mediaId, @Attr("usr")String usr, HttpServletResponse resp) throws IOException {
WxMaster master = wxctx.get(openid);
if (master == null || !master.getOpenid().equals(usr)) {
throw new IllegalArgumentException("not allow " + openid + "," + mediaId);
}
WxMedia media = mediaService.get(openid, mediaId);
if (media == null) {
throw new IllegalArgumentException("not found " + openid + "," + mediaId);
}
if (Strings.isBlank(media.getContentType())) {
resp.setContentType(media.getContentType());
}
return media.getStream();
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:19,代码来源:ExchangeModule.java
示例3: upload
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
@At({"/iot/device/?/sensor/?/datapoints", "/v1.1/device/?/sensor/?/datapoints"})
@POST
@AdaptBy(type=VoidAdaptor.class)
@Ok("void")
public void upload(String device_id, String sensor_id, InputStream in, @Attr(Zs.UID)long userId, HttpServletResponse resp) throws IOException {
IotSensor sensor = dao.fetch(IotSensor.class, Cnd.where("deviceId", "=", device_id).and(Zs.UID, "=", userId).and("id", "=", sensor_id));
if (sensor == null) {
resp.setStatus(406);
resp.getWriter().write(Iots.NOTFOUND);
return;
}
if (sensor.getLastUpdateTime() != null && System.currentTimeMillis() - sensor.getLastUpdateTime().getTime() < Iots.Limit_Sensor_Update_Interval * 1000 ) {
resp.setStatus(406);
resp.getWriter().write(Iots.TOOFAST);
return ; // too fast
}
SensorUploadResult re = iotSensorService.upload(sensor, in);
if (re.err == null)
return;
resp.setStatus(406);
Mvcs.write(resp, re, JsonFormat.compact());
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:23,代码来源:IotExchangeModule.java
示例4: logout
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
/**
* 登出页面
*/
@At("/out")
@Ok("forward:/WEB-INF/view/index.html")
public void logout(HttpSession session) {
//session.invalidate();
SecurityUtils.getSubject().logout();
}
开发者ID:strictnerd,项目名称:windows-file-change,代码行数:10,代码来源:UserModule.java
示例5: fm
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
/**
* freemarker 渲染页面
*/
@At
@Ok("fm:view.test")
public int fm(HttpServletRequest req) {
List<String> list = new ArrayList<>();
list.add("a");
list.add("b");
list.add("c");
list.add("d");
list.add("e");
req.setAttribute("list", list);
return 1;
}
开发者ID:strictnerd,项目名称:windows-file-change,代码行数:16,代码来源:UserModule.java
示例6: list
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
/**
* 角色列表
*
* @param page
* 页码
* @return
*/
@At
@Ok("beetl:pages/${table.lowerClassName!}/list.html")
@RequiresRoles("admin")
public Result list(@Param(value = "page", df = "1") int page) {
page = _fixPage(page);
Pager<${table.className!}> pager = ${table.lowerClassName!}Service.searchByPage(page);
pager.setUrl(_base() + "/${table.lowerClassName!}/list");
return Result.success().addData("pager", pager);
}
开发者ID:Kerbores,项目名称:Nutz-matic,代码行数:17,代码来源:Module.java
示例7: search
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
/**
* 搜索角色
*
* @param page
* 页码
* @param key
* 关键词
* @return
*/
@At
@Ok("beetl:pages/${table.lowerClassName!}/list.html")
@RequiresRoles("admin")
public Result search(@Param(value = "page", df = "1") int page, @Param("key") String key) {
page = _fixPage(page);
key = _fixSearchKey(key);
Pager<${table.className!}> pager = ${table.lowerClassName!}Service.searchByKeyAndPage(key, page, "name", "description");
pager.setUrl(_base() + "/${table.lowerClassName!}/search");
pager.addParas("key", key);
return Result.success().addData("pager", pager);
}
开发者ID:Kerbores,项目名称:Nutz-matic,代码行数:21,代码来源:Module.java
示例8: add
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
/**
* 添加角色页面
*
* @return
*/
@At
@GET
@Ok("beetl:pages/${table.lowerClassName!}/add_edit.html")
@RequiresRoles("admin")
public Result add() {
return Result.success();
}
开发者ID:Kerbores,项目名称:Nutz-matic,代码行数:13,代码来源:Module.java
示例9: edit
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
/**
* 编辑页码页面
*
* @param id
* 角色id
* @return
*/
@At("/edit/*")
@Ok("beetl:pages/${table.lowerClassName!}/add_edit.html")
@RequiresRoles("admin")
public Result edit(int id) {
${table.className!} ${table.lowerClassName!} = ${table.lowerClassName!}Service.fetch(id);
return Result.success().addData("${table.lowerClassName!}", ${table.lowerClassName!});
}
开发者ID:Kerbores,项目名称:Nutz-matic,代码行数:15,代码来源:Module.java
示例10: get
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
@At({"/get/?", "/get/?/?"})
@AdaptBy(type=VoidAdaptor.class)
@GET
@Ok("raw")
@Filters()
public Object get(long sensor_id, String key) {
IotSensor sensor = dao.fetch(IotSensor.class, sensor_id);
if (sensor == null) {
return HttpStatusView.HTTP_404;
}
return sensor.getValue() == null ? "" : sensor.getValue();
}
开发者ID:wendal,项目名称:whale,代码行数:13,代码来源:IotExchangeModule.java
示例11: deleteDev
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
@At({"/device/?"})
@DELETE
@Ok("void")
public void deleteDev(long device_id, @Attr(IotKeys.UID)long userId) {
dao.clear(IotDevice.class, Cnd.where("id", "=", device_id).and(IotKeys.UID, "=", userId));
dao.clear(IotSensor.class, Cnd.where("deviceId", "=", device_id).and(IotKeys.UID, "=", userId));
}
开发者ID:wendal,项目名称:whale,代码行数:8,代码来源:IotAdminModule.java
示例12: user
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
@At("/user")
@Ok("void")
public View user(@Param("username")String username, @Param("password")String password) {
log.infof("u=%s p=%s", username, password);;
if (Strings.isBlank(username))
return HTTP_403;
if (dao.count(IotUser.class, Cnd.where("name", "=", username).and("apikey", "=", password)) == 1) {
return null;
}
return HTTP_403;
}
开发者ID:wendal,项目名称:whale,代码行数:12,代码来源:MqttAuthModule.java
示例13: isSuperUser
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
@At("/super")
@Ok("void")
public View isSuperUser(@Param("username")String username) {
if ("admin".equals(username))
return null;
return HTTP_403;
}
开发者ID:wendal,项目名称:whale,代码行数:8,代码来源:MqttAuthModule.java
示例14: acl
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
@At("/acl")
@Ok("void")
@Fail("http:403")
public View acl(@Param("username")String username, @Param("topic")String topic, @Param("acc")String acc) {
if (!"1".equals(acc))
return HTTP_403; // TODO 支持mqtt发布, 即通过mqtt更新传感器的值
if (Strings.isBlank(topic) || !topic.matches("^iot2/sensor/[0-9]+$"))
return HTTP_403;
long sensor_id = Long.parseLong(topic.substring("iot2/sensor/".length()));
IotSensor sensor = dao.fetch(IotSensor.class, Cnd.where("name", "=", username).and("id", "=", sensor_id));
if (sensor == null)
return HTTP_403;
return null;
}
开发者ID:wendal,项目名称:whale,代码行数:15,代码来源:MqttAuthModule.java
示例15: passwdResetCallback
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
@At("/pwd_reset/callback/?")
@Ok("jsp:jsp.usr.pwdreset.done")
public boolean passwdResetCallback(String token) {
if (Strings.isBlank(token)) {
throw new IllegalArgumentException("bad token=["+token+"]");
}
String re = Toolkit._3DES_decode(pwdResetKey, Toolkit.hexstr2bytearray(token));
if (re == null) {
throw new IllegalArgumentException("bad token=["+token+"]");
}
NutMap map = Toolkit.kv2map(re);
if (map.getLong("t") - 30*60*1000 > System.currentTimeMillis()) {
throw new IllegalArgumentException("bad token=["+token+"] timeout");
}
String name = map.getString("u");
User usr = dao.fetch(User.class, name);
if (usr == null) {
throw new IllegalArgumentException("bad token=["+token+"]");
}
if (!usr.getSlat().equals(map.getString("slat"))) {
throw new IllegalArgumentException("bad token=["+token+"]");
}
// 看来都是正确的,那允许重置密码了
String pwd = Toolkit.randomPasswd(usr);
dao.update(usr, "(slat|passwd)"); // 重置slat,这样token就是一次性咯
// TODO 记入系统操作日志
log.info("AdminUser Password reset success >> " + name);
return mailService.send(usr.getEmail(), "New Password", "Password: ${pwd}", Lang.context().set("pwd", pwd));
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:30,代码来源:UserModule.java
示例16: console
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
@At("/console/?")
@Ok("jsp:jsp.usr.mp_console")
@Fail("http:500")
@GET
public Object console(String openid, @Attr(value="usr", scope=Scope.SESSION)String usr){
WxMpInfo master = (WxMpInfo) wxctx.get(openid);
if (master == null || !usr.equals(master.getOwner())) {
return new HttpStatusView(403);
}
return openid;
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:12,代码来源:WxManagerModule.java
示例17: getLastData
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
@At({"/iot/device/?/sensor/?/datapoints", "/v1.1/device/?/sensor/?/datapoints"})
@GET
@Ok("void")
public void getLastData(String device_id, String sensor_id, @Attr(Zs.UID)long userId, HttpServletResponse resp) throws IOException {
IotSensor sensor = dao.fetch(IotSensor.class, Cnd.where("deviceId", "=", device_id).and(Zs.UID, "=", userId).and("id", "=", sensor_id));
if (sensor == null) {
resp.setStatus(406);
resp.getWriter().write(Iots.NOTFOUND);
return;
}
if (sensor.getValue() == null)
return;
resp.getWriter().write(sensor.getValue());
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:15,代码来源:IotExchangeModule.java
示例18: deleteDev
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
@At({"/iot/device/?", "/v1.1/device/?"})
@DELETE
@Ok("void")
public void deleteDev(long device_id, @Attr(Zs.UID)long userId) {
dao.clear(IotDevice.class, Cnd.where("id", "=", device_id).and(Zs.UID, "=", userId));
dao.clear(IotSensor.class, Cnd.where("deviceId", "=", device_id).and(Zs.UID, "=", userId));
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:8,代码来源:IotAdminModule.java
示例19: get_user
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
@At("/user")
@Ok("void")
public View get_user(@Param("username")String username, @Param("password")String password) {
log.infof("u=%s p=%s", username, password);;
if (Strings.isBlank(username))
return HTTP_403;
if (dao.count(IotUser.class, Cnd.where(Zs.UID, "=", userService.userId(username)).and("apikey", "=", password)) == 1)
return null;
return HTTP_403;
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:11,代码来源:MqttAuthModule.java
示例20: isSuperUser
import org.nutz.mvc.annotation.Ok; //导入依赖的package包/类
@At("/super")
@Ok("void")
public View isSuperUser(@Param("username")String username) {
if ("root".equals(username))
return null;
return HTTP_403;
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:8,代码来源:MqttAuthModule.java
注:本文中的org.nutz.mvc.annotation.Ok类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论