Documentation ¶
Index ¶
- type Company
- type CompanyModel
- type Contract
- type ContractModel
- type ModelHandler
- func (m *ModelHandler) CheckCompanyExist(id int) bool
- func (m *ModelHandler) CheckContractsExist(id int) bool
- func (m *ModelHandler) CreateCompany(c *Company) (int, error)
- func (m *ModelHandler) CreateContract(c *Contract) (int, error)
- func (m *ModelHandler) CreatePurchase(p *Purchase) (int, error)
- func (m *ModelHandler) DeleteCompany(id int) error
- func (m *ModelHandler) DeleteContract(id int) error
- func (m *ModelHandler) GetCompany(id int) (*Company, error)
- func (m *ModelHandler) GetCompanyList() ([]*Company, error)
- func (m *ModelHandler) GetContract(id int) (*Contract, error)
- func (m *ModelHandler) GetContractList() ([]*Contract, error)
- func (m *ModelHandler) GetContractPurchaseHistory(id int) ([]*Purchase, error)
- func (m *ModelHandler) GetContractPurchaseSum(id int) int
- func (m *ModelHandler) UpdateCompany(c *Company) error
- func (m *ModelHandler) UpdateContract(c *Contract) error
- type Purchase
- type PurchaseModel
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