use of com.blade.jdbc.core.Take in project tale by otale.
the class UsersServiceImpl method login.
@Override
public Users login(String username, String password) {
if (StringKit.isBlank(username) || StringKit.isBlank(password)) {
throw new TipException("用户名和密码不能为空");
}
int count = activeRecord.count(new Take(Users.class).eq("username", username));
if (count < 1) {
throw new TipException("不存在该用户");
}
String pwd = Tools.md5(username, password);
Users users = activeRecord.one(new Take(Users.class).eq("username", username).eq("password", pwd));
if (null == users) {
throw new TipException("用户名或密码错误");
}
return users;
}
use of com.blade.jdbc.core.Take in project tale by otale.
the class ArticleController method index.
/**
* 文章管理首页
* @param page
* @param limit
* @param request
* @return
*/
@Route(value = "", method = HttpMethod.GET)
public String index(@QueryParam(value = "page", defaultValue = "1") int page, @QueryParam(value = "limit", defaultValue = "15") int limit, Request request) {
Paginator<Contents> contentsPaginator = contentsService.getArticles(new Take(Contents.class).eq("type", Types.ARTICLE).page(page, limit, "created desc"));
request.attribute("articles", contentsPaginator);
return "admin/article_list";
}
use of com.blade.jdbc.core.Take in project tale by otale.
the class CommentController method index.
@Route(value = "", method = HttpMethod.GET)
public String index(@QueryParam(value = "page", defaultValue = "1") int page, @QueryParam(value = "limit", defaultValue = "15") int limit, Request request) {
Users users = this.user();
Paginator<Comments> commentsPaginator = commentsService.getComments(new Take(Comments.class).notEq("author_id", users.getUid()).page(page, limit, "coid desc"));
request.attribute("comments", commentsPaginator);
return "admin/comment_list";
}
use of com.blade.jdbc.core.Take in project tale by otale.
the class IndexController method index.
/**
* 首页分页
*
* @param request
* @param pageIndex
* @param limit
* @return
*/
@Route(values = { "page/:p", "page/:pageIndex.html" }, method = HttpMethod.GET)
public String index(Request request, @PathParam int pageIndex, @QueryParam(value = "limit", defaultValue = "12") int limit) {
pageIndex = pageIndex < 0 || pageIndex > TaleConst.MAX_PAGE ? 1 : pageIndex;
Take take = new Take(Contents.class).eq("type", Types.ARTICLE).eq("status", Types.PUBLISH).page(pageIndex, limit, "created desc");
Paginator<Contents> articles = contentsService.getArticles(take);
request.attribute("articles", articles);
if (pageIndex > 1) {
this.title(request, "第" + pageIndex + "页");
}
request.attribute("is_home", true);
request.attribute("page_prefix", "/page");
return this.render("index");
}
use of com.blade.jdbc.core.Take in project tale by otale.
the class IndexController method search.
@Route(values = { "search/:keyword/:page", "search/:keyword/:page.html" }, method = HttpMethod.GET)
public String search(Request request, @PathParam String keyword, @PathParam int page, @QueryParam(value = "limit", defaultValue = "12") int limit) {
page = page < 0 || page > TaleConst.MAX_PAGE ? 1 : page;
Take take = new Take(Contents.class).eq("type", Types.ARTICLE).eq("status", Types.PUBLISH).like("title", "%" + keyword + "%").page(page, limit, "created desc");
Paginator<Contents> articles = contentsService.getArticles(take);
request.attribute("articles", articles);
request.attribute("type", "搜索");
request.attribute("keyword", keyword);
request.attribute("page_prefix", "/search/" + keyword);
return this.render("page-category");
}
Aggregations