API token -> API key rename
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
var ErrInvalidApiKey = errors.New("Invalid API Key")
|
||||
|
||||
type ApiKey struct {
|
||||
Id int64
|
||||
AccountId int64
|
||||
Name string
|
||||
Key string
|
||||
Role RoleType
|
||||
Created time.Time
|
||||
Updated time.Time
|
||||
}
|
||||
|
||||
// ---------------------
|
||||
// COMMANDS
|
||||
type AddApiKeyCommand struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Role RoleType `json:"role" binding:"required"`
|
||||
AccountId int64 `json:"-"`
|
||||
Key string `json:"-"`
|
||||
|
||||
Result *ApiKey `json:"-"`
|
||||
}
|
||||
|
||||
type UpdateApiKeyCommand struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Role RoleType `json:"role"`
|
||||
|
||||
AccountId int64 `json:"-"`
|
||||
}
|
||||
|
||||
type DeleteApiKeyCommand struct {
|
||||
Id int64 `json:"id"`
|
||||
AccountId int64 `json:"-"`
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
// QUERIES
|
||||
|
||||
type GetApiKeysQuery struct {
|
||||
AccountId int64
|
||||
Result []*ApiKey
|
||||
}
|
||||
|
||||
type GetApiKeyByKeyQuery struct {
|
||||
Key string
|
||||
Result *ApiKey
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// DTO & Projections
|
||||
|
||||
type ApiKeyDTO struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Key string `json:"key"`
|
||||
Role RoleType `json:"role"`
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
var ErrInvalidToken = errors.New("Invalid token")
|
||||
|
||||
type Token struct {
|
||||
Id int64
|
||||
AccountId int64 `xorm:"not null unique(uix_account_id_name)"`
|
||||
Name string `xorm:"not null unique(uix_account_id_name)"`
|
||||
Token string `xorm:"UNIQUE NOT NULL"`
|
||||
Role RoleType `xorm:"not null"`
|
||||
Created time.Time
|
||||
Updated time.Time
|
||||
}
|
||||
|
||||
// ---------------------
|
||||
// COMMANDS
|
||||
type AddTokenCommand struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Role RoleType `json:"role" binding:"required"`
|
||||
AccountId int64 `json:"-"`
|
||||
Token string `json:"-"`
|
||||
Result *Token `json:"-"`
|
||||
}
|
||||
|
||||
type UpdateTokenCommand struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Role RoleType `json:"role"`
|
||||
|
||||
AccountId int64 `json:"-"`
|
||||
Result *Token `json:"-"`
|
||||
}
|
||||
|
||||
type DeleteTokenCommand struct {
|
||||
Id int64 `json:"id"`
|
||||
AccountId int64 `json:"-"`
|
||||
Result *Token `json:"-"`
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
// QUERIES
|
||||
|
||||
type GetTokensQuery struct {
|
||||
AccountId int64
|
||||
Result []*Token
|
||||
}
|
||||
|
||||
type GetTokenByTokenQuery struct {
|
||||
Token string
|
||||
Result *Token
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// DTO & Projections
|
||||
|
||||
type TokenDTO struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Token string `json:"token"`
|
||||
Role RoleType `json:"role"`
|
||||
}
|
||||
Reference in New Issue
Block a user