database

package
v0.0.0-...-ebbd881 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusDisabled = iota
	StatusPending
	StatusEnabled
)

Variables

View Source
var (
	ErrIncorrectCreds = errors.New("username/password is incorrect")
)

Functions

func InitDB

func InitDB(dbPath string) (*sqlx.DB, error)

InitDB initializes the SQLite database and returns a sqlx DB instance.

Types

type AuthService

type AuthService interface {
	Authenticate(username, password string) (models.UserLogin, error)
}

func NewAuthServiceImpl

func NewAuthServiceImpl(userRepository UserRepository) AuthService

NewAuthServiceImpl creates a new AuthServiceImpl instance.

type AuthServiceImpl

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

AuthServiceImpl represents the concrete implementation of AuthService.

func (*AuthServiceImpl) Authenticate

func (s *AuthServiceImpl) Authenticate(username, password string) (models.UserLogin, error)

Authenticate authenticates a user with the given username and password.

type DataAccess

type DataAccess interface {
	Exec(query string, args ...any) (sql.Result, error)
	QueryRow(query string, args ...any) *sqlx.Row
	Query(query string, args ...any) (*sqlx.Rows, error)
}

DataAccess defines the interface for data access operations.

type UserRepository

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

UserRepository represents the repository for user data.

func NewUserRepository

func NewUserRepository(db *sqlx.DB) *UserRepository

NewUserRepository creates a new UserRepository instance.

func (*UserRepository) CreateUser

func (r *UserRepository) CreateUser(user models.User) (int64, error)

CreateUser inserts a new user record into the database.

func (*UserRepository) GetUserByID

func (r *UserRepository) GetUserByID(userID int) (models.User, error)

GetUserByID retrieves a user record from the database by ID.

func (*UserRepository) GetUserLogin

func (r *UserRepository) GetUserLogin(username string) (models.UserLogin, error)

GetUserLogin retrieves a user login record from the database by username.

Jump to

Keyboard shortcuts

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