mirror of https://github.com/halo-dev/halo
Create list latest by status api for comment.
parent
a6697c5d6b
commit
ff7ecc9d09
|
@ -8,8 +8,8 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import run.halo.app.model.dto.BaseCommentDTO;
|
import run.halo.app.model.dto.BaseCommentDTO;
|
||||||
import run.halo.app.model.entity.PostComment;
|
import run.halo.app.model.entity.PostComment;
|
||||||
import run.halo.app.model.enums.CommentStatus;
|
import run.halo.app.model.enums.CommentStatus;
|
||||||
import run.halo.app.model.params.PostCommentParam;
|
|
||||||
import run.halo.app.model.params.CommentQuery;
|
import run.halo.app.model.params.CommentQuery;
|
||||||
|
import run.halo.app.model.params.PostCommentParam;
|
||||||
import run.halo.app.model.vo.PostCommentWithPostVO;
|
import run.halo.app.model.vo.PostCommentWithPostVO;
|
||||||
import run.halo.app.service.PostCommentService;
|
import run.halo.app.service.PostCommentService;
|
||||||
|
|
||||||
|
@ -48,6 +48,14 @@ public class PostCommentController {
|
||||||
return postCommentService.convertToWithPostVo(content);
|
return postCommentService.convertToWithPostVo(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("latest/{status}")
|
||||||
|
@ApiOperation("Pages latest comments by status")
|
||||||
|
public List<PostCommentWithPostVO> pageLatest(@RequestParam(name = "top", defaultValue = "10") int top,
|
||||||
|
@PathVariable("status") CommentStatus status) {
|
||||||
|
List<PostComment> content = postCommentService.pageLatest(top, status).getContent();
|
||||||
|
return postCommentService.convertToWithPostVo(content);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("Creates a comment (new or reply)")
|
@ApiOperation("Creates a comment (new or reply)")
|
||||||
public BaseCommentDTO createBy(@RequestBody PostCommentParam postCommentParam) {
|
public BaseCommentDTO createBy(@RequestBody PostCommentParam postCommentParam) {
|
||||||
|
|
|
@ -51,6 +51,16 @@ public interface BaseCommentService<COMMENT extends BaseComment> extends CrudSer
|
||||||
@NonNull
|
@NonNull
|
||||||
Page<COMMENT> pageLatest(int top);
|
Page<COMMENT> pageLatest(int top);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists latest comments by status
|
||||||
|
*
|
||||||
|
* @param top top number must not be less than 0
|
||||||
|
* @param status status
|
||||||
|
* @return a page of comments
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
Page<COMMENT> pageLatest(int top, CommentStatus status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pages comments.
|
* Pages comments.
|
||||||
*
|
*
|
||||||
|
|
|
@ -78,6 +78,11 @@ public abstract class BaseCommentServiceImpl<COMMENT extends BaseComment> extend
|
||||||
return listAll(ServiceUtils.buildLatestPageable(top));
|
return listAll(ServiceUtils.buildLatestPageable(top));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<COMMENT> pageLatest(int top,CommentStatus status){
|
||||||
|
return baseCommentRepository.findAllByStatus(status,ServiceUtils.buildLatestPageable(top));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<COMMENT> pageBy(CommentStatus status, Pageable pageable) {
|
public Page<COMMENT> pageBy(CommentStatus status, Pageable pageable) {
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
<#if !post.disallowComment>
|
<#macro comment id,type>
|
||||||
<#include "/common/comment/comment.ftl">
|
<script src="https://unpkg.com/vue"></script>
|
||||||
</#if>
|
<script src="/static/js/halo-comment.min.js"></script>
|
||||||
|
<halo-comment id="${id}" type="${type}"/>
|
||||||
|
</#macro>
|
|
@ -93,6 +93,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="comment_widget">
|
<div id="comment_widget">
|
||||||
<#include "module/comment.ftl">
|
<#include "module/comment.ftl">
|
||||||
|
<@comment id="${post.id}" type="post" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<#include "module/macro.ftl">
|
<#include "module/macro.ftl">
|
||||||
<@head title="${sheet.title!} · ${options.blog_title!'Anatole'}" keywords="${sheet.title!},${options.seo_keywords!'Anatole'}" description="${sheet.summary!'Anatole'}"></@head>
|
<@head title="${post.title!} · ${options.blog_title!'Anatole'}" keywords="${post.title!},${options.seo_keywords!'Anatole'}" description="${post.summary!'Anatole'}"></@head>
|
||||||
<#include "module/sidebar.ftl">
|
<#include "module/sidebar.ftl">
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<link href="/${theme.folderName}/source/plugins/prism/prism.css" type="text/css" rel="stylesheet" />
|
<link href="/${theme.folderName}/source/plugins/prism/prism.css" type="text/css" rel="stylesheet" />
|
||||||
|
@ -40,19 +40,19 @@
|
||||||
<div class="post animated fadeInDown">
|
<div class="post animated fadeInDown">
|
||||||
<div class="post-title">
|
<div class="post-title">
|
||||||
<h3>
|
<h3>
|
||||||
<a>${sheet.title!}</a>
|
<a>${post.title!}</a>
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="post-content">
|
<div class="post-content">
|
||||||
${sheet.formatContent!}
|
${post.formatContent!}
|
||||||
</div>
|
</div>
|
||||||
<div class="post-footer">
|
<div class="post-footer">
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<i class="fa fa-sun-o"></i>
|
<i class="fa fa-sun-o"></i>
|
||||||
<span class="date">${sheet.createTime?string("yyyy-MM-dd")}</span>
|
<span class="date">${post.createTime?string("yyyy-MM-dd")}</span>
|
||||||
<i class="fa fa-comment-o"></i>
|
<i class="fa fa-comment-o"></i>
|
||||||
<a href="${options.blog_url!}/archives/${sheet.url!}#comment_widget">Comments</a>
|
<a href="${options.blog_url!}/archives/${post.url!}#comment_widget">Comments</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -67,12 +67,13 @@
|
||||||
class="fa fa-weibo"></a>
|
class="fa fa-weibo"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="twitter">
|
<div class="twitter">
|
||||||
<a href="http://twitter.com/home?status=${options.blog_url!}/archives/${sheet.url!} ,${options.blog_title!},${sheet.title!},;"
|
<a href="http://twitter.com/home?status=${options.blog_url!}/archives/${post.url!} ,${options.blog_title!},${post.title!},;"
|
||||||
class="fa fa-twitter"></a>
|
class="fa fa-twitter"></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="comment_widget">
|
<div id="comment_widget">
|
||||||
<#include "module/comment.ftl">
|
<#include "module/comment.ftl">
|
||||||
|
<@comment id="${sheet.id!}" type="sheet" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue