visa

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package visa stores business layer of our application. As you can see, this package is not depend on any low-level details. All details are hidden behind four interfaces: - ApplicationStorage - VisasStorage - ReportsStorage - ReportsPrinter If you check out main `cmd/...` packages, you can see, how we inject low-level dependencies inside our Service implementation.

Index

Constants

View Source
const MaxTimeToStay = 24 * 90

MaxTimeToStay described maximum time in hours from arrival to departure.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	ID        int
	Name      string
	Arrival   time.Time
	Departure time.Time
	Money     float64
}

Application described Visa Application domain model.

type ApplicationStorage

type ApplicationStorage interface {
	GetVisaApplication(id int) (*Application, error)
}

ApplicationStorage described VISA applications persistent storage.

type MockApplicationStorage

type MockApplicationStorage struct {
	mock.Mock
}

MockApplicationStorage is an autogenerated mock type for the ApplicationStorage type

func (*MockApplicationStorage) GetVisaApplication

func (_m *MockApplicationStorage) GetVisaApplication(id int) (*Application, error)

GetVisaApplication provides a mock function with given fields: id

type MockReportsStorage

type MockReportsStorage struct {
	mock.Mock
}

MockReportsStorage is an autogenerated mock type for the ReportsStorage type

func (*MockReportsStorage) LoadApplicationReport

func (_m *MockReportsStorage) LoadApplicationReport(id int) (*Report, error)

LoadApplicationReport provides a mock function with given fields: id

func (*MockReportsStorage) SaveApplicationReport

func (_m *MockReportsStorage) SaveApplicationReport(_a0 Report) error

SaveApplicationReport provides a mock function with given fields: _a0

type MockVisasStorage

type MockVisasStorage struct {
	mock.Mock
}

MockVisasStorage is an autogenerated mock type for the VisasStorage type

func (*MockVisasStorage) GetPreviousVisas

func (_m *MockVisasStorage) GetPreviousVisas(name string) ([]Visa, error)

GetPreviousVisas provides a mock function with given fields: name

type Report

type Report struct {
	ID            int64
	ApplicationID int
	Applicant     string
	Accepted      bool
}

Report described Visa Application Report domain model. In other words this structure described Visa Application Result.

type ReportsPrinter

type ReportsPrinter func(Report) error

ReportsPrinter implements reports printer. We use it as output port for printing application result.

type ReportsStorage

type ReportsStorage interface {
	SaveApplicationReport(Report) error
	LoadApplicationReport(id int) (*Report, error)
}

ReportsStorage describes VISA application reports persistent storage.

type Service

type Service struct {
	AStore      ApplicationStorage
	VStore      VisasStorage
	RStore      ReportsStorage
	PrintReport ReportsPrinter
}

Service implements Visa Confirmation Service.

func (*Service) CheckConfirmation

func (svc *Service) CheckConfirmation(applicationID int) error

CheckConfirmation gets information about Visa confirmation byt applicationID. This method implement our Business Logic. Don't focus on business-logic itself. THE MAIN THING HERE IS THAT OUR METHOD DEPENDS ON INTERFACES, NOT LOW-LEVEL DETAILS.

type Visa

type Visa struct {
	From      time.Time
	To        time.Time
	Arrival   time.Time
	Departure time.Time
}

Visa described Visa domain model.

type VisasStorage

type VisasStorage interface {
	GetPreviousVisas(applicantName string) ([]Visa, error)
}

VisasStorage describes VISA persistent storage.

Jump to

Keyboard shortcuts

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