From 9cb4b6aa250df5a909e71abcd01f1dbcc5ca6b62 Mon Sep 17 00:00:00 2001 From: Minho Date: Thu, 4 May 2017 10:35:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/command.go | 14 +++----------- main.go | 10 +++++++++- models/book.go | 1 + 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/commands/command.go b/commands/command.go index 2ef7b8b4..3bfd70bf 100644 --- a/commands/command.go +++ b/commands/command.go @@ -52,19 +52,9 @@ func RegisterModel() { } +//初始化数据 func Initialization() { - //o := orm.NewOrm() - //o.Raw("alter table "+models.NewMember().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec() - //o.Raw("alter table "+models.NewBook().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec() - //o.Raw("alter table "+models.NewRelationship().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec() - //o.Raw("alter table "+models.NewComment().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec() - //o.Raw("alter table " +models.NewOption().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec() - //o.Raw("alter table "+models.NewDocument().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec() - //o.Raw("alter table "+models.NewAttachment().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec() - //o.Raw("alter table "+models.NewLogger().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec() - //o.Raw("alter table "+models.NewCommentVote().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec() - options := []models.Option { { OptionName: "ENABLED_CAPTCHA", OptionValue: "false", OptionTitle:"是否启用验证码"}, { OptionName: "ENABLED_REGISTER",OptionValue:"false",OptionTitle:"是否启用注册"}, @@ -122,6 +112,8 @@ func RegisterLogger() { logs.Async() if _,err := os.Stat("logs/log.log"); os.IsNotExist(err) { + os.MkdirAll("./logs",0777) + if f,err := os.Create("logs/log.log");err == nil { f.Close() beego.SetLogger("file",`{"filename":"logs/log.log"}`) diff --git a/main.go b/main.go index c36996e5..b35273c1 100644 --- a/main.go +++ b/main.go @@ -13,8 +13,16 @@ import ( "github.com/lifei6671/godoc/controllers" ) +var ( + VERSION string + BUILD_TIME string + GO_VERSION string +) + func main() { + fmt.Printf("MinDoc version%s\n%s\n%s\nstart directory%s\n", VERSION, BUILD_TIME, GO_VERSION,os.Args[0]) + commands.RegisterDataBase() commands.RegisterModel() commands.RegisterLogger() @@ -23,7 +31,7 @@ func main() { beego.SetStaticPath("uploads","uploads") - fmt.Println(os.Args[0]) + beego.ErrorController(&controllers.ErrorController{}) beego.Run() diff --git a/models/book.go b/models/book.go index 2c3b6440..e9682a26 100644 --- a/models/book.go +++ b/models/book.go @@ -89,6 +89,7 @@ func (m *Book) Insert() error { return err } o.Commit() + return nil } o.Rollback() return err