123456789101112131415161718192021222324252627282930313233343536 |
- package sys
- import (
- "eta/eta_mini_ht_api/models"
- "gorm.io/gorm"
- "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 (sys *SysConfig) BeforeCreate(db *gorm.DB) {
- sys.CreatedTime = time.Now()
- }
- func GetConfig(configId int) (config SysConfig, err error) {
- db := models.Main()
- err = db.Where("config_id = ? and deleted=0", configId).First(&config).Error
- return
- }
|