瀏覽代碼

修复删除项目BUG

Minho 8 年之前
父節點
當前提交
d012624ac5
共有 3 個文件被更改,包括 21 次插入15 次删除
  1. 8 4
      commands/command.go
  2. 4 2
      main.go
  3. 9 9
      models/book.go

+ 8 - 4
commands/command.go

@@ -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{})
 }

+ 4 - 2
main.go

@@ -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()
 }

+ 9 - 9
models/book.go

@@ -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()