Documentation ¶
Overview ¶
* @Author: Wangjun * @Date: 2021-05-15 22:43:19 * @LastEditTime: 2022-04-11 09:22:49 * @LastEditors: Wangjun * @Description: * @FilePath: \golib\dbutils\dbutils.go * hnxr
Index ¶
- Constants
- func ClearTable(parent string) error
- func Count(parent string) (n int64, err error)
- func Map(parent string) (m map[string]string, err error)
- func ParseBool(val interface{}) (value bool, err error)
- func Save(db *gorm.DB, record interface{}) (err error)
- func SetDatabase(db *gorm.DB, confs ...*AppConf)
- func Sync(table []*AppConf, parent string) (err error)
- type AppConf
- type Conf
- func (conf *Conf) Bool(key string) (bool, error)
- func (conf *Conf) DIY(key string) (interface{}, error)
- func (conf *Conf) DefaultBool(key string, defaultVal bool) bool
- func (conf *Conf) DefaultFloat(key string, defaultVal float64) float64
- func (conf *Conf) DefaultInt(key string, defaultVal int) int
- func (conf *Conf) DefaultInt64(key string, defaultVal int64) int64
- func (conf *Conf) DefaultString(key string, defaultVal string) string
- func (conf *Conf) DefaultStrings(key string, defaultVal []string) []string
- func (conf *Conf) Float(key string) (float64, error)
- func (conf *Conf) GetSection(section string) (map[string]string, error)
- func (conf *Conf) Int(key string) (int, error)
- func (conf *Conf) Int64(key string) (int64, error)
- func (conf *Conf) Parse(key string) (c config.Configer, err error)
- func (conf *Conf) ParseData(data []byte) (config.Configer, error)
- func (conf *Conf) SaveConfigFile(filename string) error
- func (conf *Conf) Set(key, val string) (err error)
- func (conf *Conf) String(key string) (s string)
- func (conf *Conf) Strings(key string) (ss []string)
- type Time
Constants ¶
const SysAppConfFlag = "app_system_config"
SysAppConfFlag 系统标志
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AppConf ¶
type AppConf struct { UpdatedAt Time ID uint `gorm:"primary_key"` Parent string `gorm:"type:varchar(255)"` Scope string `gorm:"type:varchar(255)"` //测点类型, 是否是高级 Name string `gorm:"type:varchar(255)"` //页面显示的数据 Key string `gorm:"type:varchar(255)"` //显示数据对应的KEY Value string `gorm:"type:varchar(255)"` //需要配置的值 Desc string `gorm:"type:varchar(255);column:ed"` //描述信息 Type string `gorm:"type:varchar(255)"` //填充模式 Data string `gorm:"type:varchar(255)"` //字段候选值 Rows []string `gorm:"-"` //字段候选值,供前台使用 }
AppConf 定义配置表结构
func MakeDetails ¶
MakeDetails 生成行
func (*AppConf) DeleteByParent ¶
DeleteByParent 删除指定的数据
type Conf ¶
Conf 读取配置文件
func NewFromMap ¶
func (*Conf) DefaultBool ¶
DefaultBool int64 value by key, if value is not exist, return defaultValue
func (*Conf) DefaultFloat ¶
DefaultFloat float64 value by key, if value is not exist, return defaultValue
func (*Conf) DefaultInt ¶
DefaultInt Get int value by key, if value is not exist, return defaultValue
func (*Conf) DefaultInt64 ¶
DefaultInt64 int64 value by key, if value is not exist, return defaultValue
func (*Conf) DefaultString ¶
DefaultString Get value by key, if value is not exist, return defaultValue
func (*Conf) DefaultStrings ¶
DefaultStrings Not implementation
func (*Conf) GetSection ¶
GetSection Not implementation
func (*Conf) SaveConfigFile ¶
SaveConfigFile Save config
type Time ¶
Time 时间自动格式化
func (Time) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface. The time is a quoted string in RFC 3339 format, with sub-second precision added if present.