model

package
v0.0.0-...-4b2d302 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSettings = []Setting{
	{Key: "system_version", Type: SettingTypeSystem, Value: env.AppVersion},
}

Functions

func Module

func Module() fx.Option

Types

type Setting

type Setting struct {
	gorm.Model
	Key   string      `gorm:"uniqueIndex;not null"`
	Type  SettingType `gorm:"not null;default:0"`
	Value string      `gorm:"not null;default:''"`
}

type SettingRepository

type SettingRepository interface {
	Find(ctx context.Context, key string) (*Setting, error)
	ListByType(ctx context.Context, settingType SettingType) ([]*Setting, error)
	ListAll(ctx context.Context) ([]*Setting, error)
	Create(ctx context.Context, setting *Setting) error
	Update(ctx context.Context, setting *Setting) error
	Delete(ctx context.Context, setting *Setting) error
}

func NewSettingService

func NewSettingService(db *gorm.DB) SettingRepository

type SettingService

type SettingService struct {
	// contains filtered or unexported fields
}

SettingService implements SettingRepository

func (*SettingService) Create

func (s *SettingService) Create(ctx context.Context, setting *Setting) error

Create implements SettingRepository.Create, create a setting

func (*SettingService) Delete

func (s *SettingService) Delete(ctx context.Context, setting *Setting) error

Delete implements SettingRepository.Delete, delete a setting

func (*SettingService) Find

func (s *SettingService) Find(ctx context.Context, key string) (*Setting, error)

Find implements SettingRepository.Find, find a setting by key

func (*SettingService) ListAll

func (s *SettingService) ListAll(ctx context.Context) ([]*Setting, error)

ListAll implements SettingRepository.ListAll, list all settings

func (*SettingService) ListByType

func (s *SettingService) ListByType(ctx context.Context, t SettingType) ([]*Setting, error)

ListByType implements SettingRepository.ListByType, list settings by type

func (*SettingService) Update

func (s *SettingService) Update(ctx context.Context, setting *Setting) error

Update implements SettingRepository.Update, update a setting

type SettingType

type SettingType int
const (
	SettingTypeSystem SettingType = iota
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL