62 lines
2.9 KiB
Go
62 lines
2.9 KiB
Go
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
|
||
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
|
||
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
|
||
|
||
package models
|
||
|
||
import (
|
||
"context"
|
||
"time"
|
||
|
||
"go.ipao.vip/gen"
|
||
"go.ipao.vip/gen/types"
|
||
)
|
||
|
||
const TableNameSystemConfig = "system_configs"
|
||
|
||
// SystemConfig mapped from table <system_configs>
|
||
type SystemConfig struct {
|
||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true;comment:主键ID。" json:"id"` // 主键ID。
|
||
ConfigKey string `gorm:"column:config_key;type:character varying(64);not null;comment:配置项Key;用途:按Key读取/更新;约束:唯一。" json:"config_key"` // 配置项Key;用途:按Key读取/更新;约束:唯一。
|
||
Value types.JSON `gorm:"column:value;type:jsonb;not null;default:{};comment:配置值(JSON);用途:存储任意结构化配置;默认 {}。" json:"value"` // 配置值(JSON);用途:存储任意结构化配置;默认 {}。
|
||
Description string `gorm:"column:description;type:character varying(255);not null;comment:配置说明;用途:给运营/技术理解用途。" json:"description"` // 配置说明;用途:给运营/技术理解用途。
|
||
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now();comment:创建时间;用途:审计与追溯。" json:"created_at"` // 创建时间;用途:审计与追溯。
|
||
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;not null;default:now();comment:更新时间;用途:变更记录。" json:"updated_at"` // 更新时间;用途:变更记录。
|
||
}
|
||
|
||
// Quick operations without importing query package
|
||
// Update applies changed fields to the database using the default DB.
|
||
func (m *SystemConfig) Update(ctx context.Context) (gen.ResultInfo, error) {
|
||
return Q.SystemConfig.WithContext(ctx).Updates(m)
|
||
}
|
||
|
||
// Save upserts the model using the default DB.
|
||
func (m *SystemConfig) Save(ctx context.Context) error {
|
||
return Q.SystemConfig.WithContext(ctx).Save(m)
|
||
}
|
||
|
||
// Create inserts the model using the default DB.
|
||
func (m *SystemConfig) Create(ctx context.Context) error {
|
||
return Q.SystemConfig.WithContext(ctx).Create(m)
|
||
}
|
||
|
||
// Delete removes the row represented by the model using the default DB.
|
||
func (m *SystemConfig) Delete(ctx context.Context) (gen.ResultInfo, error) {
|
||
return Q.SystemConfig.WithContext(ctx).Delete(m)
|
||
}
|
||
|
||
// ForceDelete permanently deletes the row (ignores soft delete) using the default DB.
|
||
func (m *SystemConfig) ForceDelete(ctx context.Context) (gen.ResultInfo, error) {
|
||
return Q.SystemConfig.WithContext(ctx).Unscoped().Delete(m)
|
||
}
|
||
|
||
// Reload reloads the model from database by its primary key and overwrites current fields.
|
||
func (m *SystemConfig) Reload(ctx context.Context) error {
|
||
fresh, err := Q.SystemConfig.WithContext(ctx).GetByID(m.ID)
|
||
if err != nil {
|
||
return err
|
||
}
|
||
*m = *fresh
|
||
return nil
|
||
}
|