team.go 1.6 KB

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