grafana/pkg/models/account.go

69 lines
1.4 KiB
Go
Raw Normal View History

2014-09-19 23:37:18 +08:00
package models
import (
"errors"
"time"
)
2014-10-06 03:13:01 +08:00
var (
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"`
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
Created time.Time
Updated time.Time
2014-09-21 21:01:59 +08:00
}
// 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"`
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
}
// returns a view projection
type GetOtherAccountsQuery struct {
AccountId int64
Result []*OtherAccountDTO
}