|
|
@@ -0,0 +1,66 @@ |
|
|
|
package implement |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.fnuoos.com/zhimeng/model.git/src/dao" |
|
|
|
"code.fnuoos.com/zhimeng/model.git/src/model" |
|
|
|
zhios_order_relate_logx "code.fnuoos.com/zhimeng/model.git/utils/logx" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
func NewSysCfgDb(engine *xorm.Engine) dao.SysCfgDao { |
|
|
|
return &SysCfgDb{Db: engine} |
|
|
|
} |
|
|
|
|
|
|
|
type SysCfgDb struct { |
|
|
|
Db *xorm.Engine |
|
|
|
} |
|
|
|
|
|
|
|
func (s SysCfgDb) GetSysCfg(keys string) (sysCfg *model.SysCfg, err error) { |
|
|
|
sysCfg = new(model.SysCfg) |
|
|
|
has, err := s.Db.Where("`k` =?", keys).Get(sysCfg) |
|
|
|
if err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
if has == false { |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
return sysCfg, nil |
|
|
|
} |
|
|
|
func (s SysCfgDb) GetSysCfgStr(keys string) (str string) { |
|
|
|
sysCfg := new(model.SysCfg) |
|
|
|
has, err := s.Db.Where("`k` =?", keys).Get(sysCfg) |
|
|
|
if err != nil { |
|
|
|
return "" |
|
|
|
} |
|
|
|
if has == false { |
|
|
|
return "" |
|
|
|
} |
|
|
|
return sysCfg.V |
|
|
|
} |
|
|
|
|
|
|
|
func (s SysCfgDb) FindSysCfg(keys ...string) (sysCfg *[]model.SysCfg, err error) { |
|
|
|
sysCfg = new([]model.SysCfg) |
|
|
|
has, err := s.Db.In("`k` ", keys).Get(sysCfg) |
|
|
|
if err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
if has == false { |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
return sysCfg, nil |
|
|
|
} |
|
|
|
func (s SysCfgDb) FindSysCfgStr(keys ...string) (str map[string]string) { |
|
|
|
str = make(map[string]string) |
|
|
|
for _, v := range keys { |
|
|
|
str[v] = "" |
|
|
|
} |
|
|
|
var sysCfg []model.SysCfg |
|
|
|
err := s.Db.In("`k`", keys).Find(&sysCfg) |
|
|
|
if err != nil { |
|
|
|
return str |
|
|
|
} |
|
|
|
for _, v := range sysCfg { |
|
|
|
str[v.K] = v.V |
|
|
|
} |
|
|
|
return str |
|
|
|
} |