More migration to command/query and sql tests, looking good

This commit is contained in:
Torkel Ödegaard
2014-12-19 11:08:49 +01:00
parent ccba95542b
commit d5a59ac6b7
5 changed files with 73 additions and 63 deletions
+17 -11
View File
@@ -6,10 +6,9 @@ import (
)
var (
SaveAccount func(account *Account) error
GetAccountByLogin func(emailOrName string) (*Account, error)
GetAccount func(accountId int64) (*Account, error)
GetOtherAccountsFor func(accountId int64) ([]*OtherAccount, error)
SaveAccount func(account *Account) error
GetAccountByLogin func(emailOrName string) (*Account, error)
GetAccount func(accountId int64) (*Account, error)
)
// Typed errors
@@ -17,13 +16,6 @@ var (
ErrAccountNotFound = errors.New("Account not found")
)
// Projection from User -> other account given access to
type OtherAccount struct {
Id int64
Email string
Role string
}
type Account struct {
Id int64
Login string `xorm:"UNIQUE NOT NULL"`
@@ -41,6 +33,14 @@ type Account struct {
Updated time.Time
}
// api projection
type OtherAccountDTO struct {
Id int64 `json:"id"`
Email string `json:"email"`
Role string `json:"role"`
IsUsing bool `json:"isUsing"`
}
// api projection model
type CollaboratorDTO struct {
AccountId int64 `json:"accountId"`
@@ -60,3 +60,9 @@ type GetAccountInfoQuery struct {
Id int64
Result AccountDTO
}
// returns a view projection
type GetOtherAccountsQuery struct {
AccountId int64
Result []*OtherAccountDTO
}