team_member.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package models
  2. import (
  3. "errors"
  4. "time"
  5. )
  6. // Typed errors
  7. var (
  8. ErrTeamMemberAlreadyAdded = errors.New("User is already added to this team")
  9. )
  10. // TeamMember model
  11. type TeamMember struct {
  12. Id int64
  13. OrgId int64
  14. TeamId int64
  15. UserId int64
  16. External bool
  17. Permission PermissionType
  18. Created time.Time
  19. Updated time.Time
  20. }
  21. // ---------------------
  22. // COMMANDS
  23. type AddTeamMemberCommand struct {
  24. UserId int64 `json:"userId" binding:"Required"`
  25. OrgId int64 `json:"-"`
  26. TeamId int64 `json:"-"`
  27. External bool `json:"-"`
  28. Permission PermissionType `json:"-"`
  29. }
  30. type UpdateTeamMemberCommand struct {
  31. UserId int64 `json:"-"`
  32. OrgId int64 `json:"-"`
  33. TeamId int64 `json:"-"`
  34. Permission PermissionType `json:"permission"`
  35. }
  36. type RemoveTeamMemberCommand struct {
  37. OrgId int64 `json:"-"`
  38. UserId int64
  39. TeamId int64
  40. ProtectLastAdmin bool `json:"-"`
  41. }
  42. // ----------------------
  43. // QUERIES
  44. type GetTeamMembersQuery struct {
  45. OrgId int64
  46. TeamId int64
  47. UserId int64
  48. External bool
  49. Result []*TeamMemberDTO
  50. }
  51. // ----------------------
  52. // Projections and DTOs
  53. type TeamMemberDTO struct {
  54. OrgId int64 `json:"orgId"`
  55. TeamId int64 `json:"teamId"`
  56. UserId int64 `json:"userId"`
  57. External bool `json:"-"`
  58. Email string `json:"email"`
  59. Login string `json:"login"`
  60. AvatarUrl string `json:"avatarUrl"`
  61. Labels []string `json:"labels"`
  62. Permission int64 `json:"permission"`
  63. }