collaborator.go 1021 B

123456789101112131415161718192021222324252627282930313233343536373839
  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)"` // 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. type AddCollaboratorCommand struct {
  19. Email string `json:"email" binding:"required"`
  20. AccountId int64 `json:"-"`
  21. ForAccountId int64 `json:"-"`
  22. Role RoleType `json:"-"`
  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. }