From 38ba6d311a1b613a58df3210ed442efc38231695 Mon Sep 17 00:00:00 2001 From: aarone <184600228@qq.com> Date: Sun, 18 Nov 2018 22:22:31 +0800 Subject: [PATCH 1/4] blog1 --- views/blog1.html | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 views/blog1.html diff --git a/views/blog1.html b/views/blog1.html new file mode 100644 index 0000000..8fc470d --- /dev/null +++ b/views/blog1.html @@ -0,0 +1,59 @@ +{{template "header"}} +博客 - 个人随笔 + + + +
+{{template "nav" .}} +
+

{{.Blog.Title}}

+
+ + 头像 + + + 链接 + + + + 时间: + + + + 阅读数: + + + 标签: + Danger + +
+
+ 正文 +
+
+            
+
+ 正文 +
+
+            
+
+ 正文 +
+
+            
+
+ 正文 +
+
+            
+
+
+
+ + 链接 +
+
+
+ + \ No newline at end of file From 8dce9cb263e272922feaa78fb38c73c895609ba8 Mon Sep 17 00:00:00 2001 From: aarone <184600228@qq.com> Date: Sun, 18 Nov 2018 22:27:21 +0800 Subject: [PATCH 2/4] blogcontroller --- controllers/BlogController.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/controllers/BlogController.go b/controllers/BlogController.go index 8b4f6ba..7d97cf4 100644 --- a/controllers/BlogController.go +++ b/controllers/BlogController.go @@ -1,9 +1,9 @@ package controllers import ( - "github.com/astaxie/beego" "beeblog/models" "beeblog/service" + "github.com/astaxie/beego" "strconv" ) @@ -19,7 +19,7 @@ func (this *BlogController) Save() { labels := this.GetStrings("labels[]") blog := &models.Blog{Title: title, BlogHtml: blogHtml, CategoryId: catoryId, UserId: 1} err := service.SaveBlog(blog, labels) - if (err == nil) { + if err == nil { this.Data["json"] = blog } else { this.Data["json"] = models.ReurnError("保存失败") @@ -31,7 +31,7 @@ func (this *BlogController) Get() { idStr := this.Ctx.Input.Param(":id") id, _ := strconv.ParseInt(idStr, 10, 64) blog, err := service.GetBlog(id) - if (err == nil) { + if err == nil { this.Data["Blog"] = blog } this.TplName = "blog.html" @@ -40,3 +40,6 @@ func (this *BlogController) Get() { func (this *BlogController) New() { this.TplName = "newblog.html" } +func (this *BlogController) Blog1() { + this.TplName = "blog1.html" +} From 9a04f5deaddf8a1c6c3f7234cc5f608937465754 Mon Sep 17 00:00:00 2001 From: aarone <184600228@qq.com> Date: Sun, 18 Nov 2018 22:31:04 +0800 Subject: [PATCH 3/4] test --- routers/BlogRouter.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routers/BlogRouter.go b/routers/BlogRouter.go index e927475..7fcf040 100644 --- a/routers/BlogRouter.go +++ b/routers/BlogRouter.go @@ -1,12 +1,13 @@ package routers import ( - "github.com/astaxie/beego" "beeblog/controllers" + "github.com/astaxie/beego" ) func init() { beego.Router("/blog/new", &controllers.BlogController{}, "post:Save") beego.Router("/blog/:id([0-9]+)", &controllers.BlogController{}, "get:Get") beego.Router("/blog/new", &controllers.BlogController{}, "get:New") + beego.Router("/blog1", &controllers.BlogController{}, "get:Blog1") } From 26dd97244a4f2c3ab71289b61e9fa2390f52fa67 Mon Sep 17 00:00:00 2001 From: aarone <184600228@qq.com> Date: Sun, 18 Nov 2018 22:32:28 +0800 Subject: [PATCH 4/4] test --- routers/UserRouter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/UserRouter.go b/routers/UserRouter.go index 5bf1dd6..6cb5b14 100644 --- a/routers/UserRouter.go +++ b/routers/UserRouter.go @@ -1,8 +1,8 @@ package routers import ( - "github.com/astaxie/beego" "beeblog/controllers" + "github.com/astaxie/beego" ) func init() {