|
- package offical
-
- import (
- "applet/app/db"
- officialModel "applet/app/db/model"
- "applet/app/utils/logx"
- )
-
- func SysCfgByKey(key string) *officialModel.SysCfg {
- var data officialModel.SysCfg
- get, err := db.Db.Where("k=?", key).Get(&data)
- if get == false || err != nil {
- return nil
- }
- return &data
- }
- func SysCfgByKeyStr(key string) string {
- var data officialModel.SysCfg
- get, err := db.Db.Where("k=?", key).Get(&data)
- if get == false || err != nil {
- return ""
- }
- return data.V
- }
- func DbsSysCfgInserts(key, val string) bool {
- cfg := officialModel.SysCfg{K: key, V: val}
- _, err := db.Db.InsertOne(&cfg)
- if err != nil {
- logx.Error(err)
- return false
- }
- return true
- }
- func DbsSysCfgUpdate(key, val string) bool {
- cfg := officialModel.SysCfg{K: key, V: val}
- _, err := db.Db.Where("`k`=?", key).Cols("v").Update(&cfg)
- if err != nil {
- logx.Error(err)
- return false
- }
- return true
- }
|