修复删除项目BUG

pull/25/merge
Minho 2017-05-09 18:17:08 +08:00
parent aad8ebf8ae
commit d012624ac5
3 changed files with 21 additions and 15 deletions

View File

@ -12,9 +12,8 @@ import (
"github.com/astaxie/beego/orm"
"github.com/astaxie/beego/logs"
"github.com/lifei6671/godoc/conf"
"github.com/lifei6671/gocaptcha"
"syscall"
)
// RegisterDataBase 注册数据库
@ -32,7 +31,13 @@ func RegisterDataBase() {
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
@ -146,7 +151,6 @@ func RegisterFunction() {
}
func init() {
syscall.Setenv("ZONEINFO","./lib/time/zoneinfo.zip")
gocaptcha.ReadFonts("./static/fonts", ".ttf")
gob.Register(models.Member{})
}

View File

@ -1,6 +1,8 @@
package main
import (
"fmt"
"os"
_ "github.com/go-sql-driver/mysql"
_ "github.com/lifei6671/godoc/routers"
_ "github.com/astaxie/beego/session/redis"
@ -8,8 +10,6 @@ import (
_ "github.com/astaxie/beego/session/mysql"
"github.com/astaxie/beego"
"github.com/lifei6671/godoc/commands"
"fmt"
"os"
"github.com/lifei6671/godoc/controllers"
)
@ -19,6 +19,7 @@ var (
GO_VERSION string
)
func main() {
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.Run()
}

View File

@ -214,17 +214,17 @@ func (m *Book) ThoroughDeleteBook(id int) error {
return err
}
o.Begin()
sql1 := "DELETE FROM " + NewComment().TableNameWithPrefix() + " WHERE book_id = ?"
_,err := o.Raw(sql1,m.BookId).Exec()
if err != nil {
o.Rollback()
return err
}
//sql1 := "DELETE FROM " + NewComment().TableNameWithPrefix() + " WHERE book_id = ?"
//
//_,err := o.Raw(sql1,m.BookId).Exec()
//
//if err != nil {
// o.Rollback()
// return err
//}
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 {
o.Rollback()