mirror of https://github.com/mindoc-org/mindoc.git
当初始化数据失败时不在启动程序
parent
d3288afdc9
commit
62a4883e69
|
@ -73,7 +73,10 @@ func Initialization() {
|
|||
}
|
||||
|
||||
|
||||
models.NewOption().InsertMulti(options...)
|
||||
if err := models.NewOption().InsertMulti(options...);err != nil {
|
||||
beego.Error(err)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
member := models.NewMember()
|
||||
member.Account = "admin"
|
||||
|
@ -81,7 +84,10 @@ func Initialization() {
|
|||
member.Password = "123456"
|
||||
member.Role = 0
|
||||
|
||||
member.Add()
|
||||
if err := member.Add();err != nil {
|
||||
beego.Error(err)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
book := models.NewBook()
|
||||
|
||||
|
@ -99,7 +105,11 @@ func Initialization() {
|
|||
book.Cover = conf.GetDefaultCover()
|
||||
book.Editor = "markdown"
|
||||
book.Theme = "default"
|
||||
book.Insert()
|
||||
|
||||
if err := book.Insert(); err != nil {
|
||||
beego.Error(err)
|
||||
os.Exit(2)
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterLogger 注册日志
|
||||
|
|
|
@ -83,7 +83,7 @@ func (m *Member) Add () (error) {
|
|||
if ok,err := regexp.MatchString(conf.RegexpEmail,m.Email); !ok || err != nil || m.Email == "" {
|
||||
return errors.New("邮箱格式不正确")
|
||||
}
|
||||
if l := strings.Count(m.Password,""); l <6 || l > 50{
|
||||
if l := strings.Count(m.Password,""); l <= 6 || l >= 50{
|
||||
return errors.New("密码不能为空且必须在6-50个字符之间")
|
||||
}
|
||||
if c,err := o.QueryTable(m.TableNameWithPrefix()).Filter("email",m.Email).Count(); err == nil || c > 0 {
|
||||
|
|
Loading…
Reference in New Issue