Bläddra i källkod

修改api路径

layui
yirenyishi 6 år sedan
förälder
incheckning
b76c55ca0f
  1. 2
      controllers/BlogController.go
  2. 1
      controllers/PageController.go
  3. 28
      filter/Security.go
  4. 4
      main.go
  5. 2
      routers/NoteRouter.go
  6. 9
      routers/UserRouter.go
  7. 3
      service/LikeService.go
  8. 1
      static/css/sui.min.css
  9. 4
      static/js/aljquery.js
  10. 25
      static/js/seo.js
  11. 12
      static/js/sui.js
  12. 8
      views/blog.html
  13. 2
      views/editblog.html
  14. 8
      views/iframe/blog.html
  15. 14
      views/iframe/note.html
  16. 9
      views/iframe/user.html
  17. 30
      views/login.html
  18. 2
      views/newblog.html
  19. 6
      views/note.html
  20. 2
      views/regist.html
  21. 2
      views/ublogs.html
  22. 2
      views/ulike.html
  23. 6
      views/unote.html

2
controllers/BlogController.go

@ -135,6 +135,7 @@ func (this *BlogController) Get() {
func (this *BlogController) Del() {
blogService := service.BlogService{}
userService := service.UserService{}
likeService := service.LikeService{}
uid := this.GetSession("userid")
if uid == nil {
this.Data["json"] = models.ReurnError(401, "")
@ -164,6 +165,7 @@ func (this *BlogController) Del() {
this.Data["json"] = models.ReurnSuccess("")
this.ServeJSON()
userService.CountBlog(uid.(int64))
likeService.DelLikeByBlog(id)
return
}

1
controllers/PageController.go

@ -43,6 +43,7 @@ func (this *PageController) IframeNote() {
uid := this.GetSession("userid")
if uid == nil {
this.Data["IsLogin"] = false
this.Data["NoteColl"] = []string{}
}else {
this.Data["IsLogin"] = true
noteColls,err:=noteService.GetNoteColl(uid.(int64))

28
filter/Security.go

@ -3,25 +3,21 @@ package filter
import (
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/logs"
"beeblog/models"
"encoding/json"
)
var FilterAdmin = func(ctx *context.Context) {
url := ctx.Input.URI()
refer := ctx.Input.Refer()
logs.Info(url)
//logs.Info(refer)
//logs.Info("https://www.aiprose.com"+url)
if "https://www.aiprose.com"+url == refer {
ctx.Input.SetData("refresh", true)
}
//beego.Informational(url)
//if url != "/login"{
// ctx.Redirect(302, "/login")
//}
var LogFilter = func(ctx *context.Context) {
logs.Info(ctx.Input.URI())
}
var FilterLoginInfo = func(ctx *context.Context) {
var FilterAdmin = func(ctx *context.Context) {
if ctx.Input.Session("userid") != nil {
//ctx.
ctx.Output.SetStatus(200)
ctx.Output.Header("Access-Control-Allow-Origin","*")
result := models.ReurnError(401, "")
if b,err := json.Marshal(result); err != nil {
ctx.Output.Body(b)
}
return
}
}

4
main.go

@ -11,8 +11,8 @@ import (
func init() {
models.RegistDB()
beego.InsertFilter("/*", beego.BeforeRouter, filter.FilterAdmin)
//beego.InsertFilter("/*", beego.FinishRouter, filter.FilterLoginInfo)
beego.InsertFilter("/*", beego.BeforeRouter, filter.LogFilter)
beego.InsertFilter("/api/*", beego.BeforeRouter, filter.FilterAdmin)
}
func main() {
orm.Debug = false

2
routers/NoteRouter.go

@ -10,7 +10,7 @@ func init() {
beego.Router("/note", &controllers.NoteController{}, "get:Note")
beego.Router("/api/notecoll/save", &controllers.NoteController{}, "post:SaveNoteColl")
beego.Router("/api/notecoll/edit", &controllers.NoteController{}, "post:EditNoteColl")
beego.Router("/api/api/note/save", &controllers.NoteController{}, "post:Save")
beego.Router("/api/note/save", &controllers.NoteController{}, "post:Save")
beego.Router("/api/note/edit/:id([0-9]+)", &controllers.NoteController{}, "post:Edit")
beego.Router("/api/note/del/:id([0-9]+)", &controllers.NoteController{}, "post:Delete")
beego.Router("/api/notecol/del/:id([0-9]+)", &controllers.NoteController{}, "post:DelNoteColl")

9
routers/UserRouter.go

@ -8,17 +8,14 @@ import (
func init() {
beego.Router("/login", &controllers.UserController{}, "get:LoginPage")
beego.Router("/logout", &controllers.UserController{}, "get:Logout")
beego.Router("/login", &controllers.UserController{}, "post:Login")
beego.Router("/regist", &controllers.UserController{}, "post:Regist")
beego.Router("/regist", &controllers.UserController{}, "get:RegistPage")
beego.Router("/api/user/edit", &controllers.UserController{}, "post:Edit")
beego.Router("/u/:id([0-9]+)", &controllers.UserController{}, "get:UserInfo")
beego.Router("/api/user/edit", &controllers.UserController{}, "post:Edit")
beego.Router("/api/login", &controllers.UserController{}, "post:Login")
beego.Router("/api/regist", &controllers.UserController{}, "post:Regist")
beego.Router("/me/blog", &controllers.UserController{}, "get:PersonBlog")
beego.Router("/me/note", &controllers.UserController{}, "get:PersonNote")
beego.Router("/me/like", &controllers.UserController{}, "get:PersonLike")
beego.Router("/me/info", &controllers.UserController{}, "get:PersonInfo")
}

3
service/LikeService.go

@ -66,3 +66,6 @@ func (this *LikeService) countLike(num int, size int, uid int64) (*utils.Page, e
}
return utils.PageUtil(totalCount, num, size), nil
}
func (likeService LikeService) DelLikeByBlog(id int64) {
orm.NewOrm().QueryTable(models.Like{}).Filter("BlogId", id).Delete()
}

1
static/css/sui.min.css

File diff suppressed because one or more lines are too long

4
static/js/aljquery.js

File diff suppressed because one or more lines are too long

25
static/js/seo.js

@ -0,0 +1,25 @@
$(function () {
/*百度收录*/
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
/*360收录*/
var qihuo = document.createElement('script');
if (curProtocol === 'https') {
qihuo.src = 'https://jspassport.ssl.qhimg.com/11.0.1.js?d33b14200fa89b7ecd3780341cd234c';
}
else {
qihuo.src = 'http://js.passport.qihucdn.com/11.0.1.js?d33b14200fa89b7ecd3780341cd234c4';
}
qihuo.id = "sozz"
var s = document.getElementsByTagName("script")[1];
s.parentNode.insertBefore(qihuo, s);
})

12
static/js/sui.js

File diff suppressed because one or more lines are too long

8
views/blog.html

@ -112,7 +112,7 @@
});
return
}
$.post('/comms/save', {
$.post('/api/comms/save', {
blog: {{.Blog.Id}},
commval: commval
},
@ -168,7 +168,7 @@
layer.close(index);
return
}
$.post('/comms/save', {blog: {{.Blog.Id}},commval: val,pid: pid},
$.post('/api/comms/save', {blog: {{.Blog.Id}},commval: val,pid: pid},
function (data) {
if (data.Status == 0) {
var res = '<div style="margin-left: 18px" class="ccomm-' + data.Data.Id + '">\n' +
@ -198,7 +198,7 @@
}
function like(id) {
$.get('/like/' + id,
$.get('/api/like/' + id,
function (data) {
if (data.Status == 0) {
window.location.href = window.location.href
@ -211,7 +211,7 @@
}
function unlike(id) {
$.get('/unlike/' + id,
$.get('/api/unlike/' + id,
function (data) {
if (data.Status == 0) {
window.location.href = window.location.href

2
views/editblog.html

@ -83,7 +83,7 @@
})
function saveBlogCallback(callback) {
$.post('/blog/edit', tobj,
$.post('/api/blog/edit', tobj,
function (data) {
if (data.Status == 0) {
storage.removeItem("blogHtml");

8
views/iframe/blog.html

@ -6,11 +6,9 @@
<meta name="description" content="云悦,个人随笔是一个面向IT技术人员,提供个人平时工作总结和在线记录学习笔记,个人技术博客,在线云笔记,码农笔录,最新的技术博客,www.aiprose.com">
<meta name="keywords"
content="云悦,个人随笔,博客,个人博客,个人笔记,技术博客,免费云笔记,云笔记,随笔,IT博客,谷歌地图,码农笔录,www.aiprose.com,aiprose.com,aiprose">
<link rel="stylesheet" href="//g.alicdn.com/sui/sui3/0.0.18/css/sui.min.css">
<script type="text/javascript" src="//g.alicdn.com/sj/lib/jquery/dist/jquery.min.js"></script>
{{/*<script type="text/javascript" src="/static/js/aljquery.js"></script>*/}}
<script type="text/javascript" src="/static/js/sui.js"></script>
<script type="text/javascript" src="/static/js/layer.js"></script>
<link rel="stylesheet" href="//oss.aiprose.com/ali/sui/css/sui.min.css">
<script type="text/javascript" src="//oss.aiprose.com/ali/jquery/jquery.min.js"></script>
<script type="text/javascript" src="//oss.aiprose.com/ali/sui/js/sui.min.js"></script>
<title>发布博客 - 云悦</title>
<style>
.common {

14
views/iframe/note.html

@ -6,10 +6,9 @@
<meta name="description" content="云悦,个人随笔是一个面向IT技术人员,提供个人平时工作总结和在线记录学习笔记,个人技术博客,在线云笔记,码农笔录,最新的技术博客,www.aiprose.com">
<meta name="keywords"
content="云悦,个人随笔,博客,个人博客,个人笔记,技术博客,免费云笔记,云笔记,随笔,IT博客,谷歌地图,码农笔录,www.aiprose.com,aiprose.com,aiprose">
<link rel="stylesheet" href="//g.alicdn.com/sui/sui3/0.0.18/css/sui.min.css">
<script type="text/javascript" src="//g.alicdn.com/sj/lib/jquery/dist/jquery.min.js"></script>
{{/*<script type="text/javascript" src="/static/js/aljquery.js"></script>*/}}
<script type="text/javascript" src="/static/js/sui.js"></script>
<link rel="stylesheet" href="//oss.aiprose.com/ali/sui/css/sui.min.css">
<script type="text/javascript" src="//oss.aiprose.com/ali/jquery/jquery.min.js"></script>
<script type="text/javascript" src="//oss.aiprose.com/ali/sui/js/sui.min.js"></script>
<script type="text/javascript" src="/static/js/layer.js"></script>
<title>发布笔记 - 云悦</title>
<style>
@ -45,16 +44,17 @@
</body>
<script>
$(function () {
debugger
if (!{{.IsLogin}}) {
parent.location.href = "/login"
}
if ({{.NoteColl|len}} == 0) {
return
}else if ({{.NoteColl|len}} == 0) {
parent.location.href = "/me/note"
}
$("#saveBtn").click(function () {
var pid = $("#catory").val()
var title = $("#lable").val()
$.post('/note/save', {
$.post('/api/note/save', {
pid: pid,
title: title
},

9
views/iframe/user.html

@ -6,10 +6,9 @@
<meta name="description" content="云悦,个人随笔是一个面向IT技术人员,提供个人平时工作总结和在线记录学习笔记,个人技术博客,在线云笔记,码农笔录,最新的技术博客,www.aiprose.com">
<meta name="keywords"
content="云悦,个人随笔,博客,个人博客,个人笔记,技术博客,免费云笔记,云笔记,随笔,IT博客,谷歌地图,码农笔录,www.aiprose.com,aiprose.com,aiprose">
<link rel="stylesheet" href="//g.alicdn.com/sui/sui3/0.0.18/css/sui.min.css">
<script type="text/javascript" src="//g.alicdn.com/sj/lib/jquery/dist/jquery.min.js"></script>
{{/*<script type="text/javascript" src="/static/js/aljquery.js"></script>*/}}
<script type="text/javascript" src="/static/js/sui.js"></script>
<link rel="stylesheet" href="//oss.aiprose.com/ali/sui/css/sui.min.css">
<script type="text/javascript" src="//oss.aiprose.com/ali/jquery/jquery.min.js"></script>
<script type="text/javascript" src="//oss.aiprose.com/ali/sui/js/sui.min.js"></script>
<script type="text/javascript" src="/static/js/layer.js"></script>
<title>首页 - 云悦</title>
<style>
@ -101,7 +100,7 @@
obj.qqnum = $("#qqnum").val()
obj.catory = $("#catory").val()
obj.mdesc = $("#mdesc").val()
$.post('/user/edit', obj,
$.post('/api/user/edit', obj,
function (data) {
if (data.Status == 0) {
parent.layer.msg("保存成功", {icon: 6});

30
views/login.html

@ -47,7 +47,7 @@
});
return
}
$.post('/login', {
$.post('/api/login', {
username: username,
userpwd: userpwd
},
@ -63,31 +63,5 @@
})
})
</script>
<script>
$(function () {
/*百度收录*/
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
/*360收录*/
var qihuo = document.createElement('script');
if (curProtocol === 'https') {
qihuo.src = 'https://jspassport.ssl.qhimg.com/11.0.1.js?d33b14200fa89b7ecd3780341cd234c';
}
else {
qihuo.src = 'http://js.passport.qihucdn.com/11.0.1.js?d33b14200fa89b7ecd3780341cd234c4';
}
qihuo.id = "sozz"
var s = document.getElementsByTagName("script")[1];
s.parentNode.insertBefore(qihuo, s);
})
</script>
<script type="text/javascript" src="/static/js/seo.js"></script>
</html>

2
views/newblog.html

@ -93,7 +93,7 @@
})
function saveBlogCallback(callback) {
$.post('/blog/new', tobj,
$.post('/api/blog/new', tobj,
function (data) {
if (data.Status == 0) {
storage.removeItem("blogHtml");

6
views/note.html

@ -125,7 +125,7 @@
});
return
}
$.post('/note/edit/' + note.Id, {
$.post('/api/note/edit/' + note.Id, {
noteHtml: noteHtml
},
function (data) {
@ -140,7 +140,7 @@
}
function noteClick(id) {
$.get('/note/' + id,
$.get('/api/note/' + id,
function (data) {
if (!data.Status) {
if (data.NoteHtml && data.NoteHtml.trim().length != 0) {
@ -205,7 +205,7 @@
layer.confirm('删除确认', {
btn: ['确认', '手滑了'] //按钮
}, function () {
$.post('/note/del/' + note.Id,
$.post('/api/note/del/' + note.Id,
function (data) {
if (data.Status == 0) {
var subMenu = $(".sub-menu li a")

2
views/regist.html

@ -47,7 +47,7 @@
});
return
}
$.post('/regist', {
$.post('/api/regist', {
username: username,
userpwd: userpwd
},

2
views/ublogs.html

@ -61,7 +61,7 @@
layer.confirm('删除后将无法恢复', {
btn: ['确认', '手滑了'] //按钮
}, function () {
$.post('/blog/del/' + id,
$.post('/api/blog/del/' + id,
function (data) {
if (data.Status == 0) {
$(obj).parent().parent().parent().remove()

2
views/ulike.html

@ -60,7 +60,7 @@
layer.confirm('删除后将无法恢复', {
btn: ['确认', '手滑了'] //按钮
}, function () {
$.get('/unlike/' + id,
$.get('/api/unlike/' + id,
function (data) {
if (data.Status == 0) {
$(obj).parent().parent().parent().remove()

6
views/unote.html

@ -46,7 +46,7 @@
layer.close(index);
return
}
$.post('/notecoll/edit', {
$.post('/api/notecoll/edit', {
title: val.trim(),
id: id
},
@ -70,7 +70,7 @@
layer.confirm('文件夹下的所有笔记都将会删除', {
btn: ['确认', '手滑了'] //按钮
}, function () {
$.post('/notecol/del/' + id,
$.post('/api/notecol/del/' + id,
function (data) {
if (data.Status == 0) {
$(obj).parent().parent().remove()
@ -101,7 +101,7 @@
layer.close(index);
return
}
$.post('/notecoll/save', {
$.post('/api/notecoll/save', {
title: val.trim()
},
function (data) {

Laddar…
Avbryt
Spara