model

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init added in v1.1.0

func Init()

Types

type DataClient added in v1.1.0

type DataClient struct {
	Setting SettingService
	Text    TextService
	// contains filtered or unexported fields
}
var Client *DataClient

func NewDataClient added in v1.1.0

func NewDataClient(db *gorm.DB, settingService SettingService, textService TextService) *DataClient

type Setting added in v1.1.0

type Setting struct {
	gorm.Model
	Name string      `gorm:"not null;uniqueIndex"`
	Type SettingType `gorm:"not null;index"`
	Val  string      `gorm:"not null"`
}

type SettingService added in v1.1.0

type SettingService interface {
	Get(name string, settingType SettingType) (string, error)
	Set(name string, settingType SettingType, val string) error
	Delete(name string, settingType SettingType) error
	List() ([]Setting, error)
	ListType(settingType SettingType) ([]Setting, error)
}

func NewSettingService added in v1.1.0

func NewSettingService(db *gorm.DB) SettingService

type SettingServiceImpl added in v1.1.0

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

func (*SettingServiceImpl) Delete added in v1.1.0

func (s *SettingServiceImpl) Delete(name string, settingType SettingType) error

func (*SettingServiceImpl) Get added in v1.1.0

func (s *SettingServiceImpl) Get(name string, settingType SettingType) (string, error)

func (*SettingServiceImpl) List added in v1.1.0

func (s *SettingServiceImpl) List() ([]Setting, error)

func (*SettingServiceImpl) ListType added in v1.1.0

func (s *SettingServiceImpl) ListType(settingType SettingType) ([]Setting, error)

func (*SettingServiceImpl) Set added in v1.1.0

func (s *SettingServiceImpl) Set(name string, settingType SettingType, val string) error

type SettingType added in v1.1.0

type SettingType string
const (
	SettingTypeSystem SettingType = "system"
)

type Text added in v1.1.0

type Text struct {
	gorm.Model
	Namespace string  `gorm:"not null;index"`
	Speaker   string  `gorm:"not null;index"`
	Text      string  `gorm:"not null;size:512"`
	Context   *string `gorm:"size:512"`
}

type TextService added in v1.1.0

type TextService interface {
	Get(text Text) (*Text, error)
	List(text Text) ([]Text, error)
	GetTextByNamespace(namespace string) ([]Text, error)
	GetTextBySpeaker(speaker string) ([]Text, error)
	ListAll() ([]Text, error)
	CreateText(text Text) (*Text, error)
	UpdateText(text Text) (*Text, error)
	DeleteText(id uint) error
	Count() int64
	RandomRecord(rule Text) (*Text, error)
	Exists(text Text) bool
}

func NewTextService added in v1.1.0

func NewTextService(db *gorm.DB) TextService

type TextServiceImpl added in v1.1.0

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

func (TextServiceImpl) Count added in v1.1.0

func (t TextServiceImpl) Count() int64

func (TextServiceImpl) CreateText added in v1.1.0

func (t TextServiceImpl) CreateText(text Text) (*Text, error)

func (TextServiceImpl) DeleteText added in v1.1.0

func (t TextServiceImpl) DeleteText(id uint) error

func (TextServiceImpl) Exists added in v1.1.0

func (t TextServiceImpl) Exists(text Text) bool

func (TextServiceImpl) Get added in v1.1.0

func (t TextServiceImpl) Get(text Text) (*Text, error)

func (TextServiceImpl) GetTextByNamespace added in v1.1.0

func (t TextServiceImpl) GetTextByNamespace(namespace string) ([]Text, error)

func (TextServiceImpl) GetTextBySpeaker added in v1.1.0

func (t TextServiceImpl) GetTextBySpeaker(speaker string) ([]Text, error)

func (TextServiceImpl) List added in v1.1.0

func (t TextServiceImpl) List(text Text) ([]Text, error)

func (TextServiceImpl) ListAll added in v1.1.0

func (t TextServiceImpl) ListAll() ([]Text, error)

func (TextServiceImpl) RandomRecord added in v1.1.0

func (t TextServiceImpl) RandomRecord(rule Text) (*Text, error)

func (TextServiceImpl) UpdateText added in v1.1.0

func (t TextServiceImpl) UpdateText(text Text) (*Text, error)

Jump to

Keyboard shortcuts

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