team.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package models
  2. import (
  3. "errors"
  4. "time"
  5. )
  6. // Typed errors
  7. var (
  8. ErrTeamNotFound = errors.New("Team not found")
  9. ErrTeamNameTaken = errors.New("Team name is taken")
  10. )
  11. // Team model
  12. type Team struct {
  13. Id int64 `json:"id"`
  14. OrgId int64 `json:"orgId"`
  15. Name string `json:"name"`
  16. Created time.Time `json:"created"`
  17. Updated time.Time `json:"updated"`
  18. }
  19. // ---------------------
  20. // COMMANDS
  21. type CreateTeamCommand struct {
  22. Name string `json:"name" binding:"Required"`
  23. OrgId int64 `json:"-"`
  24. Result Team `json:"-"`
  25. }
  26. type UpdateTeamCommand struct {
  27. Id int64
  28. Name string
  29. }
  30. type DeleteTeamCommand struct {
  31. Id int64
  32. }
  33. type GetTeamByIdQuery struct {
  34. Id int64
  35. Result *Team
  36. }
  37. type GetTeamsByUserQuery struct {
  38. UserId int64 `json:"userId"`
  39. Result []*Team `json:"teams"`
  40. }
  41. type SearchTeamsQuery struct {
  42. Query string
  43. Name string
  44. Limit int
  45. Page int
  46. OrgId int64
  47. Result SearchTeamQueryResult
  48. }
  49. type SearchTeamQueryResult struct {
  50. TotalCount int64 `json:"totalCount"`
  51. Teams []*Team `json:"teams"`
  52. Page int `json:"page"`
  53. PerPage int `json:"perPage"`
  54. }