2025-06-12 10:20:26 +08:00

33 lines
1.0 KiB
Go

package system
import (
"context"
"time"
"management/internal/erpserver/model/dto"
"gorm.io/datatypes"
)
type ConfigRepository interface {
Initialize(ctx context.Context) error
Create(ctx context.Context, obj *Config) error
Update(ctx context.Context, obj *Config) error
Get(ctx context.Context, id int32) (*Config, error)
GetByKey(ctx context.Context, key string) (*Config, error)
GetValueByKey(ctx context.Context, key string) ([]byte, error)
List(ctx context.Context, q dto.SearchDto) ([]*Config, int64, error)
}
type Config struct {
ID int32 `json:"id" gorm:"primaryKey;autoIncrement;not null"`
Key string `json:"key" gorm:"type:varchar(200);not null;uniqueIndex"`
Value datatypes.JSON `json:"value" gorm:"type:jsonb;not null;"`
CreatedAt time.Time `json:"created_at" gorm:"type:timestamptz;not null;default:'now()'"`
UpdatedAt time.Time `json:"updated_at" gorm:"type:timestamptz;not null;default:'0001-01-01 00:00:00+8';"`
}
func (Config) TableName() string {
return "sys_config"
}