1234567891011121314151617181920212223242526272829303132 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // SysConfig 表示 sys_config 表的结构体
- type SysConfig struct {
- ID int `gorm:"primaryKey;autoIncrement" json:"id"`
- ConfigID int `gorm:"column:config_id" json:"config_id"`
- ConfigName string `gorm:"column:config_name" json:"config_name"`
- ConfigType string `gorm:"column:config_type;type:enum('string','int','byte')" json:"config_type"`
- Deleted int `gorm:"column:deleted" json:"deleted"`
- StrValue string `gorm:"column:str_value" json:"str_value"`
- IntValue int `gorm:"column:int_value" json:"int_value"`
- ByteValue string `gorm:"column:byte_value" json:"byte_value"`
- CreatedTime time.Time `gorm:"column:created_time" json:"created_time"`
- UpdatedTime time.Time `gorm:"column:updated_time;default:CURRENT_TIMESTAMP;autoUpdateTime" json:"updated_time"`
- }
- func (SysConfig) TableName() string {
- return "sys_config"
- }
- func GetConfig(configId int) (config SysConfig, err error) {
- o := orm.NewOrm()
- sql := `select * from sys_config where config_id = ? and deleted=0`
- err = o.Raw(sql, configId).QueryRow(&config)
- return
- }
|