team.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 SearchTeamDto struct {
  50. Id int64 `json:"id"`
  51. OrgId int64 `json:"orgId"`
  52. Name string `json:"name"`
  53. MemberCount int64 `json:"memberCount"`
  54. }
  55. type SearchTeamQueryResult struct {
  56. TotalCount int64 `json:"totalCount"`
  57. Teams []*SearchTeamDto `json:"teams"`
  58. Page int `json:"page"`
  59. PerPage int `json:"perPage"`
  60. }