models

package
v0.0.0-...-d3bb3ff Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SetDoneEvent : setting status from (not_done, closed) -> done
	SetDoneEvent ChangeStatusEvent = "set done"
	// CloseEvent : setting status from (not_done, done) -> closed
	CloseEvent ChangeStatusEvent = "close"
	// ReopenEvent : setting status from (closed, done) -> not_done
	ReopenEvent ChangeStatusEvent = "reopen"
	// LeaveUnchangedEvent : leaving status the same as it was
	LeaveUnchangedEvent ChangeStatusEvent = "leave unchanged"
	// UndefinedFromErrorMessage is `undefined 'from' status“
	UndefinedFromErrorMessage = "undefined 'from' status"
	// UndefinedToErrorMessage is `undefined 'to' status`
	UndefinedToErrorMessage = "undefined 'to' status"
	// UnsupportedStatusChangeErrorMessage is `unsupported status change from %s to %s`
	UnsupportedStatusChangeErrorMessage = "unsupported status change from %s to %s"
	// ClosingWithoutReasonErrorMessage is `trying to close task without reason`
	ClosingWithoutReasonErrorMessage = "trying to close task without reason"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeStatusEvent

type ChangeStatusEvent string

ChangeStatusEvent represents update action on task status (set from one state to another)

func NewChangeStatusEvent

func NewChangeStatusEvent(from, to api.Status, reason string) (ChangeStatusEvent, error)

NewChangeStatusEvent creates new ChangeStatusEvent from request fields

type Page

type Page struct {
	Size   int64
	Number int64
}

Page represents a GET request page

func (*Page) ToLimitOffset

func (p *Page) ToLimitOffset() (int64, int64)

ToLimitOffset represents limit + offset to be selected with from the db

type Paging

type Paging struct {
	IsEnabled bool
	Page      *Page
}

Paging represents page for GET request

func NewPaging

func NewPaging(page *api.Page) (*Paging, error)

NewPaging constructs new Paging

type Task

type Task struct {
	ID           int64      `db:"id"`
	Title        string     `db:"title"`
	Term         Term       `db:"term"`
	IsGreen      bool       `db:"is_greeen"`
	CreatedAt    time.Time  `db:"created_at"`
	UpdatedAt    time.Time  `db:"updated_at"`
	ClosedAt     *time.Time `db:"created_at"`
	ClosedReason string     `db:"closed_reason"`
	IsArchived   bool       `db:"is_archived"`
}

Task represents task entity

func NewTask

func NewTask(apiTask *api.Task) (*Task, error)

NewTask converts proto struct to the internal one

func NewTaskFromRequest

func NewTaskFromRequest(request *TaskRequest) *Task

NewTaskFromRequest creates new Task from the request

func (*Task) ToProto

func (task *Task) ToProto() *api.Task

ToProto converts internal struct from the one from proto-file

type TaskRequest

type TaskRequest struct {
	Title   string `db:"title"`
	Term    Term   `db:"term"`
	IsGreen bool   `db:"is_greeen"`
}

TaskRequest represents request for creating the task

func NewTaskRequest

func NewTaskRequest(request *api.AddTaskRequest) (*TaskRequest, error)

NewTaskRequest constructs new TaskRequest

type Term

type Term struct {
	Value    string
	ValueInt int64
}

Term is a wrapper around Term Enum

func NewTermFromInt

func NewTermFromInt(value int64) (*Term, error)

NewTermFromInt constructs new Term

func NewTermFromString

func NewTermFromString(value string) (*Term, error)

NewTermFromString constructs new Term

Jump to

Keyboard shortcuts

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