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";
}
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();
}
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";
}
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);
}
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;
}
}
Aggregations