base

package
v0.0.0-...-e854b4f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiResponse

type ApiResponse[T any] struct {
	Success bool `json:"success" doc:"Whether the request was successful"`
	Data    T    `json:"data" doc:"Response data"`
}

ApiResponse is a generic wrapper for API responses.

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error" doc:"Error message describing what went wrong"`
}

ErrorResponse represents an error response.

type JsonObject

type JsonObject map[string]interface{}

JsonObject is a map-based representation of a JSON object that can be stored in a database. It implements the sql.Valuer and sql.Scanner interfaces for seamless database integration.

nolint:recvcheck

func (*JsonObject) Scan

func (j *JsonObject) Scan(value interface{}) error

Scan implements the sql.Scanner interface for database retrieval. It unmarshals JSON data from the database into the JsonObject. Supports scanning from []byte or string values. If the value is nil, the JsonObject is set to nil.

func (JsonObject) Value

func (j JsonObject) Value() (driver.Value, error)

Value implements the driver.Valuer interface for database storage. It marshals the JsonObject to JSON bytes for database insertion. If the JsonObject is nil, it returns nil.

type MessageResponse

type MessageResponse struct {
	Message string `json:"message" doc:"Response message"`
}

MessageResponse represents a simple message response.

type Paginated

type Paginated[T any] struct {
	Success    bool               `json:"success" doc:"Whether the request was successful"`
	Data       []T                `json:"data" doc:"Array of items for the current page"`
	Pagination PaginationResponse `json:"pagination" doc:"Pagination metadata"`
}

Paginated is a generic wrapper for paginated responses.

type PaginationResponse

type PaginationResponse struct {
	TotalPages      int64 `json:"totalPages" doc:"Total number of pages"`
	TotalItems      int64 `json:"totalItems" doc:"Total number of items in the current filtered set"`
	CurrentPage     int   `json:"currentPage" doc:"Current page number (1-indexed)"`
	ItemsPerPage    int   `json:"itemsPerPage" doc:"Number of items per page"`
	GrandTotalItems int64 `json:"grandTotalItems,omitempty" doc:"Total number of items without filters"`
}

PaginationResponse contains pagination metadata.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL