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.
82 lines
2.4 KiB
82 lines
2.4 KiB
package entities
|
|
|
|
import (
|
|
"git.aiterp.net/stufflog3/stufflog3/internal/genutils"
|
|
"git.aiterp.net/stufflog3/stufflog3/models"
|
|
"sort"
|
|
"time"
|
|
)
|
|
|
|
type Project struct {
|
|
ID int `json:"id"`
|
|
ScopeID int `json:"scopeId"`
|
|
OwnerID string `json:"ownerId"`
|
|
CreatedTime time.Time `json:"createdTime"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Status models.Status `json:"status"`
|
|
Tags []string `json:"tags"`
|
|
}
|
|
|
|
func (project *Project) Update(update models.ProjectUpdate) {
|
|
if update.OwnerID != nil {
|
|
project.OwnerID = *update.OwnerID
|
|
}
|
|
if update.Name != nil {
|
|
project.Name = *update.Name
|
|
}
|
|
if update.Description != nil {
|
|
project.Description = *update.Description
|
|
}
|
|
if update.Status != nil {
|
|
project.Status = *update.Status
|
|
}
|
|
|
|
if update.RemoveTags != nil || update.AddTags != nil {
|
|
project.Tags = genutils.SliceWithout(project.Tags, update.RemoveTags)
|
|
project.Tags = genutils.SliceWithUniques(project.Tags, update.AddTags)
|
|
sort.Strings(project.Tags)
|
|
}
|
|
}
|
|
|
|
type Requirement struct {
|
|
ID int `json:"id"`
|
|
ScopeID int `json:"scopeId"`
|
|
ProjectID int `json:"projectId"`
|
|
AggregateRequired int `json:"aggregateRequired"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
IsCoarse bool `json:"isCoarse"`
|
|
Status models.Status `json:"status"`
|
|
Tags []string `json:"tags"`
|
|
}
|
|
|
|
func (requirement *Requirement) Update(update models.RequirementUpdate) {
|
|
if update.Name != nil && *update.Name != "" {
|
|
requirement.Name = *update.Name
|
|
}
|
|
if update.Description != nil {
|
|
requirement.Description = *update.Description
|
|
}
|
|
if update.Status != nil && update.Status.Valid() {
|
|
requirement.Status = *update.Status
|
|
}
|
|
if update.IsCoarse != nil {
|
|
requirement.IsCoarse = *update.IsCoarse
|
|
}
|
|
if update.AggregateRequired != nil {
|
|
requirement.AggregateRequired = *update.AggregateRequired
|
|
}
|
|
|
|
if update.RemoveTags != nil || update.AddTags != nil {
|
|
requirement.Tags = genutils.SliceWithout(requirement.Tags, update.RemoveTags)
|
|
requirement.Tags = genutils.SliceWithUniques(requirement.Tags, update.AddTags)
|
|
sort.Strings(requirement.Tags)
|
|
}
|
|
}
|
|
|
|
type RequirementStat struct {
|
|
RequirementID int `json:"requirementId"`
|
|
StatID int `json:"statId"`
|
|
Required int `json:"required"`
|
|
}
|