From 17905c2d2184327ed43a70e97f3e931b5136d4e7 Mon Sep 17 00:00:00 2001 From: hoteas Date: Sun, 13 Mar 2022 05:13:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=86=E6=9E=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/makecode.go | 14 ++++++++------ example/config/config.json | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/code/makecode.go b/code/makecode.go index 1d03fed..1d581e1 100644 --- a/code/makecode.go +++ b/code/makecode.go @@ -68,6 +68,14 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) { for _, v := range ColumnNameType { that.RuleConfig = append(that.RuleConfig, Map{"name": v.Name, "list": v.List, "edit": v.Edit, "info": v.Info, "must": v.Must, "strict": v.Strict, "type": v.Type}) } + if db != nil { + _ = os.MkdirAll(filepath.Dir(config.GetString("rule")), os.ModeDir) + err = ioutil.WriteFile(config.GetString("rule"), []byte(ObjToStr(that.RuleConfig)), os.ModePerm) + if err != nil { + that.Error.SetError(err) + } + } + that.Error.SetError(errors.New("rule配置文件不存在,或者配置出错,使用缺省默认配置")) } @@ -540,12 +548,6 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) { } } - _ = os.MkdirAll(filepath.Dir(config.GetString("rule")), os.ModeDir) - err = ioutil.WriteFile(config.GetString("rule"), []byte(ObjToStr(that.RuleConfig)), os.ModePerm) - if err != nil { - that.Error.SetError(err) - } - //写入配置文件 //err = json.Indent(&configByte, []byte(that.Config.ToJsonString()), "", "\t") _ = os.MkdirAll(filepath.Dir(config.GetString("config")), os.ModeDir) diff --git a/example/config/config.json b/example/config/config.json index 6a6eec4..ad7e303 100644 --- a/example/config/config.json +++ b/example/config/config.json @@ -41,7 +41,7 @@ "5": "数据结果异常" }, "imgPath": "img/2006/01/02/", - "mode": 0, + "mode": 2, "port": "8081", "sessionName": "HOTIME", "smsKey": "b0eb4bf0198b9983cffcb85b69fdf4fa",