|
|
@@ -19,21 +19,21 @@ func (masterListCfgDb *MasterListCfgDb) Set() { // set方法 |
|
|
|
|
|
|
|
func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetAll() (*[]model.MasterListCfg, error) { |
|
|
|
var cfgList []model.MasterListCfg |
|
|
|
if err := Db.Cols("k,v,memo").Find(&cfgList); err != nil { |
|
|
|
if err := masterListCfgDb.Db.Cols("k,v,memo").Find(&cfgList); err != nil { |
|
|
|
return nil, logx.Error(err) |
|
|
|
} |
|
|
|
return &cfgList, nil |
|
|
|
} |
|
|
|
func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetCron() (*[]model.MasterListCfg, error) { |
|
|
|
var cfgList []model.MasterListCfg |
|
|
|
if err := Db.Where("`k` LIKE 'zhimeng_cron\\_%' AND v != ''").Cols("k,v,memo").Find(&cfgList); err != nil { |
|
|
|
if err := masterListCfgDb.Db.Where("`k` LIKE 'zhimeng_cron\\_%' AND v != ''").Cols("k,v,memo").Find(&cfgList); err != nil { |
|
|
|
return nil, logx.Error(err) |
|
|
|
} |
|
|
|
return &cfgList, nil |
|
|
|
} |
|
|
|
func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneNoDataNoErr(key string) (*model.MasterListCfg, error) { |
|
|
|
var cfgList model.MasterListCfg |
|
|
|
has, err := Db.Where("`k`=?", key).Get(&cfgList) |
|
|
|
has, err := masterListCfgDb.Db.Where("`k`=?", key).Get(&cfgList) |
|
|
|
if err != nil { |
|
|
|
return nil, logx.Error(err) |
|
|
|
} |
|
|
@@ -45,14 +45,14 @@ func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneNoDataNoErr(key strin |
|
|
|
|
|
|
|
func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOne(uid, key string) (*model.MasterListCfg, error) { |
|
|
|
var cfgList model.MasterListCfg |
|
|
|
if has, err := Db.Where("`k`=? and uid=?", key, uid).Get(&cfgList); err != nil || has == false { |
|
|
|
if has, err := masterListCfgDb.Db.Where("`k`=? and uid=?", key, uid).Get(&cfgList); err != nil || has == false { |
|
|
|
return nil, logx.Error(err) |
|
|
|
} |
|
|
|
return &cfgList, nil |
|
|
|
} |
|
|
|
func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneData(uid, key string) string { |
|
|
|
var cfgList model.MasterListCfg |
|
|
|
if has, err := Db.Where("`k`=? and uid=?", key, uid).Get(&cfgList); err != nil || has == false { |
|
|
|
if has, err := masterListCfgDb.Db.Where("`k`=? and uid=?", key, uid).Get(&cfgList); err != nil || has == false { |
|
|
|
return "" |
|
|
|
} |
|
|
|
return cfgList.V |
|
|
@@ -60,7 +60,7 @@ func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneData(uid, key string) |
|
|
|
|
|
|
|
func (masterListCfgDb *MasterListCfgDb) MasterListCfgInsert(uid, key, val, memo string) bool { |
|
|
|
cfg := model.MasterListCfg{Uid: uid, K: key, V: val, Memo: memo} |
|
|
|
_, err := Db.InsertOne(&cfg) |
|
|
|
_, err := masterListCfgDb.Db.InsertOne(&cfg) |
|
|
|
if err != nil { |
|
|
|
logx.Error(err) |
|
|
|
return false |
|
|
@@ -70,7 +70,7 @@ func (masterListCfgDb *MasterListCfgDb) MasterListCfgInsert(uid, key, val, memo |
|
|
|
|
|
|
|
func (masterListCfgDb *MasterListCfgDb) MasterListCfgUpdate(uid, key, val string) bool { |
|
|
|
cfg := model.MasterListCfg{K: key, V: val} |
|
|
|
_, err := Db.Where("`k`=? and uid=?", key, uid).Cols("val").Update(&cfg) |
|
|
|
_, err := masterListCfgDb.Db.Where("`k`=? and uid=?", key, uid).Cols("val").Update(&cfg) |
|
|
|
if err != nil { |
|
|
|
logx.Error(err) |
|
|
|
return false |
|
|
|