model

package
v0.0.0-...-851a5c9 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package model provides the data models for the application.

Index

Constants

View Source
const (
	// Created is the status for a created task.
	Created = Status("created")
	// Processing is the status for a processing task.
	Processing = Status("processing")
	// Done is the status for a done task.
	Done = Status("done")
)

Variables

View Source
var ErrNotFound = fmt.Errorf("not found")

ErrNotFound is the error for not found.

View Source
var StatusMap = map[Status]bool{
	Created:    true,
	Processing: true,
	Done:       true,
}

StatusMap is a map of task status.

Functions

func IsValidPriority

func IsValidPriority(fl validator.FieldLevel) bool

IsValidPriority checks if the priority is valid (High, Medium, Low)

func IsValidStatus

func IsValidStatus(fl validator.FieldLevel) bool

IsValidStatus checks if the status is valid (Created, Processing, Done)

Types

type Config

type Config struct {
	UI            UI
	APIServer     Server
	SwaggerServer Server
	SQLite        SQLite
}

Config is the configuration for the application.

type Priority

type Priority int

Priority is the priority of the task.

const (
	// Low is the lowest priority of task
	Low Priority = iota + 1
	// Medium is the medium priority of task
	Medium
	// High is the highest priority of task
	High
)

type SQLite

type SQLite struct {
	DBFilename string `validate:"required"`
}

SQLite is the configuration for the SQLite database.

type Server

type Server struct {
	Enable bool
	Port   int
}

Server is the configuration for the server.

type Status

type Status string

Status is the status of the task.

type Todo

type Todo struct {
	ID        int `gorm:"primaryKey"`
	Task      string
	Status    Status
	Priority  Priority
	CreatedAt time.Time `gorm:"autoCreateTime"`
	UpdatedAt time.Time `gorm:"autoUpdateTime"`
}

Todo is the model for the todo endpoint.

func NewTodo

func NewTodo(task string, priority Priority) *Todo

NewTodo returns a new instance of the todo model.

func NewUpdateTodo

func NewUpdateTodo(id int, task string, priority Priority, status Status) *Todo

NewUpdateTodo returns a new instance of the todo model for updating.

type UI

type UI struct {
	URL string `validate:"required"`
}

UI is the configuration for the UI.

Jump to

Keyboard shortcuts

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