You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
1.2 KiB

package models
import (
"context"
"time"
)
type Log struct {
ID string `json:"id" db:"log_id"`
UserID string `json:"-" db:"user_id"`
TaskID string `json:"taskId" db:"task_id"`
ItemID string `json:"itemId" db:"item_id"`
LoggedTime time.Time `json:"loggedTime" db:"logged_time"`
Description string `json:"description" db:"description"`
}
func (log *Log) Update(update LogUpdate) {
if update.LoggedTime != nil {
log.LoggedTime = update.LoggedTime.UTC()
}
if update.Description != nil {
log.Description = *update.Description
}
}
type LogUpdate struct {
LoggedTime *time.Time `json:"loggedTime"`
Description *string `json:"description"`
}
type LogResult struct {
Log
Task *Task `json:"task"`
Item *Item `json:"item"`
}
type LogFilter struct {
UserID string
TaskIDs []string
ItemIDs []string
MinTime *time.Time
MaxTime *time.Time
}
type LogRepository interface {
Find(ctx context.Context, id string) (*Log, error)
List(ctx context.Context, filter LogFilter) ([]*Log, error)
Insert(ctx context.Context, log Log) error
Update(ctx context.Context, log Log) error
Delete(ctx context.Context, log Log) error
}