mirror of https://github.com/halo-dev/halo
✨ 支持文章置顶
parent
953dbc7fae
commit
24aa12fbd6
|
@ -24,8 +24,10 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.SortDefault;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.ServletRequestDataBinder;
|
||||
|
@ -85,6 +87,7 @@ public class PostController extends BaseController {
|
|||
}
|
||||
|
||||
/**
|
||||
* ¬
|
||||
* 处理后台获取文章列表的请求
|
||||
*
|
||||
* @param model model
|
||||
|
@ -93,7 +96,12 @@ public class PostController extends BaseController {
|
|||
@GetMapping
|
||||
public String posts(Model model,
|
||||
@RequestParam(value = "status", defaultValue = "0") Integer status,
|
||||
@PageableDefault(sort = "postDate", direction = DESC) Pageable pageable) {
|
||||
@RequestParam(value = "page", defaultValue = "0") Integer page,
|
||||
@SortDefault.SortDefaults({
|
||||
@SortDefault(sort = "postPriority", direction = DESC),
|
||||
@SortDefault(sort = "postDate", direction = DESC)
|
||||
}) Sort sort) {
|
||||
final Pageable pageable = PageRequest.of(page, 10, sort);
|
||||
final Page<PostAdminOutputDTO> posts = postService.findPostByStatus(status, PostTypeEnum.POST_TYPE_POST.getDesc(), pageable)
|
||||
.map(post -> new PostAdminOutputDTO().convertFrom(post));
|
||||
model.addAttribute("posts", posts);
|
||||
|
@ -259,6 +267,22 @@ public class PostController extends BaseController {
|
|||
return "redirect:/admin/page";
|
||||
}
|
||||
|
||||
/**
|
||||
* 置顶/取消置顶文章
|
||||
*
|
||||
* @param postId postId
|
||||
* @param priority priority
|
||||
* @return JsonResult
|
||||
*/
|
||||
@GetMapping(value = "/topPost")
|
||||
public String topPost(@RequestParam("postId") Long postId,
|
||||
@RequestParam("priority") Integer priority) {
|
||||
Post post = postService.getById(postId);
|
||||
post.setPostPriority(priority);
|
||||
postService.update(post);
|
||||
return "redirect:/admin/posts";
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新所有摘要
|
||||
*
|
||||
|
|
|
@ -64,16 +64,16 @@
|
|||
<#switch comment.commentStatus>
|
||||
<#case 0>
|
||||
<button class="btn btn-primary btn-xs " onclick="replyShow('${comment.commentId?c}','${comment.post.postId?c}')" <#if comment.isAdmin==1>disabled</#if>><@spring.message code="common.btn.reply" /></button>
|
||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/comments/throw?commentId=${comment.commentId?c}&status=0&page=${comments.number}','<@spring.message code="common.text.tips.to-recycle-bin" />')"><@spring.message code="common.btn.recycling" /></button>
|
||||
<button class="btn btn-danger btn-xs " onclick="modalShow('/admin/comments/throw?commentId=${comment.commentId?c}&status=0&page=${comments.number}','<@spring.message code="common.text.tips.to-recycle-bin" />')"><@spring.message code="common.btn.recycling" /></button>
|
||||
<#break >
|
||||
<#case 1>
|
||||
<a data-pjax="true" class="btn btn-primary btn-xs " href="/admin/comments/revert?commentId=${comment.commentId?c}&status=1"><@spring.message code="common.btn.pass" /></a>
|
||||
<button class="btn btn-info btn-xs " onclick="replyShow('${comment.commentId?c}','${comment.post.postId?c}')"><@spring.message code="common.btn.pass-reply" /></button>
|
||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/comments/throw?commentId=${comment.commentId?c}&status=1&page=${comments.number}','<@spring.message code="common.text.tips.to-recycle-bin" />')"><@spring.message code="common.btn.recycling" /></button>
|
||||
<button class="btn btn-danger btn-xs " onclick="modalShow('/admin/comments/throw?commentId=${comment.commentId?c}&status=1&page=${comments.number}','<@spring.message code="common.text.tips.to-recycle-bin" />')"><@spring.message code="common.btn.recycling" /></button>
|
||||
<#break >
|
||||
<#case 2>
|
||||
<a data-pjax="true" class="btn btn-primary btn-xs " href="/admin/comments/revert?commentId=${comment.commentId?c}&status=2"><@spring.message code="common.btn.reduction" /></a>
|
||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/comments/remove?commentId=${comment.commentId?c}&status=2&page=${comments.number}','<@spring.message code="common.text.tips.to-delete" />')"><@spring.message code="common.btn.delete" /></button>
|
||||
<button class="btn btn-danger btn-xs " onclick="modalShow('/admin/comments/remove?commentId=${comment.commentId?c}&status=2&page=${comments.number}','<@spring.message code="common.text.tips.to-delete" />')"><@spring.message code="common.btn.delete" /></button>
|
||||
<#break >
|
||||
</#switch>
|
||||
</td>
|
||||
|
@ -164,7 +164,7 @@
|
|||
maxHeight: '210px',
|
||||
api:"/static/halo-common/OwO/OwO.min.json"
|
||||
});
|
||||
function modelShow(url,message) {
|
||||
function modalShow(url,message) {
|
||||
$('#url').val(url);
|
||||
$('#message').html(message);
|
||||
$('#removeCommentModal').modal();
|
||||
|
|
|
@ -176,7 +176,7 @@
|
|||
<#else>
|
||||
<a data-pjax="true" href="/admin/menus/edit?menuId=${menu.menuId?c}" class="btn btn-primary btn-xs "><@spring.message code='common.btn.modify' /></a>
|
||||
</#if>
|
||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/menus/remove?menuId=${menu.menuId?c}')"><@spring.message code='common.btn.delete' /></button>
|
||||
<button class="btn btn-danger btn-xs " onclick="modalShow('/admin/menus/remove?menuId=${menu.menuId?c}')"><@spring.message code='common.btn.delete' /></button>
|
||||
</td>
|
||||
</tr>
|
||||
</#list>
|
||||
|
@ -209,7 +209,7 @@
|
|||
</div>
|
||||
<@footer>
|
||||
<script type="application/javascript" id="footer_script">
|
||||
function modelShow(url) {
|
||||
function modalShow(url) {
|
||||
$('#url').val(url);
|
||||
$('#removeMenuModal').modal();
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
<td>${page.postDate?string("yyyy-MM-dd HH:mm")}</td>
|
||||
<td>
|
||||
<a data-pjax="true" href="/admin/page/edit?pageId=${page.postId?c}" class="btn btn-primary btn-xs "><@spring.message code='common.btn.edit' /></a>
|
||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/posts/remove?postId=${page.postId?c}&postType=${page.postType}','<@spring.message code="common.text.tips.to-delete" />')"><@spring.message code='common.btn.delete' /></button>
|
||||
<button class="btn btn-danger btn-xs " onclick="modalShow('/admin/posts/remove?postId=${page.postId?c}&postType=${page.postType}','<@spring.message code="common.text.tips.to-delete" />')"><@spring.message code='common.btn.delete' /></button>
|
||||
</td>
|
||||
</tr>
|
||||
</#list>
|
||||
|
@ -135,7 +135,7 @@
|
|||
</div>
|
||||
<@footer>
|
||||
<script type="application/javascript" id="footer_script">
|
||||
function modelShow(url,message) {
|
||||
function modalShow(url,message) {
|
||||
$('#url').val(url);
|
||||
$('#message').html(message);
|
||||
$('#removePostModal').modal();
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
<#else >
|
||||
<a data-pjax="true" class="btn btn-primary btn-xs" href="/admin/page/links/edit?linkId=${link.linkId?c}"><@spring.message code='common.btn.modify' /></a>
|
||||
</#if>
|
||||
<button class="btn btn-danger btn-xs" onclick="modelShow('/admin/page/links/remove?linkId=${link.linkId?c}')"><@spring.message code='common.btn.delete' /></>
|
||||
<button class="btn btn-danger btn-xs" onclick="modalShow('/admin/page/links/remove?linkId=${link.linkId?c}')"><@spring.message code='common.btn.delete' /></>
|
||||
</td>
|
||||
</tr>
|
||||
</#list>
|
||||
|
@ -135,7 +135,7 @@
|
|||
</div>
|
||||
<@footer>
|
||||
<script type="application/javascript" id="footer_script">
|
||||
function modelShow(url) {
|
||||
function modalShow(url) {
|
||||
$('#url').val(url);
|
||||
$('#removeLinkModal').modal();
|
||||
}
|
||||
|
|
|
@ -92,18 +92,23 @@
|
|||
<td>
|
||||
<#switch post.postStatus>
|
||||
<#case 0>
|
||||
<a data-pjax="true" href="/admin/posts/edit?postId=${post.postId?c}" class="btn btn-info btn-xs "><@spring.message code='common.btn.edit' /></a>
|
||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/posts/throw?postId=${post.postId?c}&status=0','<@spring.message code="common.text.tips.to-recycle-bin" />')"><@spring.message code='common.btn.recycling' /></button>
|
||||
<#if post.postPriority == 0>
|
||||
<button class="btn btn-primary btn-xs" onclick="modalShow('/admin/posts/topPost?postId=${post.postId?c}&priority=1','是否置顶该文章?')">置顶</button>
|
||||
<#else>
|
||||
<button class="btn btn-primary btn-xs" onclick="modalShow('/admin/posts/topPost?postId=${post.postId?c}&priority=0','是否取消置顶该文章?')">取消置顶</button>
|
||||
</#if>
|
||||
<a data-pjax="true" href="/admin/posts/edit?postId=${post.postId?c}" class="btn btn-info btn-xs"><@spring.message code='common.btn.edit' /></a>
|
||||
<button class="btn btn-danger btn-xs" onclick="modalShow('/admin/posts/throw?postId=${post.postId?c}&status=0','<@spring.message code="common.text.tips.to-recycle-bin" />')"><@spring.message code='common.btn.recycling' /></button>
|
||||
<#break >
|
||||
<#case 1>
|
||||
<a data-pjax="true" href="/admin/posts/edit?postId=${post.postId?c}"
|
||||
class="btn btn-info btn-xs "><@spring.message code="common.btn.edit" /></a>
|
||||
<button class="btn btn-primary btn-xs " onclick="modelShow('/admin/posts/revert?postId=${post.postId?c}&status=1','<@spring.message code="common.text.tips.to-release-post" />')"><@spring.message code='common.btn.release' /></button>
|
||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/posts/throw?postId=${post.postId?c}&status=1','<@spring.message code="common.text.tips.to-recycle-bin" />')"><@spring.message code='common.btn.recycling' /></button>
|
||||
class="btn btn-info btn-xs"><@spring.message code="common.btn.edit" /></a>
|
||||
<button class="btn btn-primary btn-xs" onclick="modalShow('/admin/posts/revert?postId=${post.postId?c}&status=1','<@spring.message code="common.text.tips.to-release-post" />')"><@spring.message code='common.btn.release' /></button>
|
||||
<button class="btn btn-danger btn-xs" onclick="modalShow('/admin/posts/throw?postId=${post.postId?c}&status=1','<@spring.message code="common.text.tips.to-recycle-bin" />')"><@spring.message code='common.btn.recycling' /></button>
|
||||
<#break >
|
||||
<#case 2>
|
||||
<a data-pjax="true" href="/admin/posts/revert?postId=${post.postId?c}&status=2" class="btn btn-primary btn-xs "><@spring.message code='common.btn.reduction' /></a>
|
||||
<button class="btn btn-danger btn-xs " onclick="modelShow('/admin/posts/remove?postId=${post.postId?c}&postType=${post.postType}','<@spring.message code="common.text.tips.to-delete" />')"><@spring.message code='common.btn.delete' /></button>
|
||||
<button class="btn btn-danger btn-xs" onclick="modalShow('/admin/posts/remove?postId=${post.postId?c}&postType=${post.postType}','<@spring.message code="common.text.tips.to-delete" />')"><@spring.message code='common.btn.delete' /></button>
|
||||
<#break >
|
||||
</#switch>
|
||||
</td>
|
||||
|
@ -154,7 +159,7 @@
|
|||
<div class="modal-footer">
|
||||
<input type="hidden" id="url"/>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><@spring.message code='common.btn.cancel' /></button>
|
||||
<a onclick="removeIt()" class="btn btn-danger" data-dismiss="modal"><@spring.message code='common.btn.define' /></a>
|
||||
<a onclick="modalAction()" class="btn btn-danger" data-dismiss="modal"><@spring.message code='common.btn.define' /></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -162,12 +167,12 @@
|
|||
</div>
|
||||
<@footer>
|
||||
<script type="application/javascript" id="footer_script">
|
||||
function modelShow(url,message) {
|
||||
function modalShow(url,message) {
|
||||
$('#url').val(url);
|
||||
$('#message').html(message);
|
||||
$('#removePostModal').modal();
|
||||
}
|
||||
function removeIt(){
|
||||
function modalAction(){
|
||||
var url=$.trim($("#url").val());
|
||||
<#if (options.admin_pjax!'true') == 'true'>
|
||||
pjax.loadUrl(url);
|
||||
|
|
|
@ -120,18 +120,6 @@
|
|||
</div>
|
||||
<@footer>
|
||||
<script type="application/javascript" id="footer_script">
|
||||
function modelShow(url) {
|
||||
$('#url').val(url);
|
||||
$('#removeCateModal').modal();
|
||||
}
|
||||
function removeIt(){
|
||||
var url=$.trim($("#url").val());
|
||||
<#if (options.admin_pjax!'true') == 'true'>
|
||||
pjax.loadUrl(url);
|
||||
<#else>
|
||||
window.location.href = url;
|
||||
</#if>
|
||||
}
|
||||
function save() {
|
||||
var param = $("#tagSaveForm").serialize();
|
||||
$.post("/admin/tag/save",param,function (data) {
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
<div class="col-md-6 col-lg-3 col theme-body">
|
||||
<div class="box box-solid">
|
||||
<div class="box-body theme-thumbnail" style="background-image: url(/${theme.themeName!}/screenshot.png)">
|
||||
<div class="pull-right btn-delete" style="display: none" onclick="modelShow('/admin/themes/remove?themeName=${theme.themeName}')"><i class="fa fa-times fa-lg" aria-hidden="true"></i></div>
|
||||
<div class="pull-right btn-delete" style="display: none" onclick="modalShow('/admin/themes/remove?themeName=${theme.themeName}')"><i class="fa fa-times fa-lg" aria-hidden="true"></i></div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<span class="theme-title">
|
||||
|
@ -128,7 +128,7 @@
|
|||
$(this).find(".theme-thumbnail").css("opacity","1");
|
||||
$(this).find(".btn-theme-setting,.btn-theme-enable,.btn-theme-update").hide();
|
||||
});
|
||||
function modelShow(url) {
|
||||
function modalShow(url) {
|
||||
$('#url').val(url);
|
||||
$('#removeThemeModal').modal();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue