Loggest thine Stuff
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.

85 lines
2.5 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. package entities
  2. import (
  3. "git.aiterp.net/stufflog3/stufflog3/internal/genutils"
  4. "git.aiterp.net/stufflog3/stufflog3/models"
  5. "sort"
  6. "time"
  7. )
  8. type Project struct {
  9. ID int `json:"id"`
  10. ScopeID int `json:"scopeId"`
  11. OwnerID string `json:"ownerId"`
  12. CreatedTime time.Time `json:"createdTime"`
  13. Name string `json:"name"`
  14. Description string `json:"description"`
  15. Status models.Status `json:"status"`
  16. Tags []string `json:"tags"`
  17. }
  18. func (project *Project) Update(update models.ProjectUpdate) {
  19. if update.OwnerID != nil {
  20. project.OwnerID = *update.OwnerID
  21. }
  22. if update.Name != nil {
  23. project.Name = *update.Name
  24. }
  25. if update.Description != nil {
  26. project.Description = *update.Description
  27. }
  28. if update.Status != nil {
  29. project.Status = *update.Status
  30. }
  31. if update.RemoveTags != nil || update.AddTags != nil {
  32. project.Tags = genutils.SliceWithout(project.Tags, update.RemoveTags)
  33. project.Tags = genutils.SliceWithUniques(project.Tags, update.AddTags)
  34. sort.Strings(project.Tags)
  35. }
  36. }
  37. type Requirement struct {
  38. ID int `json:"id"`
  39. ScopeID int `json:"scopeId"`
  40. ProjectID int `json:"projectId"`
  41. AggregateRequired int `json:"aggregateRequired"`
  42. Name string `json:"name"`
  43. Description string `json:"description"`
  44. IsCoarse bool `json:"isCoarse"`
  45. Status models.Status `json:"status"`
  46. Tags []string `json:"tags"`
  47. }
  48. func (requirement *Requirement) Update(update models.RequirementUpdate) {
  49. if update.Name != nil && *update.Name != "" {
  50. requirement.Name = *update.Name
  51. }
  52. if update.Description != nil {
  53. requirement.Description = *update.Description
  54. }
  55. if update.Status != nil && update.Status.Valid() {
  56. requirement.Status = *update.Status
  57. }
  58. if update.IsCoarse != nil {
  59. requirement.IsCoarse = *update.IsCoarse
  60. }
  61. if update.AggregateRequired != nil {
  62. requirement.AggregateRequired = *update.AggregateRequired
  63. }
  64. if update.ProjectID != nil {
  65. requirement.ProjectID = *update.ProjectID
  66. }
  67. if update.RemoveTags != nil || update.AddTags != nil {
  68. requirement.Tags = genutils.SliceWithout(requirement.Tags, update.RemoveTags)
  69. requirement.Tags = genutils.SliceWithUniques(requirement.Tags, update.AddTags)
  70. sort.Strings(requirement.Tags)
  71. }
  72. }
  73. type RequirementStat struct {
  74. RequirementID int `json:"requirementId"`
  75. StatID int `json:"statId"`
  76. Required int `json:"required"`
  77. }