mirror of https://github.com/halo-dev/halo
Complete CommentTagDirective.
parent
954dfd6415
commit
e5790b3231
|
@ -2,7 +2,10 @@ package run.halo.app.model.freemarker.tag;
|
||||||
|
|
||||||
import freemarker.core.Environment;
|
import freemarker.core.Environment;
|
||||||
import freemarker.template.*;
|
import freemarker.template.*;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import run.halo.app.model.entity.PostComment;
|
||||||
|
import run.halo.app.model.enums.CommentStatus;
|
||||||
import run.halo.app.model.support.HaloConst;
|
import run.halo.app.model.support.HaloConst;
|
||||||
import run.halo.app.service.PostCommentService;
|
import run.halo.app.service.PostCommentService;
|
||||||
|
|
||||||
|
@ -34,7 +37,8 @@ public class CommentTagDirective implements TemplateDirectiveModel {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "latest":
|
case "latest":
|
||||||
int top = Integer.parseInt(params.get("top").toString());
|
int top = Integer.parseInt(params.get("top").toString());
|
||||||
env.setVariable("comments", builder.build().wrap(postCommentService.pageLatest(top)));
|
Page<PostComment> postComments = postCommentService.pageLatest(top, CommentStatus.PUBLISHED);
|
||||||
|
env.setVariable("comments", builder.build().wrap(postCommentService.convertToWithPostVo(postComments)));
|
||||||
break;
|
break;
|
||||||
case "count":
|
case "count":
|
||||||
env.setVariable("count", builder.build().wrap(postCommentService.count()));
|
env.setVariable("count", builder.build().wrap(postCommentService.count()));
|
||||||
|
|
Loading…
Reference in New Issue