mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-04-05 20:17:53 +08:00
修复MySQL脚本错误
This commit is contained in:
parent
c9e5fe6fbf
commit
b8088bd488
@ -8,7 +8,7 @@ environment:
|
||||
- tbs_arch: "x86"
|
||||
tbs_tools: "mingw"
|
||||
tbs_static_runtime: 1
|
||||
GOARCH: 386
|
||||
GOARCH: i386
|
||||
|
||||
- tbs_arch: "x64"
|
||||
tbs_tools: "mingw"
|
||||
@ -37,7 +37,7 @@ build_script:
|
||||
- if [%tbs_tools%]==[mingw] if [%tbs_arch%]==[x86] SET PATH=C:\mingw32\bin;%PATH%
|
||||
- if [%tbs_tools%]==[mingw] if [%tbs_arch%]==[x64] SET PATH=C:\mingw64\bin;%PATH%
|
||||
- set CGO_ENABLED=1
|
||||
- go build -v -o "godoc_windows_%GOARCH%.exe" -ldflags="-w -X github.com/lifei6671/godoc/conf.VERSION=%APPVEYOR_REPO_TAG_NAME% -X 'github.com/lifei6671/godoc/conf.BUILD_TIME=`date`' -X 'conf.GO_VERSION=`github.com/lifei6671/godoc/go version`'"
|
||||
- go build -v -o "godoc_windows_%GOARCH%.exe" -ldflags="-H windowsgui -w -X github.com/lifei6671/godoc/conf.VERSION=%APPVEYOR_REPO_TAG_NAME% -X 'github.com/lifei6671/godoc/conf.BUILD_TIME=`date`' -X 'conf.GO_VERSION=`github.com/lifei6671/godoc/go version`'"
|
||||
- 7z a -t7z -r godoc_windows_%GOARCH%.7z conf/*.conf* static/* godoc_windows_%GOARCH%.exe views/* database/* logs/* uploads/*
|
||||
test_script:
|
||||
- godoc_windows_%GOARCH%.exe version
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/lifei6671/godoc/conf"
|
||||
"github.com/lifei6671/godoc/models"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
//系统安装.
|
||||
@ -28,7 +27,7 @@ func Install() {
|
||||
}
|
||||
}
|
||||
|
||||
func Version() {
|
||||
func Version() {
|
||||
if len(os.Args) >= 2 && os.Args[1] == "version" {
|
||||
fmt.Println(conf.VERSION)
|
||||
os.Exit(0)
|
||||
@ -38,21 +37,12 @@ func Version() {
|
||||
//初始化数据
|
||||
func initialization() {
|
||||
|
||||
o := orm.NewOrm()
|
||||
|
||||
b,err := ioutil.ReadFile("./database/data.sql")
|
||||
err := models.NewOption().Init()
|
||||
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
sql := string(b)
|
||||
|
||||
_,err = o.Raw(sql).Exec()
|
||||
if err != nil {
|
||||
panic("Error => " + err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
member, err := models.NewMember().FindByFieldFirst("account", "admin")
|
||||
if err == orm.ErrNoRows {
|
||||
|
@ -67,7 +67,9 @@ func (p *Option) InsertOrUpdate() error {
|
||||
o := orm.NewOrm()
|
||||
|
||||
var err error
|
||||
if p.OptionId > 0 {
|
||||
|
||||
|
||||
if p.OptionId > 0 || o.QueryTable(p.TableNameWithPrefix()).Filter("option_name",p.OptionName).Exist() {
|
||||
_,err = o.Update(p)
|
||||
}else{
|
||||
_,err = o.Insert(p)
|
||||
@ -93,4 +95,57 @@ func (p *Option) All() ([]*Option,error) {
|
||||
return options,err
|
||||
}
|
||||
return options,nil
|
||||
}
|
||||
|
||||
func (m *Option) Init() error {
|
||||
|
||||
o := orm.NewOrm()
|
||||
|
||||
if !o.QueryTable(m.TableNameWithPrefix()).Filter("option_name","ENABLED_REGISTER").Exist() {
|
||||
option := NewOption()
|
||||
option.OptionValue = "false"
|
||||
option.OptionName = "ENABLED_REGISTER"
|
||||
option.OptionTitle = "是否启用注册"
|
||||
if _,err := o.Insert(option);err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if !o.QueryTable(m.TableNameWithPrefix()).Filter("option_name","ENABLE_DOCUMENT_HISTORY").Exist() {
|
||||
option := NewOption()
|
||||
option.OptionValue = "true"
|
||||
option.OptionName = "ENABLE_DOCUMENT_HISTORY"
|
||||
option.OptionTitle = "是否启用文档历史"
|
||||
if _,err := o.Insert(option);err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if !o.QueryTable(m.TableNameWithPrefix()).Filter("option_name","ENABLED_CAPTCHA").Exist() {
|
||||
option := NewOption()
|
||||
option.OptionValue = "true"
|
||||
option.OptionName = "ENABLED_CAPTCHA"
|
||||
option.OptionTitle = "是否启用验证码"
|
||||
if _,err := o.Insert(option);err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if !o.QueryTable(m.TableNameWithPrefix()).Filter("option_name","ENABLE_ANONYMOUS").Exist() {
|
||||
option := NewOption()
|
||||
option.OptionValue = "false"
|
||||
option.OptionName = "ENABLE_ANONYMOUS"
|
||||
option.OptionTitle = "启用匿名访问"
|
||||
if _,err := o.Insert(option);err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if !o.QueryTable(m.TableNameWithPrefix()).Filter("option_name","SITE_NAME").Exist() {
|
||||
option := NewOption()
|
||||
option.OptionValue = "MinDoc"
|
||||
option.OptionName = "SITE_NAME"
|
||||
option.OptionTitle = "站点名称"
|
||||
if _,err := o.Insert(option);err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user