huangjiajun 4 ay önce
ebeveyn
işleme
05db9d108e
2 değiştirilmiş dosya ile 76 ekleme ve 0 silme
  1. +10
    -0
      src/dao/sys_cfg_dao.go
  2. +66
    -0
      src/implement/sys_cfg_implement.go

+ 10
- 0
src/dao/sys_cfg_dao.go Dosyayı Görüntüle

@@ -0,0 +1,10 @@
package dao

import "code.fnuoos.com/zhimeng/model.git/src/model"

type SysCfgDao interface {
GetSysCfg(keys string) (m *model.SysCfg, err error)
GetSysCfgStr(keys string) (str string)
FindSysCfg(keys ...string) (m *[]model.SysCfg, err error)
FindSysCfgStr(keys ...string) (str map[string]string)
}

+ 66
- 0
src/implement/sys_cfg_implement.go Dosyayı Görüntüle

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

Yükleniyor…
İptal
Kaydet