office

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: ISC Imports: 5 Imported by: 0

README

office

builds.sr.ht status

Office Service

Quick start

Development
go mod download
go run cmd/office/main.go
Test
go test -v -cover ./...
Coverage Func
go test -coverprofile=c.out ./...
go tool cover -func c.out
Coverage HTML
go test -coverprofile=c.out ./...
go tool cover -html c.out
Deployment
go mod download
go build ./...
./office

Documentation

Index

Constants

View Source
const (
	NameMinLength = 2
	NameMaxLength = 50
)

Variables

View Source
var (
	ErrAccountIDRequired = errors.New("account id is required")
	ErrAccountIDNegative = errors.New("account id must be positive")
	ErrIDRequired        = errors.New("id is required")
	ErrIDNegative        = errors.New("id must be positive")
	ErrNameRequired      = errors.New("name is required")
	ErrNameBetween       = errors.New("name must be between 2 and 50 character(s) long")
	ErrOffsetNegative    = errors.New("offset must be positive")
	ErrLimitNegative     = errors.New("limit must be positive")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	GRPC     GRPC     `toml:"grpc"`
	Database Database `toml:"database"`
}

type CreateRequest

type CreateRequest struct {
	Name      string `valid:"required,stringlength(2|50)"`
	AccountID int64  `valid:"required,int"`
}

type Database

type Database struct {
	Name     string `toml:"name"`
	Username string `toml:"username"`
	Password string `toml:"password"`
	Host     string `toml:"host"`
	Port     int    `toml:"port"`
	SSL      SSL    `toml:"ssl"`
}

type FindManyRequest

type FindManyRequest struct {
	AccountID int64 `valid:"required,int"`
	Limit     int32 `valid:"required,int"`
	Offset    int32 `valid:"required,int"`
}

type FindManyResponse

type FindManyResponse struct {
	Offices []*Office
	Total   int32
}

type FindOneRequest

type FindOneRequest struct {
	ID int64 `valid:"required,int"`
}

type FindOneResponse

type FindOneResponse struct {
	Office *Office
}

type GRPC

type GRPC struct {
	Port int `toml:"port"`
}

type Normalize

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

func NewNormalize

func NewNormalize(s Service) Normalize

func (Normalize) Create

func (n Normalize) Create(ctx context.Context, r *CreateRequest) error

func (Normalize) FindMany

func (Normalize) FindOne

func (Normalize) Update

func (n Normalize) Update(ctx context.Context, r *UpdateRequest) error

type Office

type Office struct {
	ID   int64
	Name string
}

type SSL

type SSL string
const (
	Enable  SSL = "enable"
	Disable SSL = "disable"
)

type Service

type Service interface {
	FindMany(ctx context.Context, r *FindManyRequest) (*FindManyResponse, error)
	FindOne(ctx context.Context, r *FindOneRequest) (*FindOneResponse, error)
	Create(ctx context.Context, r *CreateRequest) error
	Update(ctx context.Context, r *UpdateRequest) error
}

type TemplateService

type TemplateService interface {
	Parse(patterns string) error
	ExecuteTemplate(w http.ResponseWriter, page fmt.Stringer) error
}

type UpdateRequest

type UpdateRequest struct {
	ID   int64  `valid:"required,int"`
	Name string `valid:"required,stringlength(2|50)"`
}

type Validate

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

func NewValidate

func NewValidate(s Service) Validate

func (Validate) Create

func (v Validate) Create(ctx context.Context, r *CreateRequest) error

func (Validate) FindMany

func (Validate) FindOne

func (Validate) Update

func (v Validate) Update(ctx context.Context, r *UpdateRequest) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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