mirror of
https://github.com/twofas/2fas-server.git
synced 2024-12-12 20:20:19 +01:00
33 lines
756 B
Go
33 lines
756 B
Go
package query
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type BrowserExtensionPresenter struct {
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
BrowserName string `json:"browser_name"`
|
|
BrowserVersion string `json:"browser_version"`
|
|
}
|
|
|
|
type BrowserExtensionQuery struct {
|
|
Id string `uri:"extension_id" validate:"required,uuid4"`
|
|
}
|
|
|
|
type BrowserExtensionQueryHandler struct {
|
|
Database *gorm.DB
|
|
}
|
|
|
|
func (h *BrowserExtensionQueryHandler) Handle(query *BrowserExtensionQuery) (*BrowserExtensionPresenter, error) {
|
|
var presenter *BrowserExtensionPresenter
|
|
|
|
result := h.Database.Raw("SELECT * FROM browser_extensions WHERE id = ?", query.Id).First(&presenter)
|
|
|
|
if result.Error != nil {
|
|
return nil, result.Error
|
|
}
|
|
|
|
return presenter, nil
|
|
}
|