@At
public Object login( c("username")String name, @Param("password")String password, HttpSession session) {
User user = dao.fetch(User.class, Cnd.where("name", "=", name). and("password", "=", password));
if (user == null) {
return false;
} else {
session.setAttribute("me", user.getId());
return true;
}
public Object login( c("username")String name, @Param("password")String password, HttpSession session) {
User user = dao.fetch(User.class, Cnd.where("name", "=", name). and("password", "=", password));
if (user == null) {
return false;
} else {
session.setAttribute("me", user.getId());
return true;
}
}
@At将一个HTTP请求映射到一个函数上,使函数成为入口函数,
@Param 将 HTTP 的参数表同入口函数的参数对应起来
dao.fetch 查询数据
Cnd.where ?.and ? Cnd.where("id", ">", 34).and("name","LIKE","T%").asc("name");
相当于
WHERE id>34 AND name LIKE 'T%' ORDER BY name ASC
Cnd.orderBy().desc("id");
相当于
ORDER BY id DESC