service

package
v0.0.0-...-17a26c4 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MissingContext     = "context is required"
	PasswordTooShort   = "password should be at least 8 characters"
	HashingFailed      = "failed to salt and hash password: %s"
	UserOrPasswordFail = "user or password mismatch"
	VetOrgRequired     = "vetOrg ID is required"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Customer

type Customer struct {
	CustomerRepo CustomerRepo
}

Customer implements the api.CustomerService interface

func (Customer) CreateCustomer

func (customerService Customer) CreateCustomer(ctx context.Context, customer model.Customer) (*model.Customer, error)

CreateCustomer creates a new model.Customer in the vetlab system The assumption is that for a new customer, the password has not been encrypted up until this point so this is done before storing it in the repository.

func (Customer) DeleteCustomer

func (customerService Customer) DeleteCustomer(ctx context.Context, customer model.Customer) error

DeleteCustomer deletes a model.Customer from the vetlab system

func (Customer) FindCustomerByID

func (customerService Customer) FindCustomerByID(ctx context.Context, customerID uint) (*model.Customer, error)

FindCustomerByID finds customers by their unique ID

func (Customer) FindCustomerByUserName

func (customerService Customer) FindCustomerByUserName(ctx context.Context, userName string) (*model.Customer, error)

FindCustomerByUserName attempts to find customers by their userName

func (Customer) FindCustomerByVetOrg

func (customerService Customer) FindCustomerByVetOrg(ctx context.Context, vetOrg model.VetOrg) ([]model.Customer, error)

FindCustomerByVetOrg attempts to find customers by the VetOrg they belong to

func (Customer) Login

func (customerService Customer) Login(ctx context.Context, userName string, password string) (*model.Customer, error)

Login tries to log in a customer into the vetlab system

func (Customer) UpdateCustomer

func (customerService Customer) UpdateCustomer(ctx context.Context, customer model.Customer) (*model.Customer, error)

UpdateCustomer updates a model.Customer in the vetlab system

func (Customer) UpdatePassword

func (customerService Customer) UpdatePassword(ctx context.Context, customer model.Customer, password string) (*model.Customer, error)

UpdatePassword allows for the change of a customer password We do not check the old password when changing to a new one since we assume the customer has been authenticated

type CustomerRepo

type CustomerRepo interface {
	Create(*model.Customer) error
	Update(*model.Customer) error
	Delete(*model.Customer) error
	GetByID(uint) (*model.Customer, error)
	GetByVetOrgID(uint) ([]model.Customer, error)
	GetByUserName(string) (*model.Customer, error)
}

CustomerRepo declares the persistence interface for the Customer struct

type DiagnosticReportRepo

type DiagnosticReportRepo interface {
	Create(*model.DiagnosticReport) error
	Update(*model.DiagnosticReport) error
	Delete(report *model.DiagnosticReport) error
	GetByID(uint) (*model.DiagnosticReport, error)
	GetByVetOrgID(uint) ([]model.DiagnosticReport, error)
	GetByUserID(uint) ([]model.DiagnosticReport, error)
	GetByCustomerID(uint) ([]model.DiagnosticReport, error)
}

DiagnosticReportRepo describes the persistence interface for a veterinary lab report

type DiagnosticRequestRepo

type DiagnosticRequestRepo interface {
	Create(*model.DiagnosticRequest) error
	Update(*model.DiagnosticRequest) error
	Delete(*model.DiagnosticRequest) error
	GetByID(uint) (*model.DiagnosticRequest, error)
	GetByVetOrgID(uint) ([]model.DiagnosticRequest, error)
	GetByUserID(uint) ([]model.DiagnosticRequest, error)
	GetByCustomerID(uint) ([]model.DiagnosticRequest, error)
}

DiagnosticRequestRepo describes the persistence interface for diagnostic requests

type User

type User struct {
	UserRepo UserRepo
}

User implements the api.UserService interface

func (User) CreateUser

func (userService User) CreateUser(ctx context.Context, user model.User) (*model.User, error)

CreateUser creates a new model.User in the vetlab system The assumption is that for a new user, the password has not been encrypted up until this point so this is done before storing it in the repository.

func (User) DeleteUser

func (userService User) DeleteUser(ctx context.Context, user model.User) error

DeleteUser delets a model.User from the vetlab system

func (User) FindUserByID

func (userService User) FindUserByID(ctx context.Context, userID uint) (*model.User, error)

FindUserByID finds users by their unique ID

func (User) FindUserByUserName

func (userService User) FindUserByUserName(ctx context.Context, userName string) (*model.User, error)

FindUserByUserName attempts to find users by their userName

func (User) Login

func (userService User) Login(ctx context.Context, userName string, password string) (*model.User, error)

Login tries to login a user into the vetlab system

func (User) UpdatePassword

func (userService User) UpdatePassword(ctx context.Context, user model.User, password string) (*model.User, error)

UpdatePassword allows for the change of a user password We do not check the old password when changing to a new one since we assume the user has been authenticated

func (User) UpdateUser

func (userService User) UpdateUser(ctx context.Context, user model.User) (*model.User, error)

UpdateUser updates a model.User in the vetlab system

type UserRepo

type UserRepo interface {
	Create(*model.User) error
	Update(*model.User) error
	Delete(*model.User) error
	GetByID(uint) (*model.User, error)
	GetByUserName(string) (*model.User, error)
}

UserRepo declares the persistence interface for the User struct

type VetOrg

type VetOrg struct {
	VetOrgRepo VetOrgRepo
}

VetOrg implements the api.VetOrgService interface

func (VetOrg) AddCustomerToVetOrg

func (vetOrgService VetOrg) AddCustomerToVetOrg(ctx context.Context, user model.Customer, vetOrg model.VetOrg) (*model.Customer, error)

func (VetOrg) CreateVetOrg

func (vetOrgService VetOrg) CreateVetOrg(ctx context.Context, vetOrg model.VetOrg) (*model.VetOrg, error)

func (VetOrg) DeleteVetOrg

func (vetOrgService VetOrg) DeleteVetOrg(ctx context.Context, vetOrg model.VetOrg) error

func (VetOrg) FindVetOrgByID

func (vetOrgService VetOrg) FindVetOrgByID(ctx context.Context, orgID uint) (*model.VetOrg, error)

func (VetOrg) FindVetOrgByName

func (vetOrgService VetOrg) FindVetOrgByName(ctx context.Context, orgName string) ([]model.VetOrg, error)

func (VetOrg) RemoveCustomerFromVetOrg

func (vetOrgService VetOrg) RemoveCustomerFromVetOrg(ctx context.Context, user model.Customer, vetOrg model.VetOrg) (*model.Customer, error)

func (VetOrg) UpdateVetOrg

func (vetOrgService VetOrg) UpdateVetOrg(ctx context.Context, vetOrg model.VetOrg) (*model.VetOrg, error)

type VetOrgRepo

type VetOrgRepo interface {
	Create(*model.VetOrg) error
	Update(*model.VetOrg) error
	Delete(*model.VetOrg) error
	GetByID(uint) (*model.VetOrg, error)
	GetByName(string) ([]model.VetOrg, error)
}

VetOrgRepo declares the persistence interface for the model.VetOrg struct

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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