Browse Source

cfg

master
huangjiajun 3 months ago
parent
commit
43909931dc
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      app/db/implement/sys_cfg_implement.go

+ 5
- 5
app/db/implement/sys_cfg_implement.go View File

@@ -1,4 +1,4 @@
package implement
package implement


import ( import (
"applet/app/db/dao" "applet/app/db/dao"
@@ -24,7 +24,7 @@ type SysCfgDb struct {


func (s SysCfgDb) SysCfgGetAll() (*[]model.SysCfg, error) { func (s SysCfgDb) SysCfgGetAll() (*[]model.SysCfg, error) {
var cfgList []model.SysCfg var cfgList []model.SysCfg
if err := s.Db.Cols("key,val,memo").Find(&cfgList); err != nil {
if err := s.Db.Cols("k,v,memo").Find(&cfgList); err != nil {
return nil, logx.Error(err) return nil, logx.Error(err)
} }
return &cfgList, nil return &cfgList, nil
@@ -32,7 +32,7 @@ func (s SysCfgDb) SysCfgGetAll() (*[]model.SysCfg, error) {


func (s SysCfgDb) SysCfgGetOneNoDataNoErr(key string) (*model.SysCfg, error) { func (s SysCfgDb) SysCfgGetOneNoDataNoErr(key string) (*model.SysCfg, error) {
var cfgList model.SysCfg var cfgList model.SysCfg
has, err := s.Db.Where("`key`=?", key).Get(&cfgList)
has, err := s.Db.Where("`k`=?", key).Get(&cfgList)
if err != nil { if err != nil {
return nil, logx.Error(err) return nil, logx.Error(err)
} }
@@ -44,7 +44,7 @@ func (s SysCfgDb) SysCfgGetOneNoDataNoErr(key string) (*model.SysCfg, error) {


func (s SysCfgDb) SysCfgGetOne(key string) (*model.SysCfg, error) { func (s SysCfgDb) SysCfgGetOne(key string) (*model.SysCfg, error) {
var cfgList model.SysCfg var cfgList model.SysCfg
if has, err := s.Db.Where("`key`=?", key).Get(&cfgList); err != nil || has == false {
if has, err := s.Db.Where("`k`=?", key).Get(&cfgList); err != nil || has == false {
return nil, logx.Error(err) return nil, logx.Error(err)
} }
return &cfgList, nil return &cfgList, nil
@@ -62,7 +62,7 @@ func (s SysCfgDb) SysCfgInsert(key, val, memo string) bool {


func (s SysCfgDb) SysCfgUpdate(key, val string) bool { func (s SysCfgDb) SysCfgUpdate(key, val string) bool {
cfg := model.SysCfg{K: key, V: val} cfg := model.SysCfg{K: key, V: val}
_, err := s.Db.Where("`key`=?", key).Cols("val").Update(&cfg)
_, err := s.Db.Where("`k`=?", key).Cols("v").Update(&cfg)
if err != nil { if err != nil {
logx.Error(err) logx.Error(err)
return false return false


Loading…
Cancel
Save