repository

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterModels

func RegisterModels(db *gorm.DB) error

Types

type Cassette added in v1.2.0

type Cassette struct {
	gorm.Model
	Id        int                 `gorm:"uniqueIndex"`
	DeviceUID string              `gorm:"index;not null"`
	Device    *Device             `gorm:"foreignkey:DeviceUID"`
	Type      domain.CassetteType `gorm:"index;not null"`
	Size      uint                `gorm:"not null"`
	Capacity  uint                `gorm:"not null"`
}

type Device

type Device struct {
	gorm.Model
	UID       string   `gorm:"uniqueIndex"`
	Active    bool     `gorm:"default:false;not null;"`
	Status    int      `gorm:"default:0;index;not null;"`
	Groups    []*Group `gorm:"many2many:device_groups;"`
	OwnerId   int64
	LastSeen  time.Time
	ExpiresAt time.Time
	Point     string `gorm:"index"`
	Label     string
	Online    bool   `gorm:"default:false;not null;"`
	TokenHash string `gorm:"uniqueIndex"`
}

func NewDevice

func NewDevice(uid string, tokenHash string) *Device

type Group

type Group struct {
	gorm.Model
	ChatID  int64     `gorm:"uniqueIndex"`
	Devices []*Device `gorm:"many2many:device_groups;"`
	Lang    string
}

type Owner

type Owner struct {
	gorm.Model
	UserId  int64     `gorm:"uniqueIndex"`
	Devices []*Device `gorm:"foreignkey:OwnerId;references:ID"`
}

type Repository added in v1.2.0

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

func NewRepository added in v1.2.0

func NewRepository(dbDial gorm.Dialector, automigrate bool) (*Repository, error)

func (*Repository) AssignGroups added in v1.2.0

func (r *Repository) AssignGroups(ctx context.Context, uid string, chatIDs []int64) error

func (*Repository) CreateDevice added in v1.2.0

func (r *Repository) CreateDevice(ctx context.Context, uid, hash string) error

func (*Repository) CreateGroup added in v1.2.0

func (r *Repository) CreateGroup(ctx context.Context, chatID int64) error

func (*Repository) Get added in v1.2.0

func (r *Repository) Get(ctx context.Context, uid string) (domain.Device, error)

func (*Repository) GetChatIds added in v1.2.0

func (r *Repository) GetChatIds(ctx context.Context, uid string) ([]int64, error)

func (*Repository) GetDevice added in v1.2.0

func (r *Repository) GetDevice(ctx context.Context, uid string) (*domain.Device, error)

func (*Repository) GetDeviceChats added in v1.2.0

func (r *Repository) GetDeviceChats(ctx context.Context, uid string) (map[int64]string, error)

func (*Repository) GetStatus added in v1.2.0

func (r *Repository) GetStatus(ctx context.Context, uid string) (domain.DeviceStatus, error)

func (*Repository) SetActive added in v1.2.0

func (r *Repository) SetActive(ctx context.Context, uid string, active bool) error

func (*Repository) UpdateExpires added in v1.2.0

func (r *Repository) UpdateExpires(ctx context.Context, uid string, t time.Time) error

func (*Repository) UpdateInfo added in v1.2.0

func (r *Repository) UpdateInfo(ctx context.Context, uid, label, point string) error

func (*Repository) UpdateOnline added in v1.2.0

func (r *Repository) UpdateOnline(ctx context.Context, uid string, online bool) error

func (*Repository) UpdateStatus added in v1.2.0

func (r *Repository) UpdateStatus(ctx context.Context, uid string, status domain.DeviceStatus) error

Jump to

Keyboard shortcuts

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