Browse Source

去除多余的文件

master
dengbiao 4 months ago
parent
commit
bfd73b3245
2 changed files with 7 additions and 50 deletions
  1. +0
    -50
      src/db_sys_cfg.go
  2. +7
    -0
      src/super/model/sys_cfg.go

+ 0
- 50
src/db_sys_cfg.go View File

@@ -1,50 +0,0 @@
package db

import (
"code.fnuoos.com/zhimeng/model.git/src/model"
"xorm.io/xorm"
)

// 系统配置get
func SysCfgGetAll(Db *xorm.Engine) (*[]model.SysCfg, error) {
var cfgList []model.SysCfg
if err := Db.Cols("k,v,memo").Find(&cfgList); err != nil {
return nil, err
}
return &cfgList, nil
}

// 获取一条记录
func SysCfgGetOne(Db *xorm.Engine, key string) (*model.SysCfg, error) {
var cfgList model.SysCfg
if has, err := Db.Where("`k`=?", key).Get(&cfgList); err != nil || has == false {
return nil, err
}
return &cfgList, nil
}

// 返回最后插入id
func SysCfgInsert(Db *xorm.Engine, key, val, memo string) bool {
cfg := model.SysCfg{K: key, V: val, Memo: memo}
_, err := Db.InsertOne(&cfg)
if err != nil {
return false
}
return true
}

func SysCfgUpdate(Db *xorm.Engine, key, val, memo string) bool {
cfg := model.SysCfg{K: key, V: val, Memo: memo}
_, err := Db.Where("`key`=?", key).Cols("val,memo").Update(&cfg)
if err != nil {
return false
}
return true
}
func SysCfgGetWithDb(eg *xorm.Engine, masterId string, HKey string) string {
cfg, err := SysCfgGetOne(eg, HKey)
if err != nil || cfg == nil {
return ""
}
return cfg.V
}

+ 7
- 0
src/super/model/sys_cfg.go View File

@@ -0,0 +1,7 @@
package model

type SysCfg struct {
K string `json:"k" xorm:"not null pk comment('键') VARCHAR(127)"`
V string `json:"v" xorm:"comment('值') TEXT"`
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"`
}

Loading…
Cancel
Save