Documentation ¶
Index ¶
- Variables
- func ContextWithUser(ctx context.Context, u *User) context.Context
- func MakePermissions(perms []string) (map[PermissionType]bool, error)
- func NewCodedError(code int, err error) error
- type AddressService
- type BreedService
- type CityStreet
- type CityStreetList
- type CodedError
- type CreateOwner
- type CreatePatient
- type CreateRecord
- type CreateTag
- type CreatorModifier
- type GenderService
- type GetOwner
- type GetPatient
- type GetRecord
- type GetRecordItem
- type GetTag
- type IncomeStatistics
- type LOVItem
- type LOVItemList
- type NewPatient
- type NewRecord
- type Owner
- type OwnerService
- type OwnersPatient
- type Patient
- type PatientByTag
- type PatientService
- type PatientsRecord
- type PatientsTag
- type PermissionType
- type Product
- type ProductSearchRequest
- type ProductSearchResult
- type ProductService
- type RecordItem
- type RecordItemType
- type RecordService
- type ReportRequest
- type ReportService
- type SearchRecord
- type SearchResult
- type SearchService
- type SpeciesService
- type TagService
- type TagType
- type TitleService
- type UnitService
- type UpdateOwner
- type UpdatePatient
- type UpdateRecord
- type UpdateTag
- type User
- type UserService
- type Versioned
Constants ¶
This section is empty.
Variables ¶
var DefaultPermissions = []PermissionType{ViewRecord}
DefaultPermissions is set of default permissions for new user
Functions ¶
func ContextWithUser ¶
ContextWithUser returns a new Context that carries User u.
func MakePermissions ¶
func MakePermissions(perms []string) (map[PermissionType]bool, error)
MakePermissions converts string slice to PermissionType set
func NewCodedError ¶
NewCodedError creates new CodedError instance
Types ¶
type AddressService ¶
type AddressService interface { SearchCity(ctx context.Context, query string) (*CityStreetList, error) SearchStreetForCity(ctx context.Context, cityID uint64, query string) (*CityStreetList, error) }
AddressService manages addresses
type BreedService ¶
type BreedService interface {
GetAllBreedsBySpecies(ctx context.Context, speciesID uint64) (*LOVItemList, error)
}
BreedService manages breeds
type CityStreet ¶
CityStreet is JSON encoded city or street structure
type CityStreetList ¶
type CityStreetList struct { Total int `json:"total"` Items []CityStreet `json:"items"` }
CityStreetList is JSON encoded List of cities/streets
type CodedError ¶
type CodedError struct {
// contains filtered or unexported fields
}
CodedError is an error with HTTP status code hint for error handler
type CreateOwner ¶
type CreateOwner struct { Owner Patient NewPatient `json:"patient"` }
CreateOwner is JSON encoded create owner structure
type CreatePatient ¶
type CreatePatient struct { OwnerID uint64 `json:"ownerId"` NewPatient }
CreatePatient is JSON encoded create patient data
type CreateRecord ¶
CreateRecord is JSON encoded create record data
type CreateTag ¶
type CreateTag struct { PatientID uint64 `json:"patientId"` Type string `json:"type"` Value string `json:"value"` Data []byte `json:"data"` }
CreateTag is JSON encoded create tag data
type CreatorModifier ¶
type CreatorModifier struct { Creator string `json:"creator"` Created time.Time `json:"created"` Modifier string `json:"modifier"` Modified time.Time `json:"modified"` }
CreatorModifier contains object's creator & modifier fields
type GenderService ¶
type GenderService interface {
GetAllGenders(ctx context.Context) (*LOVItemList, error)
}
GenderService manages genders
type GetOwner ¶
type GetOwner struct { Versioned Owner Title string `json:"title"` City string `json:"city"` Street string `json:"street"` CreatorModifier Patients []OwnersPatient `json:"patients"` }
GetOwner is JSON encoded retrievable owner data
type GetPatient ¶
type GetPatient struct { Versioned CreatorModifier Patient Dead bool `json:"dead"` Species string `json:"species"` Breed string `json:"breed"` Gender string `json:"gender"` Records []PatientsRecord `json:"records"` Tags []PatientsTag `json:"tags"` }
GetPatient is JSON encoded retrievable patient data
type GetRecord ¶
type GetRecord struct { Versioned CreatorModifier Date time.Time `json:"date"` Text string `json:"text"` Billed bool `json:"billed"` Items []GetRecordItem `json:"items"` Total string `json:"total"` }
GetRecord is JSON encoded retrievable record data
type GetRecordItem ¶
type GetRecordItem struct { ID uint64 `json:"id"` RecordItem Product string `json:"product"` Unit string `json:"unit"` PLU string `json:"plu"` }
GetRecordItem is JSON encoded retrievable record item data
type GetTag ¶
type GetTag struct { Versioned CreatorModifier Type string `json:"type"` Value string `json:"value"` Data []byte `json:"data"` }
GetTag is JSON encoded retrievable tag data
type IncomeStatistics ¶
type IncomeStatistics struct { Records int `json:"records"` // count Income string `json:"income"` // currency (formatted decimal, precision: 8.2) IncomeBilled string `json:"incomeBilled"` // currency IncomeNotBilled string `json:"incomeNotBilled"` // currency }
IncomeStatistics is JSON encoded income statistics report
type LOVItemList ¶
type LOVItemList struct {
Items []LOVItem `json:"items"`
}
LOVItemList is JSON encoded list of of LOVItems
type NewPatient ¶
NewPatient is JSON encoded data of a patient created together with an owner
type NewRecord ¶
type NewRecord struct { Text string `json:"text"` Billed bool `json:"billed"` Items []RecordItem `json:"items"` }
NewRecord is JSON encoded data of a record created together with an owner
type Owner ¶
type Owner struct { FirstName string `json:"firstName"` LastName string `json:"lastName"` TitleID uint64 `json:"titleId"` CityID uint64 `json:"cityId"` StreetID uint64 `json:"streetId"` HouseNo string `json:"houseNo"` Phone1 string `json:"phone1"` Phone2 string `json:"phone2"` Email string `json:"email"` Note string `json:"note"` IC string `json:"IC"` DIC string `json:"DIC"` ICDPH string `json:"ICDPH"` }
Owner is JSON encoded updatable owner fields
type OwnerService ¶
type OwnerService interface { Get(ctx context.Context, id uint64) (*GetOwner, error) Update(ctx context.Context, id uint64, o *UpdateOwner) error Create(ctx context.Context, o *CreateOwner) (uint64, error) }
OwnerService manages owners
type OwnersPatient ¶
type OwnersPatient struct { ID uint64 `json:"id"` Name string `json:"name"` Species string `json:"species"` Breed string `json:"breed"` Gender string `json:"gender"` Dead bool `json:"dead"` }
OwnersPatient is JSON encoded owner's patient data
type Patient ¶
type Patient struct { Name string `json:"name"` BirthDate time.Time `json:"birthDate"` SpeciesID uint64 `json:"speciesId"` BreedID uint64 `json:"breedId"` GenderID uint64 `json:"genderId"` Note string `json:"note"` }
Patient is JSON encoded updatable patient fields
type PatientByTag ¶
type PatientByTag struct { TagType string `json:"tagType"` Name string `json:"name"` Species string `json:"species"` Breed string `json:"breed"` Gender string `json:"gender"` OwnerID uint64 `json:"ownerId"` // DB primary key OwnerName string `json:"ownerName"` // formatted owner name (first, last, title) OwnerAddress string `json:"ownerAddress"` // owner's address }
PatientByTag is JSON encoded patient's data found by tag value
type PatientService ¶
type PatientService interface { Get(ctx context.Context, id uint64) (*GetPatient, error) Update(ctx context.Context, id uint64, p *UpdatePatient) error Create(ctx context.Context, p *CreatePatient) (uint64, error) }
PatientService manages patients
type PatientsRecord ¶
type PatientsRecord struct { ID uint64 `json:"id"` Date time.Time `json:"date"` Text string `json:"text"` }
PatientsRecord is JSON encoded patient's record data
type PatientsTag ¶
type PatientsTag struct { ID uint64 `json:"id"` Type string `json:"type"` Value string `json:"value"` }
PatientsTag is JSON encoded patient's tag data
type PermissionType ¶
type PermissionType int
PermissionType defines user's permission requires golang.org/x/tools/cmd/stringer installed locally if new object permission added to enum, run "go generate"
const ( ViewRecord PermissionType = iota EditRecord ViewReports EditProducts )
Permission types enum
func (*PermissionType) FromString ¶
func (i *PermissionType) FromString(perm string) error
FromString creates PermissionType from string
func (PermissionType) String ¶
func (i PermissionType) String() string
type Product ¶
type Product struct { ID uint64 `json:"id"` // DB primary key Name string `json:"name"` // product's name Unit string `json:"unit"` // product's unit of measure Price string `json:"price"` // product's price (formatted decimal, precision: 8.2) }
Product is JSON encoded product structure
type ProductSearchRequest ¶
ProductSearchRequest is JSON encoded search product request structure
type ProductSearchResult ¶
ProductSearchResult is JSON encoded search product result structure
type ProductService ¶
type ProductService interface {
Search(ctx context.Context, p *ProductSearchRequest) (*ProductSearchResult, error)
}
ProductService manages products
type RecordItem ¶
type RecordItem struct { ProductID uint64 `json:"productId"` ProductPrice string `json:"productPrice"` Amount string `json:"amount"` ItemPrice string `json:"itemPrice"` ItemType RecordItemType `json:"itemType"` }
RecordItem is JSON encoded data od record's item containing all writable data
type RecordItemType ¶
type RecordItemType int
RecordItemType is enum defining system permissions requires golang.org/x/tools/cmd/stringer installed locally
const ( Labor RecordItemType = iota Material )
RecordItemType enum
func (RecordItemType) MarshalJSON ¶
func (i RecordItemType) MarshalJSON() ([]byte, error)
MarshalJSON is JSON marshaller implementation for RecordItemType
func (RecordItemType) String ¶
func (i RecordItemType) String() string
func (*RecordItemType) UnmarshalJSON ¶
func (i *RecordItemType) UnmarshalJSON(data []byte) error
UnmarshalJSON is JSON unmarshaller implementation for RecordItemType
type RecordService ¶
type RecordService interface { Get(ctx context.Context, id uint64) (*GetRecord, error) Update(ctx context.Context, id uint64, r *UpdateRecord) error Create(ctx context.Context, r *CreateRecord) (uint64, error) }
RecordService manages records
type ReportRequest ¶
type ReportRequest struct { ValidFrom time.Time `json:"validFrom"` ValidTo time.Time `json:"validTo"` }
ReportRequest is JSON encoded request structure for various reports
type ReportService ¶
type ReportService interface {
GetIncomeStatistics(ctx context.Context, r *ReportRequest) (*IncomeStatistics, error)
}
ReportService generates data for various reports
type SearchRecord ¶
type SearchRecord struct { ID uint64 `json:"id"` // DB primary key Name string `json:"name"` // formatted owner name (first, last, title) Address string `json:"address"` // owner's address }
SearchRecord is JSON encoded search record (owner)
type SearchResult ¶
type SearchResult struct { Total int `json:"total"` Records []SearchRecord `json:"records"` }
SearchResult is JSON encoded search result structure
type SearchService ¶
type SearchService interface {
Search(ctx context.Context, q string) (*SearchResult, error)
}
SearchService searches owners
type SpeciesService ¶
type SpeciesService interface {
GetAllSpecies(ctx context.Context) (*LOVItemList, error)
}
SpeciesService manages species
type TagService ¶
type TagService interface { Get(ctx context.Context, id uint64) (*GetTag, error) Update(ctx context.Context, id uint64, o *UpdateTag) error Create(ctx context.Context, o *CreateTag) (uint64, error) GetPatientByTag(ctx context.Context, tagValue string) (*PatientByTag, error) }
TagService manages patient's tags
type TagType ¶
type TagType int
TagType defines patient's tag type requires golang.org/x/tools/cmd/stringer installed locally if new object permission added to enum, run "go generate"
const ( LyssaVirus TagType = iota // Canine Rabies Tags, tag format: YYYY-SK-9999 Tattoo // Pet tattoo, tag format: regular string PetPassport // EU Pet Passport, tag format: SK999999999 RFID // ISO 11784/11785 FDX-B RFID chip, tag format: 999999999999999 )
Tag types enum
func (*TagType) FromString ¶
FromString creates TagType from string
type TitleService ¶
type TitleService interface {
GetAllTitles(ctx context.Context) (*LOVItemList, error)
}
TitleService manages titles
type UnitService ¶
type UnitService interface {
GetAllUnits(ctx context.Context) (*LOVItemList, error)
}
UnitService manages units
type UpdateOwner ¶
UpdateOwner is JSON encoded updatable owner data
type UpdatePatient ¶
UpdatePatient is JSON encoded update patient data
type UpdateRecord ¶
type UpdateRecord struct { Version uint64 `json:"version"` Text string `json:"text"` Items []RecordItem `json:"items"` }
UpdateRecord is JSON encoded update record data
type UpdateTag ¶
type UpdateTag struct { Version uint64 `json:"version"` Value string `json:"value"` Data []byte `json:"data"` }
UpdateTag is JSON encoded update tag data
type User ¶
type User struct { Login string Permissions map[PermissionType]bool // map instead of slice, for fast searching }
User is application user
type UserService ¶
type UserService interface { Authenticate(ctx context.Context, login, password string) (*User, error) Register(ctx context.Context, login, password string, permissions []PermissionType) error Grant(ctx context.Context, login string, permissions []PermissionType) error Revoke(ctx context.Context, login string, permissions []PermissionType) error }
UserService manages application's users