postgres

package
v0.0.0-...-6151759 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2017 License: GPL-2.0, GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(user, pass, host, name string, port uint, sslMode string) (*sql.DB, error)

Open creates new connection pool to database. Clients of this call should defer Close on returned object.

Types

type AddressService

type AddressService struct {
	DB *sql.DB
}

AddressService is implementation of lara.AddressService using postgresql database

func (*AddressService) SearchCity

func (s *AddressService) SearchCity(ctx context.Context, query string) (*lara.CityStreetList, error)

SearchCity is implementation of AddressService.SearchCity using postgresql database. TODO make search limit parametric

func (*AddressService) SearchStreetForCity

func (s *AddressService) SearchStreetForCity(ctx context.Context, cityID uint64, query string) (*lara.CityStreetList, error)

SearchStreetForCity is implementation of AddressService.SearchStreetForCity using postgresql database

type OwnerAddressDTO

type OwnerAddressDTO struct {
	City    sql.NullString
	Street  sql.NullString
	HouseNo sql.NullString
}

OwnerAddressDTO is common DTO for formatted Owner's address retrieval

func (*OwnerAddressDTO) String

func (o *OwnerAddressDTO) String() string

type OwnerNameDTO

type OwnerNameDTO struct {
	FirstName sql.NullString
	LastName  string
	Title     sql.NullString
}

OwnerNameDTO is common DTO for formatted Owner's name retrieval

func (*OwnerNameDTO) String

func (o *OwnerNameDTO) String() string

type OwnerService

type OwnerService struct {
	DB *sql.DB
}

OwnerService is implementation of lara.OwnerService using postgresql database

func (*OwnerService) Create

func (s *OwnerService) Create(ctx context.Context, o *lara.CreateOwner) (uint64, error)

Create is implementation of OwnerService.Create using postgresql database. Creates new owner in database and returns its ID.

func (*OwnerService) Get

func (s *OwnerService) Get(ctx context.Context, id uint64) (*lara.GetOwner, error)

Get is implementation of OwnerService.Get using postgresql database. Returns GetOwner data by ID.

func (*OwnerService) Update

func (s *OwnerService) Update(ctx context.Context, id uint64, o *lara.UpdateOwner) error

Update is implementation of OwnerService.Update using postgresql database.

type Password

type Password interface {
	Create(pass string) ([]byte, []byte, error) // hash, salt, err
	Check(pass string, salt, hash []byte) error
}

Password is interface for passwords manipulation

type PatientService

type PatientService struct {
	DB *sql.DB
}

PatientService is implementation of lara.PatientService using postgresql database

func (*PatientService) Create

Create is implementation of PatientService.Create using postgresql database.

func (*PatientService) Get

Get is implementation of PatientService.Get using postgresql database.

func (*PatientService) Update

func (s *PatientService) Update(ctx context.Context, id uint64, p *lara.UpdatePatient) error

Update is implementation of PatientService.Update using postgresql database.

type ProductService

type ProductService struct {
	DB *sql.DB
}

ProductService is lara.ProductService implementation backed by postgresql

func (*ProductService) Search

Search performs DB search according to ProductSearchRequest TODO make search limit parametric

type RecordService

type RecordService struct {
	DB *sql.DB
}

RecordService is implementation of lara.RecordService using postgresql database

func (*RecordService) Create

func (s *RecordService) Create(ctx context.Context, r *lara.CreateRecord) (uint64, error)

Create is implementation of RecordService.Create using postgresql database.

func (*RecordService) Get

func (s *RecordService) Get(ctx context.Context, id uint64) (*lara.GetRecord, error)

Get is implementation of RecordService.Get using postgresql database.

func (*RecordService) Update

func (s *RecordService) Update(ctx context.Context, id uint64, r *lara.UpdateRecord) error

Update is implementation of RecordService.Update using postgresql database.

type ReportService

type ReportService struct {
	DB  *sql.DB
	Loc *time.Location
}

ReportService is lara.ReportService implementation backed by postgresql

func (*ReportService) GetIncomeStatistics

func (s *ReportService) GetIncomeStatistics(ctx context.Context,
	r *lara.ReportRequest) (*lara.IncomeStatistics, error)

GetIncomeStatistics counts records and income for specified time period

TODO: better query - all SUMs in one query - over months SELECT extract(year FROM r.rec_date) AS yr,

      extract(month FROM r.rec_date) AS mon,
      sum(case when r.billed = true then ri.item_price else 0.0 end) AS "Billed",
      sum(case when r.billed = false then ri.item_price else 0.0 end) AS "Not Billed",
      sum(ri.item_price) AS "Total"
FROM record r
JOIN record_item ri on ri.record_id = r.id
GROUP BY yr, mon ORDER by yr, mon;

type SearchService

type SearchService struct {
	DB *sql.DB
}

SearchService is lara.SearchService implementation backed by postgresql

func (*SearchService) Search

func (s *SearchService) Search(ctx context.Context, q string) (*lara.SearchResult, error)

Search performs DB search of "q" string in owner/pet records TODO make search limit parametric

type SimpleLovService

type SimpleLovService struct {
	DB *sql.DB
}

SimpleLovService is implementation of lara.TitleService, lara.UnitService, lara.GenderService, lara.SpeciesService, lara.BreedService using postgresql database.

func (*SimpleLovService) GetAllBreedsBySpecies

func (s *SimpleLovService) GetAllBreedsBySpecies(ctx context.Context, speciesID uint64) (*lara.LOVItemList, error)

GetAllBreedsBySpecies is implementation of BreedService.GetAllBreedsBySpecies using postgresql database.

func (*SimpleLovService) GetAllGenders

func (s *SimpleLovService) GetAllGenders(ctx context.Context) (*lara.LOVItemList, error)

GetAllGenders is implementation of GenderService.GetAllGenders using postgresql database.

func (*SimpleLovService) GetAllSpecies

func (s *SimpleLovService) GetAllSpecies(ctx context.Context) (*lara.LOVItemList, error)

GetAllSpecies is implementation of SpeciesService.GetAllSpecies using postgresql database.

func (*SimpleLovService) GetAllTitles

func (s *SimpleLovService) GetAllTitles(ctx context.Context) (*lara.LOVItemList, error)

GetAllTitles is implementation of TitleService.GetAllTitles using postgresql database.

func (*SimpleLovService) GetAllUnits

func (s *SimpleLovService) GetAllUnits(ctx context.Context) (*lara.LOVItemList, error)

GetAllUnits is implementation of UnitService.GetAllUnits using postgresql database.

type TagService

type TagService struct {
	DB *sql.DB
}

TagService is lara.TagService implementation backed by postgresql

func (*TagService) Create

func (s *TagService) Create(ctx context.Context, t *lara.CreateTag) (uint64, error)

Create is implementation of TagService.Create using postgresql database.

func (*TagService) Get

func (s *TagService) Get(ctx context.Context, id uint64) (*lara.GetTag, error)

Get is implementation of TagService.Get using postgresql database.

func (*TagService) GetPatientByTag

func (s *TagService) GetPatientByTag(ctx context.Context, tagValue string) (*lara.PatientByTag, error)

GetPatientByTag is implementation of TagService.GetPatientByTag using postgresql database.

func (*TagService) Update

func (s *TagService) Update(ctx context.Context, id uint64, t *lara.UpdateTag) error

Update is implementation of TagService.Update using postgresql database.

type UserService

type UserService struct {
	DB   *sql.DB
	Pass Password
}

UserService is lara.UserService implementation backed by postgresql

func (*UserService) Authenticate

func (s *UserService) Authenticate(ctx context.Context, login, password string) (*lara.User, error)

Authenticate checks password for given login and returns User structure Method Desn't wrap errors, that it wasn't possible to find out, whether password was incorrect, or login didn't exist. This method logs *all* errors and transforms them to unauthorizedError for http layer

func (*UserService) Grant

func (s *UserService) Grant(ctx context.Context, login string, permissions []lara.PermissionType) error

Grant supplies user with a specified list of permissions

func (*UserService) Register

func (s *UserService) Register(ctx context.Context, login, password string, permissions []lara.PermissionType) error

Register creates new user in database. If user already exists, error is returned.

func (*UserService) Revoke

func (s *UserService) Revoke(ctx context.Context, login string, permissions []lara.PermissionType) error

Revoke removes supplied permissions from user

Jump to

Keyboard shortcuts

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