From 9a197a41adef476ef3de027d30e520151055387a Mon Sep 17 00:00:00 2001 From: yirenyishi Date: Mon, 3 Dec 2018 22:48:26 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=8D=9A=E5=AE=A2=E7=9A=84?= =?UTF-8?q?=E8=AF=84=E8=AE=BA=E5=92=8C=E6=94=B6=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +--- controllers/CommentController.go | 4 ++-- controllers/LikeController.go | 4 ++-- service/UserService.go | 6 ++++-- static/css/us.css | 2 +- views/index.html | 8 ++++---- views/us.html | 6 +++--- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 0d48621..294303e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,4 @@ * go get github.com/go-sql-driver/mysql -* go get github.com/mattn/go-sqlite3 - -* go get github.com/Unknwon/com \ No newline at end of file +* go get github.com/olivere/elastic \ No newline at end of file diff --git a/controllers/CommentController.go b/controllers/CommentController.go index d59eba1..06a0723 100644 --- a/controllers/CommentController.go +++ b/controllers/CommentController.go @@ -46,7 +46,7 @@ func (this *CommentController) Save() { this.Data["json"] = models.ReurnError(500, "保存失败") } this.ServeJSON() - service.CountComments(uid.(int64)) + service.CountComments(uid.(int64),blogId) return } @@ -78,6 +78,6 @@ func (this *CommentController) Del() { this.Data["json"] = models.ReurnError(500, "保存失败") } this.ServeJSON() - service.CountComments(uid.(int64)) + service.CountComments(uid.(int64),id) return } diff --git a/controllers/LikeController.go b/controllers/LikeController.go index 452b8ac..cb041d3 100644 --- a/controllers/LikeController.go +++ b/controllers/LikeController.go @@ -27,7 +27,7 @@ func (this *LikeController) Save() { this.Data["json"] = models.ReurnSuccess("") } this.ServeJSON() - service.CountLike(uid.(int64)) + service.CountLike(uid.(int64),id) return } @@ -47,6 +47,6 @@ func (this *LikeController) Delete() { this.Data["json"] = models.ReurnSuccess("") } this.ServeJSON() - service.CountLike(uid.(int64)) + service.CountLike(uid.(int64),id) return } diff --git a/service/UserService.go b/service/UserService.go index c70f1b5..89236ac 100644 --- a/service/UserService.go +++ b/service/UserService.go @@ -53,16 +53,18 @@ func CountBrows(uid int64) { o.Raw("UPDATE `auth_user` SET `blog_browes` = (select SUM(browses) browses from blog where user_id = ?) WHERE `id` = ? ", uid, uid).QueryRow(&browses) //获取总条数 return } -func CountComments(uid int64) { +func CountComments(uid int64,bid int64) { o := orm.NewOrm() browses := 0 o.Raw("UPDATE `auth_user` SET `blog_comment` = (select count(id) num from comment where cuser_id = ?) WHERE `id` = ? ", uid, uid).QueryRow(&browses) //获取总条数 + o.Raw("UPDATE `blog` SET `comments` = (select count(id) num from comment where blog_id = ?) WHERE `id` = ? ", bid, bid).QueryRow(&browses) //获取总条数 return } -func CountLike(uid int64) { +func CountLike(uid int64,bid int64) { o := orm.NewOrm() browses := 0 o.Raw("UPDATE `auth_user` SET `blog_like` = (select count(id) num from tb_like where user_id = ?) WHERE `id` = ?", uid, uid).QueryRow(&browses) + o.Raw("UPDATE `blog` SET `likes` = (select count(id) num from tb_like where blog_id = ?) WHERE `id` = ?", bid, bid).QueryRow(&browses) return } diff --git a/static/css/us.css b/static/css/us.css index d9a137e..0ba0618 100644 --- a/static/css/us.css +++ b/static/css/us.css @@ -4,6 +4,6 @@ a { .us-root{ display: flex; - margin: 0 5%; + margin-left: 5%; font-size: 16px; } \ No newline at end of file diff --git a/views/index.html b/views/index.html index 1198786..a9dcd9a 100644 --- a/views/index.html +++ b/views/index.html @@ -15,13 +15,13 @@
最新发布
{{range .TimeBlog}} -

{{.Title}}

+

{{.Title}}

{{end}}
流量王者
{{range .BrowsBlog}} -

{{.Title}}

+

{{.Title}}

{{end}}
@@ -29,13 +29,13 @@
收藏排行
{{range .LikeBlog}} -

{{.Title}}

+

{{.Title}}

{{end}}
人气最旺
{{range .CommBlog}} -

{{.Title}}

+

{{.Title}}

{{end}}
diff --git a/views/us.html b/views/us.html index 0704d00..781c486 100644 --- a/views/us.html +++ b/views/us.html @@ -10,7 +10,7 @@

个人随笔2.0(golang)版本正式上线

-
+

·项目源码: 点击查看

·项目框架:

@@ -29,8 +29,8 @@
- - + +