package model import ( "context" "time" "github.com/zeromicro/go-zero/core/stores/sqlx" ) // TConfig is one dynamic configuration row. Hot-reloadable audit settings // (MinIO endpoint/keys, log level, archive threshold, HMAC secret) are // stored here and read back on every request by the audit middleware. type TConfig struct { Id int64 `db:"id"` // 主键 ConfigItem string `db:"config_item"` // 配置项 ConfigValue string `db:"config_value"` // 配置值 EditFlag int64 `db:"edit_flag"` // 是否允许编辑,1是不可编辑configItem,2是所有均可编辑 Description string `db:"description"` // 描述 UpdatedBy string `db:"updated_by"` // 最后更新人 UpdatedAt time.Time `db:"updated_at"` // 配置更新时间 } type TConfigModel interface { // FindAll returns every configuration row ordered by id. FindAll(ctx context.Context) ([]TConfig, error) } type customTConfigModel struct { conn sqlx.SqlConn table string } var _ TConfigModel = (*customTConfigModel)(nil) // NewTConfigModel returns the model for the t_config table. func NewTConfigModel(conn sqlx.SqlConn) TConfigModel { return &customTConfigModel{ conn: conn, table: "`t_config`", } } func (m *customTConfigModel) FindAll(ctx context.Context) ([]TConfig, error) { var resp []TConfig query := "select `id`, `config_item`, `config_value`, `edit_flag`, `description`, `updated_by`, `updated_at` from t_config order by `id` asc" if err := m.conn.QueryRowsCtx(ctx, &resp, query); err != nil { return nil, err } return resp, nil }