collaborator.go 1000 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package models
  2. import (
  3. "time"
  4. )
  5. const (
  6. ROLE_READ_WRITE RoleType = "ReadWrite"
  7. ROLE_READ = "Read"
  8. )
  9. type RoleType string
  10. type Collaborator struct {
  11. Id int64
  12. AccountId int64 `xorm:"not null unique(uix_account_id_for_account_id)"`
  13. Role RoleType `xorm:"not null"`
  14. CollaboratorId int64 `xorm:"not null unique(uix_account_id_for_account_id)"`
  15. Created time.Time
  16. Updated time.Time
  17. }
  18. type RemoveCollaboratorCommand struct {
  19. CollaboratorId int64
  20. AccountId int64
  21. }
  22. type AddCollaboratorCommand struct {
  23. Email string `json:"email" binding:"required"`
  24. AccountId int64 `json:"-"`
  25. CollaboratorId int64 `json:"-"`
  26. Role RoleType `json:"-"`
  27. }
  28. func NewCollaborator(accountId int64, collaboratorId int64, role RoleType) *Collaborator {
  29. return &Collaborator{
  30. AccountId: accountId,
  31. CollaboratorId: collaboratorId,
  32. Role: role,
  33. Created: time.Now(),
  34. Updated: time.Now(),
  35. }
  36. }