collaborator.go 924 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package models
  2. import (
  3. "time"
  4. )
  5. const (
  6. ROLE_READ_WRITE = "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)"` // The account that can use another account
  13. Role RoleType `xorm:"not null"` // Permission type
  14. ForAccountId int64 `xorm:"not null unique(uix_account_id_for_account_id)"` // The account being given access to
  15. Created time.Time
  16. Updated time.Time
  17. }
  18. // read only projection
  19. type CollaboratorInfo struct {
  20. AccountId int64
  21. Role string
  22. Email string
  23. }
  24. func NewCollaborator(accountId int64, forAccountId int64, role RoleType) *Collaborator {
  25. return &Collaborator{
  26. AccountId: accountId,
  27. ForAccountId: forAccountId,
  28. Role: role,
  29. Created: time.Now(),
  30. Updated: time.Now(),
  31. }
  32. }