From 62a4883e695ba04c06d275f09638c48f55f13fe3 Mon Sep 17 00:00:00 2001 From: Minho Date: Wed, 3 May 2017 15:08:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E5=88=9D=E5=A7=8B=E5=8C=96=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=A4=B1=E8=B4=A5=E6=97=B6=E4=B8=8D=E5=9C=A8=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/command.go | 16 +++++++++++++--- models/member.go | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/commands/command.go b/commands/command.go index 981324b8..4cb63fad 100644 --- a/commands/command.go +++ b/commands/command.go @@ -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 注册日志 diff --git a/models/member.go b/models/member.go index 26a598a0..41dc6001 100644 --- a/models/member.go +++ b/models/member.go @@ -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 {