use of com.tale.model.entity.Contents in project tale by otale.
the class CategoryController method tags.
/**
* 标签下文章分页
*/
@GetRoute(value = { "tag/:name/:page", "tag/:name/:page.html" })
public String tags(Request request, @PathParam String name, @PathParam int page, @Param(defaultValue = "12") int limit) {
page = page < 0 || page > TaleConst.MAX_PAGE ? 1 : page;
Metas metaDto = metasService.getMeta(Types.TAG, name);
if (null == metaDto) {
return this.render_404();
}
Page<Contents> contentsPage = contentsService.getArticles(metaDto.getMid(), page, limit);
request.attribute("articles", contentsPage);
request.attribute("meta", metaDto);
request.attribute("type", "标签");
request.attribute("keyword", name);
request.attribute("is_tag", true);
request.attribute("page_prefix", "/tag/" + name);
return this.render("page-category");
}
use of com.tale.model.entity.Contents in project tale by otale.
the class CommentsService method delete.
/**
* 删除评论,暂时没用
*
* @param coid
* @param cid
* @throws Exception
*/
public void delete(Integer coid, Integer cid) {
Anima.delete().from(Comments.class).deleteById(coid);
Contents contents = select().from(Contents.class).byId(cid);
if (null != contents && contents.getCommentsNum() > 0) {
update().from(Contents.class).set(Contents::getCommentsNum, contents.getCommentsNum() - 1).updateById(cid);
}
}
use of com.tale.model.entity.Contents in project tale by otale.
the class CommentsService method saveComment.
/**
* 保存评论
*
* @param comments
*/
public void saveComment(Comments comments) {
comments.setAuthor(TaleUtils.cleanXSS(comments.getAuthor()));
comments.setContent(TaleUtils.cleanXSS(comments.getContent()));
comments.setAuthor(EmojiParser.parseToAliases(comments.getAuthor()));
comments.setContent(EmojiParser.parseToAliases(comments.getContent()));
Contents contents = select().from(Contents.class).byId(comments.getCid());
if (null == contents) {
throw new ValidatorException("不存在的文章");
}
try {
comments.setOwnerId(contents.getAuthorId());
comments.setAuthorId(null == comments.getAuthorId() ? 0 : comments.getAuthorId());
comments.setCreated(DateKit.nowUnix());
comments.setParent(null == comments.getCoid() ? 0 : comments.getCoid());
comments.setCoid(null);
comments.save();
new Contents().set(Contents::getCommentsNum, contents.getCommentsNum() + 1).updateById(contents.getCid());
} catch (Exception e) {
throw e;
}
}
use of com.tale.model.entity.Contents in project tale by otale.
the class MetasService method exec.
private void exec(String type, String name, Contents contents) {
Integer cid = contents.getCid();
boolean isUpdate = false;
Contents temp = new Contents();
if (type.equals(Types.CATEGORY)) {
temp.setCategories(reMeta(name, contents.getCategories()));
isUpdate = true;
}
if (type.equals(Types.TAG)) {
temp.setTags(reMeta(name, contents.getTags()));
isUpdate = true;
}
if (isUpdate) {
temp.updateById(cid);
}
}
Aggregations