Working on account collaborators

This commit is contained in:
Torkel Ödegaard
2015-01-14 16:12:37 +01:00
parent 50a5355de0
commit 6f63d63ee0
6 changed files with 71 additions and 45 deletions
+7 -7
View File
@@ -72,16 +72,16 @@ type GetAccountByLoginQuery struct {
// DTO & Projections
type OtherAccountDTO struct {
Id int64 `json:"id"`
Email string `json:"email"`
Role string `json:"role"`
IsUsing bool `json:"isUsing"`
}
type CollaboratorDTO struct {
AccountId int64 `json:"accountId"`
Email string `json:"email"`
Role string `json:"role"`
IsUsing bool `json:"isUsing"`
}
type CollaboratorDTO struct {
CollaboratorId int64 `json:"id"`
Email string `json:"email"`
Role string `json:"role"`
}
type AccountDTO struct {
+20 -15
View File
@@ -12,28 +12,33 @@ const (
type RoleType string
type Collaborator struct {
Id int64
AccountId int64 `xorm:"not null unique(uix_account_id_for_account_id)"` // The account that can use another account
Role RoleType `xorm:"not null"` // Permission type
ForAccountId int64 `xorm:"not null unique(uix_account_id_for_account_id)"` // The account being given access to
Id int64
AccountId int64 `xorm:"not null unique(uix_account_id_for_account_id)"`
Role RoleType `xorm:"not null"`
CollaboratorId int64 `xorm:"not null unique(uix_account_id_for_account_id)"`
Created time.Time
Updated time.Time
}
type AddCollaboratorCommand struct {
Email string `json:"email" binding:"required"`
AccountId int64 `json:"-"`
ForAccountId int64 `json:"-"`
Role RoleType `json:"-"`
type RemoveCollaboratorCommand struct {
CollaboratorId int64
AccountId int64
}
func NewCollaborator(accountId int64, forAccountId int64, role RoleType) *Collaborator {
type AddCollaboratorCommand struct {
Email string `json:"email" binding:"required"`
AccountId int64 `json:"-"`
CollaboratorId int64 `json:"-"`
Role RoleType `json:"-"`
}
func NewCollaborator(accountId int64, collaboratorId int64, role RoleType) *Collaborator {
return &Collaborator{
AccountId: accountId,
ForAccountId: forAccountId,
Role: role,
Created: time.Now(),
Updated: time.Now(),
AccountId: accountId,
CollaboratorId: collaboratorId,
Role: role,
Created: time.Now(),
Updated: time.Now(),
}
}