team.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. Email string `json:"email"`
  17. Created time.Time `json:"created"`
  18. Updated time.Time `json:"updated"`
  19. }
  20. // ---------------------
  21. // COMMANDS
  22. type CreateTeamCommand struct {
  23. Name string `json:"name" binding:"Required"`
  24. Email string `json:"email"`
  25. OrgId int64 `json:"-"`
  26. Result Team `json:"-"`
  27. }
  28. type UpdateTeamCommand struct {
  29. Id int64
  30. Name string
  31. Email string
  32. }
  33. type DeleteTeamCommand struct {
  34. Id int64
  35. }
  36. type GetTeamByIdQuery struct {
  37. Id int64
  38. Result *Team
  39. }
  40. type GetTeamsByUserQuery struct {
  41. UserId int64 `json:"userId"`
  42. Result []*Team `json:"teams"`
  43. }
  44. type SearchTeamsQuery struct {
  45. Query string
  46. Name string
  47. Limit int
  48. Page int
  49. OrgId int64
  50. Result SearchTeamQueryResult
  51. }
  52. type SearchTeamDto struct {
  53. Id int64 `json:"id"`
  54. OrgId int64 `json:"orgId"`
  55. Name string `json:"name"`
  56. Email string `json:"email"`
  57. AvatarUrl string `json:"avatarUrl"`
  58. MemberCount int64 `json:"memberCount"`
  59. }
  60. type SearchTeamQueryResult struct {
  61. TotalCount int64 `json:"totalCount"`
  62. Teams []*SearchTeamDto `json:"teams"`
  63. Page int `json:"page"`
  64. PerPage int `json:"perPage"`
  65. }