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.
 
 
 
 
 
 

68 lines
1.7 KiB

package models
import (
"context"
"time"
)
type Project struct {
ID string `json:"id" db:"project_id"`
UserID string `json:"-" db:"user_id"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
Icon string `json:"icon" db:"icon"`
Active bool `json:"active" db:"active"`
CreatedTime time.Time `json:"createdTime" db:"created_time"`
EndTime *time.Time `json:"endTime" db:"end_time"`
}
func (project *Project) Update(update ProjectUpdate) {
if update.Name != nil {
project.Name = *update.Name
}
if update.Description != nil {
project.Description = *update.Description
}
if update.Icon != nil {
project.Icon = *update.Icon
}
if update.Active != nil {
project.Active = *update.Active
}
if update.EndTime != nil {
endTimeCopy := update.EndTime.UTC()
project.EndTime = &endTimeCopy
}
if update.ClearEndTime {
project.EndTime = nil
}
}
type ProjectUpdate struct {
Name *string `json:"name"`
Description *string `json:"description"`
Icon *string `json:"icon"`
Active *bool `json:"active"`
EndTime *time.Time `json:"endTime"`
ClearEndTime bool `json:"clearEndTime"`
}
type ProjectResult struct {
Project
Tasks []*TaskResult `json:"tasks"`
}
type ProjectFilter struct {
UserID string
Active *bool
Expiring bool
IDs []string
}
type ProjectRepository interface {
Find(ctx context.Context, id string) (*Project, error)
List(ctx context.Context, filter ProjectFilter) ([]*Project, error)
Insert(ctx context.Context, project Project) error
Update(ctx context.Context, project Project) error
Delete(ctx context.Context, project Project) error
}