当前位置: 首页>>代码示例>>Java>>正文


Java At类代码示例

本文整理汇总了Java中org.nutz.mvc.annotation.At的典型用法代码示例。如果您正苦于以下问题:Java At类的具体用法?Java At怎么用?Java At使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


At类属于org.nutz.mvc.annotation包,在下文中一共展示了At类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: image

import org.nutz.mvc.annotation.At; //导入依赖的package包/类
/**
 * 发送图片,上传图片接口
 * @param file
 * @param context
 * @return
 */
@At
@POST
@Filters({@By(type=CrossOriginFilter.class)})
@AdaptBy(type = UploadAdaptor.class, args = { "${app.root}/WEB-INF/tmp" })
public Object image(@Param("file") TempFile file,ServletContext context){
	System.out.println(file.getName());
	System.out.println(file.getMeta().getFileLocalName());
	String relpath = getDir()+"/upload/imgs/"+file.getMeta().getFileLocalName(); // 此为: D:\\apache-tomcat-8.0.36\\webapps\\upload\\tomat.png
	Files.copy(file.getFile(),new File(relpath));

	String url ="/upload/imgs/"+file.getMeta().getFileLocalName();	//eclipse默认的tomcat目录是在其缓存文件中,你要自己指定到tomcat所在目录
	//构建json数据
	Map<String,Object> data = new HashMap<String,Object>();
	data.put("code", "0");
	data.put("msg", "");
	Map<String,String> sourceUrl = new HashMap<String,String>();
	sourceUrl.put("src", url);
	data.put("data", sourceUrl);
	
	return data;
}
 
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:28,代码来源:UploadModule.java

示例2: files

import org.nutz.mvc.annotation.At; //导入依赖的package包/类
/**
 * 发送图片,上传图片接口
 * @param file
 * @param context
 * @return
 */
@At
@POST
@Filters({@By(type=CrossOriginFilter.class)})
@AdaptBy(type = UploadAdaptor.class, args = { "${app.root}/WEB-INF/tmp" })
public Object files(@Param("file") TempFile file,ServletContext context){
	System.out.println(file.getName());
	System.out.println(file.getMeta().getFileLocalName());
	String relpath = getDir()+"/upload/files/"+file.getMeta().getFileLocalName(); // 此为: D:\\apache-tomcat-8.0.36\\webapps\\upload\\tomat.png
	Files.copy(file.getFile(),new File(relpath));
	String url ="/upload/files/"+file.getMeta().getFileLocalName();	//eclipse默认的tomcat目录是在其缓存文件中,你要自己指定到tomcat所在目录
	//构建json数据
	Map<String,Object> data = new HashMap<String,Object>();
	data.put("code", "0");
	data.put("msg", "");
	Map<String,String> sourceUrl = new HashMap<String,String>();
	sourceUrl.put("src", url);
	data.put("data", sourceUrl);

	return data;
}
 
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:27,代码来源:UploadModule.java

示例3: resetApikey

import org.nutz.mvc.annotation.At; //导入依赖的package包/类
@At("/ukey/reset")
@GET
@Filters()
public Object resetApikey(@Attr(IotKeys.UID)long userId) {
	if (userId == 0)
		return Collections.EMPTY_MAP;
	IotUser usr = dao.fetch(IotUser.class, userId);
	if (usr == null) {
		usr = new IotUser();
		iotService.makeApiKey(usr);
		dao.insert(usr);
	} else {
		iotService.makeApiKey(usr);
		dao.update(usr);
	}
	return new NutMap().addv("apikey", usr.getApikey());
}
 
开发者ID:wendal,项目名称:whale,代码行数:18,代码来源:IotAdminModule.java

示例4: createSensor

import org.nutz.mvc.annotation.At; //导入依赖的package包/类
@At({"/device/?/sensors"})
@POST
@AdaptBy(type=JsonAdaptor.class)
public IotSensor createSensor(long device_id, @Param("..")IotSensor sensor, @Attr(IotKeys.UID)long userId) {
	if (sensor == null)
		return null;
	IotDevice dev = dao.fetch(IotDevice.class, Cnd.where("deviceId", "=", device_id).and(IotKeys.UID, "=", userId));
	if (dev == null)
		return null;
	int sensorCount = dao.count(IotSensor.class, Cnd.where("deviceId", "=", device_id).and(IotKeys.UID, "=", userId));
	if (sensorCount > Iots.Limit_Sensor_Per_Dev) {
		return null;
	}
	sensor.setDeviceId(device_id);
	sensor.setUserId(userId);
	dao.insert(sensor);
	return sensor;
}
 
开发者ID:wendal,项目名称:whale,代码行数:19,代码来源:IotAdminModule.java

示例5: updateCaptcha

import org.nutz.mvc.annotation.At; //导入依赖的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

示例6: query

import org.nutz.mvc.annotation.At; //导入依赖的package包/类
@At({"/?", "/?/?"})
public Object query(String openid, String clientId, 
		Map<String, Object> map, @Param("..")Pager pager,
		@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);
	Cnd cnd = Cnd.NEW();
	if (clientId != null)
		cnd.and("client", "=", clientId);
	if (map != null) {
		for (Entry<String, Object> en : map.entrySet()) {
			cnd.and(en.getKey(), "=", en.getValue());
		}
	}
	int count = ExtDaos.ext(dao, openid).count(WxMsgHistory.class, cnd);
	cnd.desc("createTime"); // count之后再加orderBy嘛
	List<WxMsgHistory> list = ExtDaos.ext(dao, FieldFilter.locked(WxMsgHistory.class, "$(body)$"), openid).query(WxMsgHistory.class, cnd, pager);
	pager.setRecordCount(count);
	return new QueryResult(list, pager);
}
 
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:22,代码来源:WxMsgHistoryModule.java

示例7: readMedia

import org.nutz.mvc.annotation.At; //导入依赖的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

示例8: upload

import org.nutz.mvc.annotation.At; //导入依赖的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

示例9: resetApikey

import org.nutz.mvc.annotation.At; //导入依赖的package包/类
@At("/iot/apikey/reset")
@GET
@Filters()
public Object resetApikey(@Attr(Zs.UID)long userId) {
	if (userId == 0)
		return Collections.EMPTY_MAP;
	IotUser usr = dao.fetch(IotUser.class, userId);
	if (usr == null) {
		usr = new IotUser();
		iotService.makeApiKey(usr);
		dao.insert(usr);
	} else {
		iotService.makeApiKey(usr);
		dao.update(usr);
	}
	return new NutMap().addv("apikey", usr.getApikey());
}
 
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:18,代码来源:IotAdminModule.java

示例10: createSensor

import org.nutz.mvc.annotation.At; //导入依赖的package包/类
@At({"/iot/device/?/sensors", "/v1.1/device/?/sensors"})
@POST
@AdaptBy(type=JsonAdaptor.class)
public IotSensor createSensor(long device_id, @Param("..")IotSensor sensor, @Attr(Zs.UID)long userId) {
	if (sensor == null)
		return null;
	IotDevice dev = dao.fetch(IotDevice.class, Cnd.where("deviceId", "=", device_id).and(Zs.UID, "=", userId));
	if (dev == null)
		return null;
	int sensorCount = dao.count(IotSensor.class, Cnd.where("deviceId", "=", device_id).and(Zs.UID, "=", userId));
	if (sensorCount > Iots.Limit_Sensor_Per_Dev) {
		return null;
	}
	sensor.setDeviceId(device_id);
	sensor.setUserId(userId);
	dao.insert(sensor);
	return sensor;
}
 
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:19,代码来源:IotAdminModule.java

示例11: accept

import org.nutz.mvc.annotation.At; //导入依赖的package包/类
@At("/accept")
@AdaptBy(type=JsonAdaptor.class)
public Object accept(CqpPostMsg cqpPostMsg) throws IOException {
    if (cqpPostMsg.getMessage().startsWith("#")) {
        switch (cqpPostMsg.getPost_type()) {
            case "message":
                return processMessage(cqpPostMsg);
            case "event":
                break;
            case "request":
                break;
        }
    }
    return "";
}
 
开发者ID:yangjinhe,项目名称:maintain-robot,代码行数:16,代码来源:RobotModule.java

示例12: test

import org.nutz.mvc.annotation.At; //导入依赖的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;
}
 
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:12,代码来源:UploadModule.java

示例13: getTodoById

import org.nutz.mvc.annotation.At; //导入依赖的package包/类
@GET
@At("/api/?")
public Object getTodoById(String id) {
	Todo todo = todos.get(id);
	if (todo == null)
		return new HttpStatusView(404);
    return todo;
}
 
开发者ID:nutzam,项目名称:todo-backend-nutzboot,代码行数:9,代码来源:TodoLauncher.java

示例14: createTodo

import org.nutz.mvc.annotation.At; //导入依赖的package包/类
@POST
@At("/api/")
@AdaptBy(type=JsonAdaptor.class)
public Todo createTodo(Todo todo, HttpServletRequest request) {
    todo.setUrl(request.getRequestURL().toString() + currentId);
    todos.put(""+currentId, todo);
    currentId++;
    return todo;
}
 
开发者ID:nutzam,项目名称:todo-backend-nutzboot,代码行数:10,代码来源:TodoLauncher.java

示例15: update

import org.nutz.mvc.annotation.At; //导入依赖的package包/类
@At(value="/api/?", methods="patch")
@AdaptBy(type=JsonAdaptor.class)
public Object update(String id, Todo todo) {
	Todo _todo = todos.get(id);
	if (_todo == null)
		return new HttpStatusView(404);
    return _todo.patchWith(todo);
}
 
开发者ID:nutzam,项目名称:todo-backend-nutzboot,代码行数:9,代码来源:TodoLauncher.java


注:本文中的org.nutz.mvc.annotation.At类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。