|
123456789101112131415161718192021222324252627282930313233343536373839404142 |
- 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
- }
|