logic

package
v0.0.0-...-b99d2af Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DuplicateErrorCode = "23505"

Variables

View Source
var ErrUserAlreadyExists = errors.New("user already exists")
View Source
var ErrUserNameEmpty = errors.New("user name empty")
View Source
var ErrUserNotFound = errors.New("user not found")

Functions

func NewBlocks

func NewBlocks(t *testing.T) (*Block, *Block, *Block)

Types

type Block

type Block struct {
	*testing.T
	// contains filtered or unexported fields
}

type MockQueries

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

func (*MockQueries) CreateUser

func (m *MockQueries) CreateUser(ctx context.Context, params db.CreateUserParams) (db.User, error)

func (*MockQueries) DeleteUser

func (m *MockQueries) DeleteUser(ctx context.Context, id int64) error

func (*MockQueries) GetUser

func (m *MockQueries) GetUser(ctx context.Context, id int64) (db.User, error)

func (*MockQueries) ListUsers

func (m *MockQueries) ListUsers(ctx context.Context, params db.ListUsersParams) ([]db.User, error)

func (*MockQueries) UpdateUser

func (m *MockQueries) UpdateUser(ctx context.Context, params db.UpdateUserParams) (db.User, error)

type Service

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

func NewService

func NewService(userRepo userRepo) *Service

func (*Service) CreateUser

func (s *Service) CreateUser(ctx context.Context, user User) (*User, error)

func (*Service) DeleteUserByID

func (s *Service) DeleteUserByID(ctx context.Context, id int64) error

func (*Service) GetUserByID

func (s *Service) GetUserByID(ctx context.Context, id int64) (*User, error)

func (*Service) ListUsers

func (s *Service) ListUsers(ctx context.Context, limit, offset int32) (*UsersResponse, error)

func (*Service) UpdateUserByID

func (s *Service) UpdateUserByID(ctx context.Context, id int64, user User) (*User, error)

type User

type User struct {
	ID        int64      `json:"id"`
	Name      string     `json:"name"`
	Other     string     `json:"other"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func FromDBUser

func FromDBUser(dbUser db.User) *User

type UsersResponse

type UsersResponse struct {
	Users []*User `json:"users"`
	Count int     `json:"count"`
}

func FromDBUsers

func FromDBUsers(dbUser []db.User) *UsersResponse

Jump to

Keyboard shortcuts

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