dao

package
v0.13.0-alpha.54 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDB

func WithDB(ctx context.Context, db DB) context.Context

WithDB returns a new context with the given database connection.

Types

type DB

type DB interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}

func GetDB

func GetDB(ctx context.Context) DB

GetDB retrieves the database connection from the context.

type Login

type Login struct{}

func NewLogin

func NewLogin() *Login

func (*Login) Create

func (l *Login) Create(ctx context.Context, login model.Login) (int64, error)

func (*Login) DeleteByID

func (l *Login) DeleteByID(ctx context.Context, id int64) error

func (*Login) GetByAccount

func (l *Login) GetByAccount(ctx context.Context, account string) (model.Login, error)

func (*Login) GetByID

func (l *Login) GetByID(ctx context.Context, id int64) (model.Login, error)

func (*Login) InitTable

func (l *Login) InitTable(ctx context.Context) error

func (*Login) UpdatePassword

func (l *Login) UpdatePassword(ctx context.Context, id int64, newPassword string) error

type Registry

type Registry struct{}

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Create

func (r *Registry) Create(ctx context.Context, registry model.Registry) (int64, error)

func (*Registry) DeleteByID

func (r *Registry) DeleteByID(ctx context.Context, registryID, userID int64) error

func (*Registry) GetByDomain

func (r *Registry) GetByDomain(ctx context.Context, domain string) (model.Registry, error)

func (*Registry) GetByID

func (r *Registry) GetByID(ctx context.Context, registryID, userID int64) (model.Registry, error)

func (*Registry) GetByUserID

func (r *Registry) GetByUserID(ctx context.Context, userID int64) ([]model.Registry, error)

func (*Registry) InitTable

func (r *Registry) InitTable(ctx context.Context) error

func (*Registry) UpdateByID

func (r *Registry) UpdateByID(ctx context.Context, registryID, userID int64, registry model.Registry) error

type Token

type Token struct{}

func NewToken

func NewToken() *Token

func (*Token) Create

func (t *Token) Create(ctx context.Context, token model.Token) (int64, error)

func (*Token) DeleteByID

func (t *Token) DeleteByID(ctx context.Context, tokenID, userID int64) error

func (*Token) GetByAccount

func (t *Token) GetByAccount(ctx context.Context, userID int64, account, password string) (model.Token, error)

func (*Token) GetByID

func (t *Token) GetByID(ctx context.Context, tokenID, userID int64) (model.Token, error)

func (*Token) GetByUserID

func (t *Token) GetByUserID(ctx context.Context, userID int64) ([]model.Token, error)

func (*Token) InitTable

func (t *Token) InitTable(ctx context.Context) error

type User

type User struct{}

func NewUser

func NewUser() *User

func (*User) Create

func (c *User) Create(ctx context.Context, u model.User) (int64, error)

func (*User) GetByID

func (c *User) GetByID(ctx context.Context, id int64) (model.User, error)

func (*User) InitTable

func (c *User) InitTable(ctx context.Context) error

func (*User) UpdateNickname

func (c *User) UpdateNickname(ctx context.Context, id int64, nickname string) error

Jump to

Keyboard shortcuts

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