mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-12-20 04:00:05 +08:00
修复删除项目BUG
This commit is contained in:
@@ -12,9 +12,8 @@ import (
|
|||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
"github.com/astaxie/beego/logs"
|
"github.com/astaxie/beego/logs"
|
||||||
"github.com/lifei6671/godoc/conf"
|
"github.com/lifei6671/godoc/conf"
|
||||||
|
|
||||||
"github.com/lifei6671/gocaptcha"
|
"github.com/lifei6671/gocaptcha"
|
||||||
"syscall"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterDataBase 注册数据库
|
// RegisterDataBase 注册数据库
|
||||||
@@ -32,7 +31,13 @@ func RegisterDataBase() {
|
|||||||
|
|
||||||
orm.RegisterDataBase("default", "mysql", dataSource)
|
orm.RegisterDataBase("default", "mysql", dataSource)
|
||||||
|
|
||||||
orm.DefaultTimeLoc, _ = time.LoadLocation(timezone)
|
location , err := time.LoadLocation(timezone);
|
||||||
|
if err == nil {
|
||||||
|
orm.DefaultTimeLoc = location
|
||||||
|
}else{
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterModel 注册Model
|
// RegisterModel 注册Model
|
||||||
@@ -146,7 +151,6 @@ func RegisterFunction() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
syscall.Setenv("ZONEINFO","./lib/time/zoneinfo.zip")
|
|
||||||
gocaptcha.ReadFonts("./static/fonts", ".ttf")
|
gocaptcha.ReadFonts("./static/fonts", ".ttf")
|
||||||
gob.Register(models.Member{})
|
gob.Register(models.Member{})
|
||||||
}
|
}
|
||||||
6
main.go
6
main.go
@@ -1,6 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
_ "github.com/lifei6671/godoc/routers"
|
_ "github.com/lifei6671/godoc/routers"
|
||||||
_ "github.com/astaxie/beego/session/redis"
|
_ "github.com/astaxie/beego/session/redis"
|
||||||
@@ -8,8 +10,6 @@ import (
|
|||||||
_ "github.com/astaxie/beego/session/mysql"
|
_ "github.com/astaxie/beego/session/mysql"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/lifei6671/godoc/commands"
|
"github.com/lifei6671/godoc/commands"
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"github.com/lifei6671/godoc/controllers"
|
"github.com/lifei6671/godoc/controllers"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@ var (
|
|||||||
GO_VERSION string
|
GO_VERSION string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
fmt.Printf("MinDoc version => %s\nbuild time => %s\nstart directory => %s\n%s\n", VERSION, BUILD_TIME, os.Args[0],GO_VERSION)
|
fmt.Printf("MinDoc version => %s\nbuild time => %s\nstart directory => %s\n%s\n", VERSION, BUILD_TIME, os.Args[0],GO_VERSION)
|
||||||
@@ -33,6 +34,7 @@ func main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
beego.ErrorController(&controllers.ErrorController{})
|
beego.ErrorController(&controllers.ErrorController{})
|
||||||
beego.Run()
|
beego.Run()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,17 +214,17 @@ func (m *Book) ThoroughDeleteBook(id int) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
o.Begin()
|
o.Begin()
|
||||||
sql1 := "DELETE FROM " + NewComment().TableNameWithPrefix() + " WHERE book_id = ?"
|
//sql1 := "DELETE FROM " + NewComment().TableNameWithPrefix() + " WHERE book_id = ?"
|
||||||
|
//
|
||||||
_,err := o.Raw(sql1,m.BookId).Exec()
|
//_,err := o.Raw(sql1,m.BookId).Exec()
|
||||||
|
//
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
o.Rollback()
|
// o.Rollback()
|
||||||
return err
|
// return err
|
||||||
}
|
//}
|
||||||
sql2 := "DELETE FROM " + NewDocument().TableNameWithPrefix() + " WHERE book_id = ?"
|
sql2 := "DELETE FROM " + NewDocument().TableNameWithPrefix() + " WHERE book_id = ?"
|
||||||
|
|
||||||
_,err = o.Raw(sql2,m.BookId).Exec()
|
_,err := o.Raw(sql2,m.BookId).Exec()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
o.Rollback()
|
o.Rollback()
|
||||||
|
|||||||
Reference in New Issue
Block a user