mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-04-05 20:17:53 +08:00
修复在sqlite数据库下项目成员切换权限错误的BUG
This commit is contained in:
parent
186810cb4a
commit
8486bb3809
@ -15,6 +15,7 @@ import (
|
||||
"github.com/lifei6671/godoc/models"
|
||||
"strings"
|
||||
"github.com/lifei6671/godoc/commands/migrate"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
|
||||
@ -43,6 +44,8 @@ func RegisterDataBase() {
|
||||
}
|
||||
}else if adapter == "sqlite3" {
|
||||
database := beego.AppConfig.String("db_database")
|
||||
dbPath := filepath.Dir(database)
|
||||
os.MkdirAll(dbPath,0777)
|
||||
|
||||
orm.RegisterDataBase("default", "sqlite3", database)
|
||||
}
|
||||
|
@ -79,7 +79,11 @@ func (m *Relationship) UpdateRoleId(book_id,member_id, role_id int) (*Relationsh
|
||||
}
|
||||
m.RoleId = role_id
|
||||
|
||||
_,err = o.InsertOrUpdate(m)
|
||||
if m.RelationshipId > 0 {
|
||||
_,err = o.Update(m)
|
||||
}else{
|
||||
_,err = o.Insert(m)
|
||||
}
|
||||
|
||||
return m,err
|
||||
|
||||
@ -176,10 +180,18 @@ func (m *Relationship) Transfer(book_id,founder_id,receive_id int) error {
|
||||
o.Rollback()
|
||||
return err
|
||||
}
|
||||
if _,err := o.InsertOrUpdate(receive);err != nil {
|
||||
o.Rollback()
|
||||
return err
|
||||
if receive.RelationshipId > 0 {
|
||||
if _,err := o.Update(receive);err != nil {
|
||||
o.Rollback()
|
||||
return err
|
||||
}
|
||||
}else{
|
||||
if _,err := o.Insert(receive);err != nil {
|
||||
o.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return o.Commit()
|
||||
}
|
||||
|
||||
|
@ -23,3 +23,13 @@ func AbsolutePath(p string) (string,error) {
|
||||
}
|
||||
return s,nil
|
||||
}
|
||||
|
||||
// FileExists reports whether the named file or directory exists.
|
||||
func FileExists(name string) bool {
|
||||
if _, err := os.Stat(name); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
Loading…
Reference in New Issue
Block a user