use of org.nutz.mvc.annotation.Ok in project nutzboot by nutzam.
the class MainLauncher method make.
@AdaptBy(type = JsonAdaptor.class)
@At("/maker/make")
@Ok("json:full")
public NutMap make(@Param("..") NutMap params) throws IOException {
NutMap re = new NutMap();
String key = R.UU32();
File tmpRoot = Files.createDirIfNoExists(tmpDir + "/" + key);
build(tmpRoot, params);
re.put("key", key);
re.put("ok", true);
return re;
}
use of org.nutz.mvc.annotation.Ok in project nutzboot by nutzam.
the class MainLauncher method index.
@At({ "/", "/index" })
@Ok("vm:/index.vm")
public NutMap index() {
NutMap obj = new NutMap();
obj.setv("name", "牛牪犇").setv("age", 18);
return obj;
}
use of org.nutz.mvc.annotation.Ok in project nutzboot by nutzam.
the class UserModule method login.
@Ok("json")
@Fail("http:500")
@POST
@At("/login")
public boolean login(@Param("username") String username, @Param("password") String password, HttpSession session) {
User user = dao.fetch(User.class, username);
if (user == null)
return false;
Sha256Hash hash = new Sha256Hash(password, user.getSalt());
if (!hash.toHex().equals(user.getPassword())) {
return false;
}
Subject subject = SecurityUtils.getSubject();
subject.login(new SimpleShiroToken(user.getId()));
return true;
}
use of org.nutz.mvc.annotation.Ok in project nutzboot by nutzam.
the class UserModule method apitest.
/**
* 这是演示api调用的入口,会顺序调用一堆请求,请关注日志
*/
@Ok("raw")
@At
public String apitest() {
List<User> users = userService.list();
log.info("users=" + Json.toJson(users));
User haoqoo = userService.add("haoqoo", 19);
User wendal = userService.add("wendal", 28);
users = userService.list();
log.info("users=" + Json.toJson(users));
userService.delete(haoqoo.getId());
userService.delete(wendal.getId());
users = userService.list();
log.info("users=" + Json.toJson(users));
return "done";
}
use of org.nutz.mvc.annotation.Ok in project nutzcloud by nutzam.
the class UserModule method apitest.
/**
* 这是演示api调用的入口,会顺序调用一堆请求,请关注日志
*/
@Ok("raw")
@At
public String apitest() {
List<User> users = userService.list();
log.info("users=" + Json.toJson(users));
User haoqoo = userService.add("haoqoo", 19);
User wendal = userService.add("wendal", 28);
users = userService.list();
log.info("users=" + Json.toJson(users));
userService.delete(haoqoo.getId());
userService.delete(wendal.getId());
users = userService.list();
log.info("users=" + Json.toJson(users));
return "done";
}
Aggregations