2014-09-19 23:37:18 +08:00
|
|
|
package models
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"errors"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
2014-10-06 03:13:01 +08:00
|
|
|
var (
|
2014-12-19 18:08:49 +08:00
|
|
|
SaveAccount func(account *Account) error
|
|
|
|
|
GetAccountByLogin func(emailOrName string) (*Account, error)
|
|
|
|
|
GetAccount func(accountId int64) (*Account, error)
|
2014-10-06 03:13:01 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Typed errors
|
|
|
|
|
var (
|
|
|
|
|
ErrAccountNotFound = errors.New("Account not found")
|
|
|
|
|
)
|
|
|
|
|
|
2014-09-20 18:13:46 +08:00
|
|
|
type Account struct {
|
2014-11-20 19:11:07 +08:00
|
|
|
Id int64
|
|
|
|
|
Login string `xorm:"UNIQUE NOT NULL"`
|
|
|
|
|
Email string `xorm:"UNIQUE NOT NULL"`
|
2014-12-19 17:45:22 +08:00
|
|
|
Name string
|
2014-11-20 19:11:07 +08:00
|
|
|
FullName string
|
2014-09-19 23:37:18 +08:00
|
|
|
Password string
|
2014-11-20 19:11:07 +08:00
|
|
|
IsAdmin bool
|
|
|
|
|
Salt string `xorm:"VARCHAR(10)"`
|
2014-09-22 17:39:40 +08:00
|
|
|
Company string
|
2014-09-19 23:37:18 +08:00
|
|
|
NextDashboardId int
|
2014-11-20 19:11:07 +08:00
|
|
|
UsingAccountId int64
|
2014-12-17 04:05:49 +08:00
|
|
|
|
|
|
|
|
Created time.Time
|
|
|
|
|
Updated time.Time
|
2014-09-21 21:01:59 +08:00
|
|
|
}
|
2014-12-19 16:43:16 +08:00
|
|
|
|
2014-12-19 18:08:49 +08:00
|
|
|
// api projection
|
|
|
|
|
type OtherAccountDTO struct {
|
|
|
|
|
Id int64 `json:"id"`
|
|
|
|
|
Email string `json:"email"`
|
|
|
|
|
Role string `json:"role"`
|
|
|
|
|
IsUsing bool `json:"isUsing"`
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-19 16:43:16 +08:00
|
|
|
// api projection model
|
|
|
|
|
type CollaboratorDTO struct {
|
|
|
|
|
AccountId int64 `json:"accountId"`
|
|
|
|
|
Email string `json:"email"`
|
|
|
|
|
Role string `json:"role"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// api view projection
|
|
|
|
|
type AccountDTO struct {
|
|
|
|
|
Email string `json:"email"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Collaborators []*CollaboratorDTO `json:"collaborators"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// returns a view projection
|
|
|
|
|
type GetAccountInfoQuery struct {
|
|
|
|
|
Id int64
|
|
|
|
|
Result AccountDTO
|
|
|
|
|
}
|
2014-12-19 18:08:49 +08:00
|
|
|
|
|
|
|
|
// returns a view projection
|
|
|
|
|
type GetOtherAccountsQuery struct {
|
|
|
|
|
AccountId int64
|
|
|
|
|
Result []*OtherAccountDTO
|
|
|
|
|
}
|