diff --git a/controllers/BlogController.go b/controllers/BlogController.go index 7a0297f..75498fa 100644 --- a/controllers/BlogController.go +++ b/controllers/BlogController.go @@ -86,6 +86,7 @@ func (this *BlogController) Save() { } this.ServeJSON() userService.CountBlog(uid.(int64)) + utils.PostDataZZ(blog.Id) return } @@ -129,6 +130,7 @@ func (this *BlogController) Edit() { } this.ServeJSON() userService.CountBlog(uid.(int64)) + utils.PostDataZZ(id) return } @@ -138,12 +140,12 @@ func (this *BlogController) Get() { idStr := this.Ctx.Input.Param(":id") id, _ := strconv.ParseInt(idStr, 10, 64) blog, err := blogService.GetBlog(id) - blog.User.Salt = "" - blog.User.UserPwd = "" if err != nil { this.Redirect("/404", 302) return } + blog.User.Salt = "" + blog.User.UserPwd = "" if uid := this.GetSession("userid"); uid != nil { if blog.UserId == uid.(int64) { this.Data["IsAuthor"] = true @@ -161,6 +163,7 @@ func (this *BlogController) Get() { userService.CountBrows(blog.UserId) blogService.EditBlogBrows(id) } + //utils.PostDataZZ(id) return } diff --git a/utils/data_zz.go b/utils/data_zz.go new file mode 100644 index 0000000..b393c46 --- /dev/null +++ b/utils/data_zz.go @@ -0,0 +1,30 @@ +package utils + +import ( + "io/ioutil" + "net/http" + "strconv" + "strings" +) + +//const baseUrl = "http://localhost/blog/" +const baseUrl = "https://www.aiprose.com/blog/" + +func PostDataZZ(id int64) { + //if len(ids) < 1 { + // return + //} + //dataStr := "" + //for id := range ids{ + // dataStr = dataStr + baseUrl + string(id) + "\n" + //} + dataStr := baseUrl + strconv.FormatInt(id, 10) + url := "http://data.zz.baidu.com/urls?site=www.aiprose.com&token=lO2wHMVqVq8SC9Ag" + res, err := http.Post(url, "text/plain", strings.NewReader(dataStr)) + if err != nil { + println(err) + } + defer res.Body.Close() + content, err := ioutil.ReadAll(res.Body) + println(string(content)) +}