mirror of https://github.com/halo-dev/halo
👽 bored!
parent
39b986376a
commit
bfdc736a94
|
@ -196,4 +196,12 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
* @return List<Post>
|
||||
*/
|
||||
List<Post> findPostsByPostTypeOrderByPostViewsDesc(String postStatus);
|
||||
|
||||
/**
|
||||
* 获取所有文章阅读量总和
|
||||
*
|
||||
* @return Long
|
||||
*/
|
||||
@Query(value = "select sum(post_views) from halo_post", nativeQuery = true)
|
||||
Long getPostViewsSum();
|
||||
}
|
||||
|
|
|
@ -231,6 +231,13 @@ public interface PostService {
|
|||
*/
|
||||
List<Post> relatedPosts(Post post);
|
||||
|
||||
/**
|
||||
* 获取所有文章的阅读量
|
||||
*
|
||||
* @return Long
|
||||
*/
|
||||
Long getPostViews();
|
||||
|
||||
/**
|
||||
* 生成rss
|
||||
*
|
||||
|
|
|
@ -398,6 +398,16 @@ public class PostServiceImpl implements PostService {
|
|||
return allPosts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有文章的阅读量
|
||||
*
|
||||
* @return Long
|
||||
*/
|
||||
@Override
|
||||
public Long getPostViews() {
|
||||
return postRepository.getPostViewsSum();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成rss
|
||||
*
|
||||
|
|
|
@ -4,8 +4,6 @@ import cc.ryanc.halo.model.domain.Tag;
|
|||
import cc.ryanc.halo.repository.TagRepository;
|
||||
import cc.ryanc.halo.service.TagService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -22,8 +20,6 @@ public class TagServiceImpl implements TagService {
|
|||
@Autowired
|
||||
private TagRepository tagRepository;
|
||||
|
||||
private static final String TAGS_CACHE_NAME = "tags";
|
||||
|
||||
/**
|
||||
* 新增/修改标签
|
||||
*
|
||||
|
@ -31,7 +27,6 @@ public class TagServiceImpl implements TagService {
|
|||
* @return Tag
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(value = TAGS_CACHE_NAME, allEntries = true, beforeInvocation = true)
|
||||
public Tag saveByTag(Tag tag) {
|
||||
return tagRepository.save(tag);
|
||||
}
|
||||
|
@ -43,7 +38,6 @@ public class TagServiceImpl implements TagService {
|
|||
* @return Tag
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(value = TAGS_CACHE_NAME, allEntries = true, beforeInvocation = true)
|
||||
public Tag removeByTagId(Long tagId) {
|
||||
Optional<Tag> tag = findByTagId(tagId);
|
||||
tagRepository.delete(tag.get());
|
||||
|
@ -56,7 +50,6 @@ public class TagServiceImpl implements TagService {
|
|||
* @return List
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = TAGS_CACHE_NAME, key = "'tag'")
|
||||
public List<Tag> findAllTags() {
|
||||
return tagRepository.findAll();
|
||||
}
|
||||
|
|
|
@ -90,6 +90,9 @@ public class AdminController extends BaseController {
|
|||
model.addAttribute("comments", comments);
|
||||
|
||||
model.addAttribute("mediaCount", HaloConst.ATTACHMENTS.size());
|
||||
|
||||
Long postViewsSum = postService.getPostViews();
|
||||
model.addAttribute("postViewsSum",postViewsSum);
|
||||
return "admin/admin_index";
|
||||
}
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@
|
|||
<div class="small-box bg-red">
|
||||
<div class="inner"><h3 id="blogStart">1</h3><p>成立天数</p></div>
|
||||
<div class="icon"><i class="ion ion-pie-graph"></i></div>
|
||||
<a href="#" class="small-box-footer">${options.blog_start?default('0000-00-00')} <i class="fa fa-star"></i></a>
|
||||
<a href="#" class="small-box-footer" data-toggle="modal" data-target="#blogInfo">${options.blog_start?default('0000-00-00')} <i class="fa fa-star"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</#if>
|
||||
|
@ -335,6 +335,29 @@
|
|||
</#if>
|
||||
</div>
|
||||
</section>
|
||||
<div class="modal fade" id="blogInfo" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="myModalLabel">博客数据</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>「${options.blog_title?if_exists}」已经运行了<span id="blogStartDay"></span>天了。</p>
|
||||
<p>在此期间:</p>
|
||||
<p>累计发表了${postCount?default(0)}篇文章。</p>
|
||||
<p>累计创建了<@commonTag method="tags">${tags?size}</@commonTag>个标签。</p>
|
||||
<p>累计获得了${commentCount}条评论。</p>
|
||||
<p>累计添加了<@commonTag method="links">${links?size}</@commonTag>个友链。</p>
|
||||
<p>文章总访问${postViewsSum}次。</p>
|
||||
<p>加油!不要因为走的太远,而忘了当初为什么出发。</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/static/plugins/layer/layer.js"></script>
|
||||
<script src="/static/js/app.js"></script>
|
||||
<script type="application/javascript">
|
||||
|
@ -344,6 +367,7 @@
|
|||
var parseDate = dateEnd.getTime() - dateBegin.getTime();
|
||||
var days = Math.floor(parseDate/(24*3600*1000));
|
||||
$('#blogStart').html(days+1);
|
||||
$('#blogStartDay').html(days+1);
|
||||
});
|
||||
function openAllLogs() {
|
||||
layer.open({
|
||||
|
|
Loading…
Reference in New Issue