Search in sources :

Example 11 with Take

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;
}
Also used : Take(com.blade.jdbc.core.Take) Users(com.tale.model.Users) TipException(com.tale.exception.TipException)

Example 12 with Take

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";
}
Also used : Take(com.blade.jdbc.core.Take) Contents(com.tale.model.Contents)

Example 13 with Take

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";
}
Also used : Take(com.blade.jdbc.core.Take) Comments(com.tale.model.Comments) Users(com.tale.model.Users) Route(com.blade.mvc.annotation.Route)

Example 14 with Take

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");
}
Also used : Take(com.blade.jdbc.core.Take) Contents(com.tale.model.Contents)

Example 15 with Take

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");
}
Also used : Take(com.blade.jdbc.core.Take) Contents(com.tale.model.Contents)

Aggregations

Take (com.blade.jdbc.core.Take)15 Contents (com.tale.model.Contents)7 TipException (com.tale.exception.TipException)4 Comments (com.tale.model.Comments)3 Metas (com.tale.model.Metas)3 Relationships (com.tale.model.Relationships)2 Users (com.tale.model.Users)2 Paginator (com.blade.jdbc.model.Paginator)1 Route (com.blade.mvc.annotation.Route)1 Comment (com.tale.dto.Comment)1 Options (com.tale.model.Options)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1