service

package
v0.0.2-beta Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

func New

func New(db *ent.Client) *Service

func (Service) CloseTomatoByUserId

func (s Service) CloseTomatoByUserId(ctx context.Context, userId int) error

CloseTomatoByUserId close all tomato clock by user id.

func (Service) CreateTomato

func (s Service) CreateTomato(ctx context.Context, param TomatoCreate) (*ent.UserTomato, error)

CreateTomato create a tomato clock if there is no working on tomato clock

func (Service) CreateUser

func (s Service) CreateUser(ctx context.Context, create UserCreate) (*ent.User, error)

CreateUser init user config and return it.

func (Service) GetUserByUsername

func (s Service) GetUserByUsername(ctx context.Context, username string) (*ent.User, error)

GetUserByUsername returns user entity by username if exists. If user is not exists, it will return errors of not found

func (Service) GetWorkingTomatoByUserId

func (s Service) GetWorkingTomatoByUserId(ctx context.Context, userId int) (*ent.UserTomato, error)

GetWorkingTomatoByUserId get a working on tomato clock by user id

func (Service) GiveUpTomatoByUserId

func (s Service) GiveUpTomatoByUserId(ctx context.Context, userId int) error

GiveUpTomatoByUserId give up all tomato clock by user id.

type TomatoCreate

type TomatoCreate struct {
	// Duration unit is second
	Duration int
	// Color signed tomato clock type
	Color  usertomato.Color
	UserId int
	// StartTime clock start time
	StartTime time.Time
}

TomatoCreate create new tomato clock param

type UserCreate

type UserCreate struct {
	Username string
	Password string
	Config   struct {
		RedDuration   uint
		GreedDuration uint
	}
}

Jump to

Keyboard shortcuts

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