domain

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DateLayout = "2006-01-02"

Variables

View Source
var (
	ErrNotFound = NewError("record not found")
)

Functions

func FixBrandModel

func FixBrandModel(brandModel, model string) (resBrand, resModel string)

FixBrandModel returns fixed brand.

func FixDate

func FixDate(lexeme string) string

FixDate returns fixed date in string format.

Types

type Error

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

func NewError

func NewError(msg string) Error

func (Error) Error

func (e Error) Error() string

type Operation

type Operation struct {
	Person      string   `json:"person" db:"person" csv:"person"`
	RegAddress  *string  `json:"reg_addr_koatuu,omitempty" db:"reg_address" csv:"reg_addr_koatuu"`
	RegCode     int16    `json:"registration_code" db:"code" csv:"oper_code"`
	Reg         string   `json:"registration" db:"name" csv:"oper_name"`
	Date        string   `json:"date" db:"reg_date" csv:"d_reg"`
	DepCode     int32    `json:"dep_code" db:"office_id" csv:"dep_code"`
	Dep         string   `json:"dep" db:"office_name" csv:"dep"`
	Brand       string   `json:"brand" db:"make" csv:"brand"`
	Model       string   `json:"model" db:"model" csv:"model"`
	Year        int16    `json:"year" db:"year" csv:"make_year"`
	Color       string   `json:"color" db:"color" csv:"color"`
	Kind        string   `json:"kind" db:"kind" csv:"kind"`
	Body        string   `json:"body" db:"body" csv:"body"`
	Purpose     string   `json:"purpose" db:"purpose" csv:"purpose"`
	Fuel        *string  `json:"fuel,omitempty" db:"fuel" csv:"fuel"`
	Capacity    *int     `json:"capacity,omitempty" db:"capacity" csv:"capacity"`
	OwnWeight   *float64 `json:"own_weight,omitempty" db:"own_weight" csv:"own_weight"`
	TotalWeight *float64 `json:"total_weight,omitempty" db:"total_weight" csv:"total_weight"`
	Number      string   `json:"number" db:"number" csv:"n_reg_new"`
	ResourceID  int64    `json:"-" db:"resource_id" csv:"-"`
}

Operation represents entity in the domain.Store.

func OperationFromGov

func OperationFromGov(columns []string) (*Operation, error)

OperationFromGov returns new instance of Operation from CSV row.

func TestOperation

func TestOperation(t *testing.T) *Operation

TestOperation return special operations for testing purposes.

func (*Operation) PrettyPerson

func (op *Operation) PrettyPerson() string

type OperationRepository

type OperationRepository interface {
	ReadOperationRepository
	WriteOperationRepository
}

type Parser

type Parser interface {
	Parse(ctx context.Context, resource *Resource, r *bulkreader.BulkReader) error
}

type ReadOperationRepository

type ReadOperationRepository interface {
	FindByNumber(ctx context.Context, number string, limit uint64, order string) ([]Operation, error)
}

type Resource

type Resource struct {
	ID           int64     `json:"id" db:"id"`
	UID          string    `json:"uid" db:"uid"`
	Name         string    `json:"name" db:"name"`
	URL          string    `json:"url" db:"url"`
	LastModified time.Time `json:"last_modified" db:"last_modified"`
	CreatedAt    time.Time `json:"created_at" db:"created_at"`
}

Resource represents entity from the data.gov.ua web portal.

func TestResource

func TestResource(t *testing.T) *Resource

TestResource return special resource for testing purposes.

type ResourceRepository

type ResourceRepository interface {
	Create(ctx context.Context, resource *Resource) error
	Update(rctx context.Context, esource *Resource) error
	FindByUID(ctx context.Context, uid string) (*Resource, error)
	All(ctx context.Context) ([]Resource, error)
}

type Revision

type Revision struct {
	ID          string    `json:"id" db:"id"`
	URL         string    `json:"url" db:"url"`
	FileHashSum *string   `json:"file_hash_sum" db:"file_hash_sum"`
	Deleted     int32     `json:"deleted" db:"deleted"`
	Added       int32     `json:"added" db:"added"`
	CreatedAt   time.Time `json:"created_at" db:"created_at"`
}

Revision represents entity in the domain.Store.

type Store

type Store interface {
	Resource() ResourceRepository
	Operation() OperationRepository
}

type UserOperationService

type UserOperationService interface {
	FindByNumber(ctx context.Context, snumber string, limit uint64, order string) ([]Operation, error)
}

type WriteOperationRepository

type WriteOperationRepository interface {
	Create(ctx context.Context, operations ...*Operation) error
	DeleteByResourceID(ctx context.Context, id int64) (int64, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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