dao

package
v0.0.0-...-93f578c Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const SystemConfigKey = "system_config"

Variables

This section is empty.

Functions

func GetKeyValueStore

func GetKeyValueStore[T any](ctx context.Context, dao *Dao, key string) (*T, error)

func RemoveDuplicateAndZero

func RemoveDuplicateAndZero[T cmp.Ordered](origin []T) []T

func SetSystemConfig

func SetSystemConfig[T any](ctx context.Context, dao *Dao, key string, value *T) error

func WithTx

func WithTx[T any](ctx context.Context, db *ent.Client, exe func(ctx context.Context, tx *ent.Client) (*T, error)) (*T, error)

func WithTxEx

func WithTxEx(ctx context.Context, db *ent.Client, exe func(ctx context.Context, tx *ent.Client) error) error

Types

type Dao

type Dao struct {
	*ent.Client
}

func NewDao

func NewDao(client *ent.Client) *Dao

func (*Dao) GetAdmins

func (d *Dao) GetAdmins(ctx context.Context, ids []int64) (map[int64]*ent.Admin, error)

func (*Dao) GetSystemConfig

func (d *Dao) GetSystemConfig(ctx context.Context) (*SystemConfig, error)

func (*Dao) GetUserPlatforms

func (d *Dao) GetUserPlatforms(ctx context.Context, ids []int64) (map[int64][]*ent.UserPlatform, error)

func (*Dao) GetUsers

func (d *Dao) GetUsers(ctx context.Context, ids []int64) (map[int64]*ent.User, error)

func (*Dao) SetSystemConfig

func (d *Dao) SetSystemConfig(ctx context.Context, config *SystemConfig) error

type SystemConfig

type SystemConfig struct {
	ExampleField string `json:"example_field"`
}

Jump to

Keyboard shortcuts

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