Loggest thy 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.

64 lines
3.1 KiB

3 years ago
3 years ago
3 years ago
  1. package database
  2. import (
  3. "context"
  4. "git.aiterp.net/stufflog3/stufflog3-api/internal/models"
  5. "time"
  6. )
  7. type Database interface {
  8. Scopes() ScopeRepository
  9. Stats(scopeID int) StatRepository
  10. Items(scopeID int) ItemRepository
  11. Projects(scopeID int) ProjectRepository
  12. ItemsMultiScope(scopeIDs []int) ItemMultiScopeRepository
  13. }
  14. type ScopeRepository interface {
  15. Find(ctx context.Context, id int, full bool) (*models.Scope, error)
  16. List(ctx context.Context) ([]models.ScopeEntry, error)
  17. ListByUser(ctx context.Context, userID string) ([]models.ScopeEntry, error)
  18. Create(ctx context.Context, scope models.ScopeEntry, owner models.ScopeMember) (*models.Scope, error)
  19. Update(ctx context.Context, scope models.ScopeEntry) error
  20. Delete(ctx context.Context, scope models.Scope) error
  21. UpdateMember(ctx context.Context, scope models.Scope, member models.ScopeMember) (*models.Scope, error)
  22. DeleteMember(ctx context.Context, scope models.Scope, userID string) (*models.Scope, error)
  23. }
  24. type StatRepository interface {
  25. Find(ctx context.Context, id int) (*models.Stat, error)
  26. List(ctx context.Context) ([]models.Stat, error)
  27. Create(ctx context.Context, stat models.Stat) (*models.Stat, error)
  28. Update(ctx context.Context, stat models.Stat, update models.StatUpdate) (*models.Stat, error)
  29. Delete(ctx context.Context, stat models.Stat) error
  30. }
  31. type ItemRepository interface {
  32. Find(ctx context.Context, id int) (*models.Item, error)
  33. ListCreated(ctx context.Context, from, to time.Time) ([]models.Item, error)
  34. ListAcquired(ctx context.Context, from, to time.Time) ([]models.Item, error)
  35. ListScheduled(ctx context.Context, from, to models.Date) ([]models.Item, error)
  36. ListLoose(ctx context.Context, from, to time.Time) ([]models.Item, error)
  37. Create(ctx context.Context, item models.Item) (*models.Item, error)
  38. Update(ctx context.Context, item models.Item, update models.ItemUpdate) (*models.Item, error)
  39. Delete(ctx context.Context, item models.Item) error
  40. }
  41. type ItemMultiScopeRepository interface {
  42. ListCreated(ctx context.Context, from, to time.Time) ([]models.Item, error)
  43. ListAcquired(ctx context.Context, from, to time.Time) ([]models.Item, error)
  44. ListScheduled(ctx context.Context, from, to models.Date) ([]models.Item, error)
  45. ListLoose(ctx context.Context, from, to time.Time) ([]models.Item, error)
  46. }
  47. type ProjectRepository interface {
  48. Find(ctx context.Context, id int) (*models.Project, error)
  49. List(ctx context.Context) ([]models.ProjectEntry, error)
  50. Create(ctx context.Context, project models.Project) (*models.Project, error)
  51. Update(ctx context.Context, project models.Project, update models.ProjectUpdate) (*models.Project, error)
  52. Delete(ctx context.Context, project models.ProjectEntry, deleteItems bool) error
  53. AddRequirement(ctx context.Context, project models.ProjectEntry, requirement models.ProjectRequirement) (*models.Project, error)
  54. UpdateRequirement(ctx context.Context, project models.ProjectEntry, requirement models.ProjectRequirement, update models.ProjectRequirementUpdate) (*models.Project, error)
  55. DeleteRequirement(ctx context.Context, project models.ProjectEntry, requirement models.ProjectRequirement, deleteItems bool) (*models.Project, error)
  56. }