team.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. OrgId int64 `json:"-"`
  33. }
  34. type DeleteTeamCommand struct {
  35. OrgId int64
  36. Id int64
  37. }
  38. type GetTeamByIdQuery struct {
  39. OrgId int64
  40. Id int64
  41. Result *Team
  42. }
  43. type GetTeamsByUserQuery struct {
  44. OrgId int64
  45. UserId int64 `json:"userId"`
  46. Result []*Team `json:"teams"`
  47. }
  48. type SearchTeamsQuery struct {
  49. Query string
  50. Name string
  51. Limit int
  52. Page int
  53. OrgId int64
  54. Result SearchTeamQueryResult
  55. }
  56. type SearchTeamDto struct {
  57. Id int64 `json:"id"`
  58. OrgId int64 `json:"orgId"`
  59. Name string `json:"name"`
  60. Email string `json:"email"`
  61. AvatarUrl string `json:"avatarUrl"`
  62. MemberCount int64 `json:"memberCount"`
  63. }
  64. type SearchTeamQueryResult struct {
  65. TotalCount int64 `json:"totalCount"`
  66. Teams []*SearchTeamDto `json:"teams"`
  67. Page int `json:"page"`
  68. PerPage int `json:"perPage"`
  69. }