The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/models/user.go

112 lines
1.8 KiB

package models
import (
"errors"
"time"
)
// Typed errors
var (
ErrUserNotFound = errors.New("User not found")
)
type User struct {
Id int64
Email string
Name string
Login string
Password string
Salt string
Rands string
Company string
IsAdmin bool
AccountId int64
Created time.Time
Updated time.Time
}
// ---------------------
// COMMANDS
type CreateUserCommand struct {
Email string `json:"email" binding:"Required"`
Login string `json:"login"`
Name string `json:"name"`
Company string `json:"compay"`
Password string `json:"password" binding:"Required"`
Salt string `json:"-"`
Rands string `json:"-"`
IsAdmin bool `json:"-"`
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"`
}