From bfd73b32452ee8c86438f18df1f0f6c533e1e7eb Mon Sep 17 00:00:00 2001 From: dengbiao Date: Wed, 21 Aug 2024 16:20:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=A4=9A=E4=BD=99=E7=9A=84?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/db_sys_cfg.go | 50 -------------------------------------- src/super/model/sys_cfg.go | 7 ++++++ 2 files changed, 7 insertions(+), 50 deletions(-) delete mode 100644 src/db_sys_cfg.go create mode 100644 src/super/model/sys_cfg.go diff --git a/src/db_sys_cfg.go b/src/db_sys_cfg.go deleted file mode 100644 index f6c3099..0000000 --- a/src/db_sys_cfg.go +++ /dev/null @@ -1,50 +0,0 @@ -package db - -import ( - "code.fnuoos.com/zhimeng/model.git/src/model" - "xorm.io/xorm" -) - -// 系统配置get -func SysCfgGetAll(Db *xorm.Engine) (*[]model.SysCfg, error) { - var cfgList []model.SysCfg - if err := Db.Cols("k,v,memo").Find(&cfgList); err != nil { - return nil, err - } - return &cfgList, nil -} - -// 获取一条记录 -func SysCfgGetOne(Db *xorm.Engine, key string) (*model.SysCfg, error) { - var cfgList model.SysCfg - if has, err := Db.Where("`k`=?", key).Get(&cfgList); err != nil || has == false { - return nil, err - } - return &cfgList, nil -} - -// 返回最后插入id -func SysCfgInsert(Db *xorm.Engine, key, val, memo string) bool { - cfg := model.SysCfg{K: key, V: val, Memo: memo} - _, err := Db.InsertOne(&cfg) - if err != nil { - return false - } - return true -} - -func SysCfgUpdate(Db *xorm.Engine, key, val, memo string) bool { - cfg := model.SysCfg{K: key, V: val, Memo: memo} - _, err := Db.Where("`key`=?", key).Cols("val,memo").Update(&cfg) - if err != nil { - return false - } - return true -} -func SysCfgGetWithDb(eg *xorm.Engine, masterId string, HKey string) string { - cfg, err := SysCfgGetOne(eg, HKey) - if err != nil || cfg == nil { - return "" - } - return cfg.V -} diff --git a/src/super/model/sys_cfg.go b/src/super/model/sys_cfg.go new file mode 100644 index 0000000..5508c9a --- /dev/null +++ b/src/super/model/sys_cfg.go @@ -0,0 +1,7 @@ +package model + +type SysCfg struct { + K string `json:"k" xorm:"not null pk comment('键') VARCHAR(127)"` + V string `json:"v" xorm:"comment('值') TEXT"` + Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"` +}