Search in sources :

Example 1 with Contents

use of com.tale.model.Contents in project tale by otale.

the class PageController method index.

@Route(value = "", method = HttpMethod.GET)
public String index(Request request) {
    Paginator<Contents> contentsPaginator = contentsService.getArticles(new Take(Contents.class).eq("type", Types.PAGE).page(1, TaleConst.MAX_POSTS, "created desc"));
    request.attribute("articles", contentsPaginator);
    return "admin/page_list";
}
Also used : Take(com.blade.jdbc.core.Take) Contents(com.tale.model.Contents)

Example 2 with Contents

use of com.tale.model.Contents in project tale by otale.

the class PageController method modifyArticle.

@Route(value = "modify", method = HttpMethod.POST)
@JSON
public RestResponse modifyArticle(@QueryParam Integer cid, @QueryParam String title, @QueryParam String content, @QueryParam String fmt_type, @QueryParam String status, @QueryParam String slug, @QueryParam Boolean allow_comment) {
    Users users = this.user();
    Contents contents = new Contents();
    contents.setCid(cid);
    contents.setTitle(title);
    contents.setContent(content);
    contents.setStatus(status);
    contents.setFmt_type(fmt_type);
    contents.setSlug(slug);
    contents.setType(Types.PAGE);
    contents.setAllow_comment(allow_comment);
    contents.setAllow_ping(true);
    contents.setAuthor_id(users.getUid());
    try {
        contentsService.updateArticle(contents);
    } catch (Exception e) {
        String msg = "页面编辑失败";
        if (e instanceof TipException) {
            msg = e.getMessage();
        } else {
            LOGGER.error(msg, e);
        }
        return RestResponse.fail(msg);
    }
    return RestResponse.ok();
}
Also used : Contents(com.tale.model.Contents) Users(com.tale.model.Users) TipException(com.tale.exception.TipException) TipException(com.tale.exception.TipException)

Example 3 with Contents

use of com.tale.model.Contents in project tale by otale.

the class PageController method editPage.

@Route(value = "/:cid", method = HttpMethod.GET)
public String editPage(@PathParam String cid, Request request) {
    Contents contents = contentsService.getContents(cid);
    request.attribute("contents", contents);
    request.attribute(Types.ATTACH_URL, Commons.site_option(Types.ATTACH_URL, Commons.site_url()));
    return "admin/page_edit";
}
Also used : Contents(com.tale.model.Contents)

Example 4 with Contents

use of com.tale.model.Contents in project tale by otale.

the class Theme method comments.

/**
     * 获取当前文章/页面的评论
     * @param limit
     * @return
     */
public static Paginator<Comment> comments(int limit) {
    Contents contents = current_article();
    if (null == contents) {
        return new Paginator<>(0, limit);
    }
    InterpretContext ctx = InterpretContext.current();
    Object value = ctx.getValueStack().getValue("cp");
    int page = 1;
    if (null != value) {
        page = (int) value;
    }
    return siteService.getComments(contents.getCid(), page, limit);
}
Also used : Contents(com.tale.model.Contents) InterpretContext(jetbrick.template.runtime.InterpretContext) Paginator(com.blade.jdbc.model.Paginator)

Example 5 with Contents

use of com.tale.model.Contents in project tale by otale.

the class CommentsServiceImpl method delete.

@Override
public void delete(Integer coid, Integer cid) {
    if (null == coid) {
        throw new TipException("主键为空");
    }
    try {
        activeRecord.delete(Comments.class, coid);
        Contents contents = contentsService.getContents(cid + "");
        if (null != contents && contents.getComments_num() > 0) {
            Contents temp = new Contents();
            temp.setCid(cid);
            temp.setComments_num(contents.getComments_num() - 1);
            contentsService.update(temp);
        }
    } catch (Exception e) {
        throw e;
    }
}
Also used : Contents(com.tale.model.Contents) TipException(com.tale.exception.TipException) TipException(com.tale.exception.TipException)

Aggregations

Contents (com.tale.model.Contents)26 TipException (com.tale.exception.TipException)8 Take (com.blade.jdbc.core.Take)7 Users (com.tale.model.Users)4 Paginator (com.blade.jdbc.model.Paginator)2 MetaDto (com.tale.dto.MetaDto)2 Metas (com.tale.model.Metas)2 InterpretContext (jetbrick.template.runtime.InterpretContext)2 PageRow (com.blade.jdbc.model.PageRow)1 Route (com.blade.mvc.annotation.Route)1 Statistics (com.tale.dto.Statistics)1 Comments (com.tale.model.Comments)1 Logs (com.tale.model.Logs)1 Relationships (com.tale.model.Relationships)1