fix:修复mysql兼容问题

This commit is contained in:
lifei6671
2018-11-26 18:54:50 +08:00
parent a64a6c80e6
commit 1b6c7e4793
9 changed files with 57 additions and 38 deletions

View File

@@ -411,7 +411,10 @@ func (c *BookController) Users() {
}
c.Abort("500")
}
//如果不是创始人也不是管理员则不能操作
if book.RoleId != conf.BookFounder && book.RoleId != conf.BookAdmin {
c.Abort("403")
}
c.Data["Model"] = *book
members, totalCount, err := models.NewMemberRelationshipResult().FindForUsersByBookId(book.BookId, pageIndex, conf.PageSize)
@@ -854,7 +857,10 @@ func (c *BookController) Team() {
}
c.ShowErrorPage(500, "系统错误")
}
//如果不是创始人也不是管理员则不能操作
if book.RoleId != conf.BookFounder && book.RoleId != conf.BookAdmin {
c.Abort("403")
}
c.Data["Model"] = book
members, totalCount, err := models.NewTeamRelationship().FindByBookToPager(book.BookId, pageIndex, conf.PageSize)
@@ -884,7 +890,10 @@ func (c *BookController) TeamAdd() {
if err != nil {
c.JsonResult(500, err.Error())
}
//如果不是创始人也不是管理员则不能操作
if book.RoleId != conf.BookFounder && book.RoleId != conf.BookAdmin {
c.Abort("403")
}
_, err = models.NewTeam().First(teamId, "team_id")
if err != nil {
if err == orm.ErrNoRows {
@@ -921,7 +930,11 @@ func (c *BookController) TeamDelete() {
if err != nil {
c.JsonResult(5002, err.Error())
}
beego.Error(book)
//如果不是创始人也不是管理员则不能操作
if book.RoleId != conf.BookFounder && book.RoleId != conf.BookAdmin {
c.Abort("403")
}
err = models.NewTeamRelationship().DeleteByBookId(book.BookId, teamId)
if err != nil {
@@ -944,6 +957,7 @@ func (c *BookController) TeamSearch() {
if err != nil {
c.JsonResult(500, err.Error())
}
searchResult, err := models.NewTeamRelationship().FindNotJoinBookByBookIdentify(book.BookId, keyword, 10)
if err != nil {

View File

@@ -183,7 +183,7 @@ func (c *DocumentController) Edit() {
bookResult := models.NewBookResult()
var err error
// 如果是超级管理者,则不判断权限
// 如果是管理者,则不判断权限
if c.Member.IsAdministrator() {
book, err := models.NewBook().FindByFieldFirst("identify", identify)
if err != nil {
@@ -195,7 +195,7 @@ func (c *DocumentController) Edit() {
bookResult, err = models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
if err != nil {
if err == orm.ErrNoRows {
if err == orm.ErrNoRows || err == models.ErrPermissionDenied{
c.ShowErrorPage(403, "项目不存在或没有权限")
} else {
beego.Error("查询项目时出错 -> ", err)