Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ac65edb

Browse files
committed
图书总数
1 parent 5f24409 commit ac65edb

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

src/http/controller/sidebar.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ func (SidebarController) WebsiteStat(ctx echo.Context) error {
6565
topicTotal := logic.DefaultTopic.Total()
6666
cmtTotal := logic.DefaultComment.Total()
6767
resourceTotal := logic.DefaultResource.Total()
68+
bookTotal := logic.DefaultGoBook.Total()
6869
userTotal := logic.DefaultUser.Total()
6970

7071
data := map[string]interface{}{
7172
"article": articleTotal,
7273
"project": projectTotal,
7374
"topic": topicTotal,
7475
"resource": resourceTotal,
76+
"book": bookTotal,
7577
"comment": cmtTotal,
7678
"user": userTotal,
7779
}

src/logic/gobook.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ func (GoBookLogic) FindById(ctx context.Context, id string) (*model.Book, error)
9494
return book, err
9595
}
9696

97+
// Total 图书总数
98+
func (GoBookLogic) Total() int64 {
99+
total, err := MasterDB.Count(new(model.Book))
100+
if err != nil {
101+
logger.Errorln("GoBookLogic Total error:", err)
102+
}
103+
return total
104+
}
105+
97106
// 图书评论
98107
type BookComment struct{}
99108

static/js/sidebar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ $(function(){
230230
'<li>话题数: <span>'+data.topic+'</span> 个</li>'+
231231
'<li>评论数: <span>'+data.comment+'</span> 条</li>'+
232232
'<li>资源数: <span>'+data.resource+'</span> 个</li>'+
233-
'<li>项目数: <span>'+data.project+'</span> 个</li>';
233+
'<li>项目数: <span>'+data.project+'</span> 个</li>'+
234234
'<li>图书数: <span>'+data.book+'</span> 本</li>';
235235

236236
$('.sb-content .stat-list ul').html(content);

template/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ <h2><a href="/articles/[%:id%]" target="_blank" title="[%:title%]">
423423
</script>
424424

425425
<script type="text/x-jsrender" id="resource-tpl">
426-
<li>[%if #index > 2%]<em>[%:#getIndex()+1%]</em>[%else%]<img src="/static/img/rank_medal[%:#getIndex()+1%].png" width="15px">[%/if%]&nbsp;<a href="/resources/[%:tid%]" title="[%:title%]">[%substring:title 35%]</a><span class="pull-right" style="color: #bbb;"><span class="glyphicon glyphicon-eye-open"></span> [%:rank_view%]</span></li>
426+
<li>[%if #index > 2%]<em>[%:#getIndex()+1%]</em>[%else%]<img src="/static/img/rank_medal[%:#getIndex()+1%].png" width="15px">[%/if%]&nbsp;<a href="/resources/[%:id%]" title="[%:title%]">[%substring:title 35%]</a><span class="pull-right" style="color: #bbb;"><span class="glyphicon glyphicon-eye-open"></span> [%:rank_view%]</span></li>
427427
</script>
428428

429429
<script type="text/x-jsrender" id="no-resource-tpl">
@@ -491,7 +491,7 @@ <h2><a href="/articles/[%:id%]" target="_blank" title="[%:title%]">
491491

492492
$(listIdSelector).html($('#loading-tpl').html());
493493

494-
var params = {objtype: objtype, limit: 10, rank_type: type}
494+
var params = {objtype: objtype, limit: 10, rank_type: type, fr: "index"}
495495
$.getJSON('/rank/view', params, function(result) {
496496
if (result.ok) {
497497
var data = result.data.list;

0 commit comments

Comments
 (0)