model

package
v0.0.0-...-b84815f Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Company

type Company struct {
	ID      int     `json:"ID"`
	Name    string  `json:"name"`
	RegCode *string `json:"regcode"`
}

Company represent company DB table structure

type CompanyModel

type CompanyModel interface {
	GetList() ([]*Company, error)
	GetItem(int) (*Company, error)
	CreateItem(*Company) (int, error)
	UpdateItem(*Company) error
	DeleteItem(int) error
	CheckExist(int) bool
}

CompanyModel represents company interaction scheme

type Contract

type Contract struct {
	ID           int       `json:"ID"`
	SellerID     int       `json:"sellerID"`
	ClientID     int       `json:"clientID"`
	ValidFrom    time.Time `json:"validFrom"`
	ValidTo      time.Time `json:"validTo"`
	CreditAmount int       `json:"amount"`
}

Contract represent contract DB table structure

type ContractModel

type ContractModel interface {
	GetList() ([]*Contract, error)
	GetItem(int) (*Contract, error)
	CreateItem(*Contract) (int, error)
	UpdateItem(*Contract) error
	DeleteItem(int) error
	CheckExist(int) bool
}

ContractModel represents contract interaction scheme

type ModelHandler

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

ModelHandler is a persistent data interaction object

func GetModelHandler

func GetModelHandler(
	company CompanyModel,
	contract ContractModel,
	purchase PurchaseModel,
) *ModelHandler

GetModelHandler returns model singleton

func NewModelHandler

func NewModelHandler(
	company CompanyModel,
	contract ContractModel,
	purchase PurchaseModel,
) *ModelHandler

NewModelHandler creates model handler

func (*ModelHandler) CheckCompanyExist

func (m *ModelHandler) CheckCompanyExist(id int) bool

CheckCompanyExist checks are company with id exists

func (*ModelHandler) CheckContractsExist

func (m *ModelHandler) CheckContractsExist(id int) bool

CheckContractsExist checks are company with id exists

func (*ModelHandler) CreateCompany

func (m *ModelHandler) CreateCompany(c *Company) (int, error)

CreateCompany creates new company

func (*ModelHandler) CreateContract

func (m *ModelHandler) CreateContract(c *Contract) (int, error)

CreateContract creates new contract

func (*ModelHandler) CreatePurchase

func (m *ModelHandler) CreatePurchase(p *Purchase) (int, error)

CreatePurchase creates new purchase document

func (*ModelHandler) DeleteCompany

func (m *ModelHandler) DeleteCompany(id int) error

DeleteCompany removes company

func (*ModelHandler) DeleteContract

func (m *ModelHandler) DeleteContract(id int) error

DeleteContract removes contract

func (*ModelHandler) GetCompany

func (m *ModelHandler) GetCompany(id int) (*Company, error)

GetCompany returns company by id

func (*ModelHandler) GetCompanyList

func (m *ModelHandler) GetCompanyList() ([]*Company, error)

GetCompanyList returns list of all companies

func (*ModelHandler) GetContract

func (m *ModelHandler) GetContract(id int) (*Contract, error)

GetContract returns contract by id

func (*ModelHandler) GetContractList

func (m *ModelHandler) GetContractList() ([]*Contract, error)

GetContractList returns list of all contracts

func (*ModelHandler) GetContractPurchaseHistory

func (m *ModelHandler) GetContractPurchaseHistory(id int) ([]*Purchase, error)

GetContractPurchaseHistory returns purchase history of contract

func (*ModelHandler) GetContractPurchaseSum

func (m *ModelHandler) GetContractPurchaseSum(id int) int

GetContractPurchaseSum returns purchase sum of contract

func (*ModelHandler) UpdateCompany

func (m *ModelHandler) UpdateCompany(c *Company) error

UpdateCompany updates company

func (*ModelHandler) UpdateContract

func (m *ModelHandler) UpdateContract(c *Contract) error

UpdateContract updates contract

type Purchase

type Purchase struct {
	ID               int       `json:"ID"`
	ContractID       int       `json:"contractID"`
	PurchaseDateTime time.Time `json:"datetime"`
	CreditSpent      int       `json:"amount"`
}

Purchase represent purchase DB table structure

type PurchaseModel

type PurchaseModel interface {
	AddItem(*Purchase) (int, error)
	GetContractHistory(int) ([]*Purchase, error)
	GetContractSum(int) int
}

PurchaseModel represents purchase interaction scheme

Jump to

Keyboard shortcuts

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