71 lines
1.8 KiB
Go
71 lines
1.8 KiB
Go
package api
|
|
|
|
type ApiResponse[T any] struct {
|
|
Success bool `json:"success"`
|
|
Data *T `json:"data,omitempty"` // Nullable data
|
|
Error *string `json:"error,omitempty"` // Nullable error message
|
|
Timestamp int64 `json:"timestamp"`
|
|
}
|
|
|
|
type ErrorResponse struct {
|
|
Error string `json:"error"`
|
|
Code *string `json:"code,omitempty"`
|
|
Details map[string]string `json:"details,omitempty"`
|
|
Timestamp int64 `json:"timestamp"`
|
|
}
|
|
|
|
type SuccessResponse struct {
|
|
Message string `json:"message"`
|
|
Timestamp int64 `json:"timestamp"`
|
|
}
|
|
|
|
type HealthResponse struct {
|
|
Status string `json:"status"`
|
|
Version string `json:"version"`
|
|
Uptime int64 `json:"uptime"`
|
|
Database DatabaseHealth `json:"database"`
|
|
BlockChain BlockChainHealth `json:"blockchain"`
|
|
}
|
|
|
|
type DatabaseHealth struct {
|
|
Connected bool `json:"connected"`
|
|
ResponseTime int64 `json:"response_time"`
|
|
ActiveConnections int `json:"active_connections"`
|
|
MaxConnections int `json:"max_connections"`
|
|
}
|
|
|
|
type BlockChainHealth struct {
|
|
LatestBlock int `json:"latest_block"`
|
|
PendingTransactions int `json:"pending_transactions"`
|
|
NetworkHashRate float64 `json:"network_hash_rate"`
|
|
AverageBlockTime int64 `json:"average_block_time"`
|
|
}
|
|
|
|
type PaginationRequest struct {
|
|
Page int `json:"page"`
|
|
PageSize int `json:"page_size"`
|
|
SortBy *string `json:"sort_by,omitempty"`
|
|
SortOrder SortOrder `json:"sort_order"`
|
|
}
|
|
|
|
type PaginatedResponse[T any] struct {
|
|
Data []T `json:"data"`
|
|
Pagination PaginationInfo `json:"pagination"`
|
|
}
|
|
|
|
type PaginationInfo struct {
|
|
CurrentPage int `json:"current_page"`
|
|
PageSize int `json:"page_size"`
|
|
TotalItems int `json:"total_items"`
|
|
TotalPages int `json:"total_pages"`
|
|
HasNext bool `json:"has_next"`
|
|
HasPrevious bool `json:"has_previous"`
|
|
}
|
|
|
|
type SortOrder string
|
|
|
|
const (
|
|
ASC SortOrder = "ASC"
|
|
DESC SortOrder = "DESC"
|
|
)
|