User / Account model split, User and account now seperate entities, collaborators are now AccountUsers

This commit is contained in:
Torkel Ödegaard
2015-01-19 18:01:04 +01:00
parent f1996a9f1f
commit 90925273a0
29 changed files with 592 additions and 705 deletions

View File

@@ -1,6 +1,14 @@
package models
import "time"
import (
"errors"
"time"
)
// Typed errors
var (
ErrUserNotFound = errors.New("User not found")
)
type User struct {
Id int64
@@ -9,6 +17,7 @@ type User struct {
Login string
Password string
Salt string
Company string
IsAdmin bool
AccountId int64
@@ -17,30 +26,85 @@ type User struct {
Updated time.Time
}
type Account2 struct {
Id int64
Name string
Created time.Time
Updated time.Time
}
type AccountUser struct {
AccountId int64
UserId int64
Role RoleType
Created time.Time
Updated time.Time
}
// ---------------------
// COMMANDS
type CreateUserCommand struct {
Email string
Login string
Name string
Company string
Password string
Salt string
IsAdmin bool
Result User `json:"-"`
}
type UpdateUserCommand struct {
Name string `json:"name"`
Email string `json:"email"`
Login string `json:"login"`
UserId int64 `json:"-"`
}
type SetUsingAccountCommand struct {
UserId int64
AccountId int64
}
// ----------------------
// QUERIES
type GetUserByLoginQuery struct {
LoginOrEmail string
Result *User
}
type GetSignedInUserQuery struct {
UserId int64
Result *SignedInUser
}
type GetUserInfoQuery struct {
UserId int64
Result UserDTO
}
type SearchUsersQuery struct {
Query string
Page int
Limit int
Result []*UserSearchHitDTO
}
// ------------------------
// DTO & Projections
type SignedInUser struct {
UserId int64
AccountId int64
AccountName string
AccountRole RoleType
Login string
Name string
Email string
ApiKeyId int64
IsGrafanaAdmin bool
}
type UserDTO struct {
Email string `json:"email"`
Name string `json:"name"`
Login string `json:"login"`
}
type UserSearchHitDTO struct {
Id int64 `json:"id"`
Name string `json:"name"`
Login string `json:"login"`
Email string `json:"email"`
IsAdmin bool `json:"isAdmin"`
}