|
@@ -9,8 +9,8 @@ var (
|
|
|
CreateAccount func(acccount *Account) error
|
|
CreateAccount func(acccount *Account) error
|
|
|
UpdateAccount func(acccount *Account) error
|
|
UpdateAccount func(acccount *Account) error
|
|
|
GetAccountByLogin func(emailOrName string) (*Account, error)
|
|
GetAccountByLogin func(emailOrName string) (*Account, error)
|
|
|
- GetAccount func(accountId int) (*Account, error)
|
|
|
|
|
- GetOtherAccountsFor func(accountId int) ([]*OtherAccount, error)
|
|
|
|
|
|
|
+ GetAccount func(accountId int64) (*Account, error)
|
|
|
|
|
+ GetOtherAccountsFor func(accountId int64) ([]*OtherAccount, error)
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// Typed errors
|
|
// Typed errors
|
|
@@ -19,7 +19,7 @@ var (
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
type CollaboratorLink struct {
|
|
type CollaboratorLink struct {
|
|
|
- AccountId int
|
|
|
|
|
|
|
+ AccountId int64
|
|
|
Role string
|
|
Role string
|
|
|
Email string
|
|
Email string
|
|
|
ModifiedOn time.Time
|
|
ModifiedOn time.Time
|
|
@@ -33,20 +33,20 @@ type OtherAccount struct {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type Account struct {
|
|
type Account struct {
|
|
|
- Id int `gorethink:"id"`
|
|
|
|
|
- Version int
|
|
|
|
|
- Login string
|
|
|
|
|
- Email string
|
|
|
|
|
- AccountName string
|
|
|
|
|
|
|
+ Id int64
|
|
|
|
|
+ Login string `xorm:"UNIQUE NOT NULL"`
|
|
|
|
|
+ Email string `xorm:"UNIQUE NOT NULL"`
|
|
|
|
|
+ Name string `xorm:"UNIQUE NOT NULL"`
|
|
|
|
|
+ FullName string
|
|
|
Password string
|
|
Password string
|
|
|
- Name string
|
|
|
|
|
|
|
+ IsAdmin bool
|
|
|
|
|
+ Salt string `xorm:"VARCHAR(10)"`
|
|
|
Company string
|
|
Company string
|
|
|
NextDashboardId int
|
|
NextDashboardId int
|
|
|
- UsingAccountId int
|
|
|
|
|
- Collaborators []CollaboratorLink
|
|
|
|
|
- CreatedOn time.Time
|
|
|
|
|
- ModifiedOn time.Time
|
|
|
|
|
- LastLoginOn time.Time
|
|
|
|
|
|
|
+ UsingAccountId int64
|
|
|
|
|
+ Collaborators []CollaboratorLink `xorm:"-"`
|
|
|
|
|
+ Created time.Time `xorm:"CREATED"`
|
|
|
|
|
+ Updated time.Time `xorm:"UPDATED"`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (account *Account) AddCollaborator(newCollaborator *Account) error {
|
|
func (account *Account) AddCollaborator(newCollaborator *Account) error {
|
|
@@ -67,7 +67,7 @@ func (account *Account) AddCollaborator(newCollaborator *Account) error {
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (account *Account) RemoveCollaborator(accountId int) {
|
|
|
|
|
|
|
+func (account *Account) RemoveCollaborator(accountId int64) {
|
|
|
list := account.Collaborators
|
|
list := account.Collaborators
|
|
|
for i, collaborator := range list {
|
|
for i, collaborator := range list {
|
|
|
if collaborator.AccountId == accountId {
|
|
if collaborator.AccountId == accountId {
|
|
@@ -77,7 +77,7 @@ func (account *Account) RemoveCollaborator(accountId int) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (account *Account) HasCollaborator(accountId int) bool {
|
|
|
|
|
|
|
+func (account *Account) HasCollaborator(accountId int64) bool {
|
|
|
for _, collaborator := range account.Collaborators {
|
|
for _, collaborator := range account.Collaborators {
|
|
|
if collaborator.AccountId == accountId {
|
|
if collaborator.AccountId == accountId {
|
|
|
return true
|
|
return true
|