|
@ -6,17 +6,18 @@ import ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
type Project struct { |
|
|
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"` |
|
|
|
|
|
StartTime *time.Time `json:"startTime" db:"start_time"` |
|
|
|
|
|
EndTime *time.Time `json:"endTime" db:"end_time"` |
|
|
|
|
|
StatusTag *string `json:"statusTag" db:"status_tag"` |
|
|
|
|
|
Favorite bool `json:"favorite" db:"favorite"` |
|
|
|
|
|
|
|
|
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"` |
|
|
|
|
|
StartTime *time.Time `json:"startTime" db:"start_time"` |
|
|
|
|
|
EndTime *time.Time `json:"endTime" db:"end_time"` |
|
|
|
|
|
SubtractAmount int `json:"subtractAmount" db:"subtract_amount"` |
|
|
|
|
|
StatusTag *string `json:"statusTag" db:"status_tag"` |
|
|
|
|
|
Favorite bool `json:"favorite" db:"favorite"` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (project *Project) Update(update ProjectUpdate) { |
|
|
func (project *Project) Update(update ProjectUpdate) { |
|
@ -46,6 +47,12 @@ func (project *Project) Update(update ProjectUpdate) { |
|
|
if update.ClearEndTime { |
|
|
if update.ClearEndTime { |
|
|
project.EndTime = nil |
|
|
project.EndTime = nil |
|
|
} |
|
|
} |
|
|
|
|
|
if update.SubtractAmount != nil { |
|
|
|
|
|
project.SubtractAmount = *update.SubtractAmount |
|
|
|
|
|
if project.SubtractAmount < 0 { |
|
|
|
|
|
project.SubtractAmount = 0 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
if update.StatusTag != nil { |
|
|
if update.StatusTag != nil { |
|
|
project.StatusTag = update.StatusTag |
|
|
project.StatusTag = update.StatusTag |
|
|
} |
|
|
} |
|
@ -70,6 +77,7 @@ type ProjectUpdate struct { |
|
|
ClearStartTime bool `json:"clearStartTime"` |
|
|
ClearStartTime bool `json:"clearStartTime"` |
|
|
EndTime *time.Time `json:"endTime"` |
|
|
EndTime *time.Time `json:"endTime"` |
|
|
ClearEndTime bool `json:"clearEndTime"` |
|
|
ClearEndTime bool `json:"clearEndTime"` |
|
|
|
|
|
SubtractAmount *int `json:"subtractAmount"` |
|
|
StatusTag *string `json:"statusTag"` |
|
|
StatusTag *string `json:"statusTag"` |
|
|
ClearStatusTag bool `json:"clearStatusTag"` |
|
|
ClearStatusTag bool `json:"clearStatusTag"` |
|
|
Favorite *bool `json:"favorite"` |
|
|
Favorite *bool `json:"favorite"` |
|
|