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 @@
@@ -29,13 +29,13 @@ 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)版本正式上线