utils

package
v0.0.0-...-76fe1ca Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB
View Source
var RedisClient *redis.Client

Functions

func DeleteCache

func DeleteCache(key string) error

func GetCache

func GetCache(key string) (string, error)

func HandleInternalServerError

func HandleInternalServerError(c *gin.Context, err error)

func HandleNotFoundError

func HandleNotFoundError(c *gin.Context, err error)

func HandleValidationError

func HandleValidationError(c *gin.Context, err error)

func InitDB

func InitDB(cfg *config.Config) (*gorm.DB, error)

func InitRedis

func InitRedis(addr string)

func SetCache

func SetCache(key string, value interface{}, expiration time.Duration) error

func ValidateStruct

func ValidateStruct(s interface{}) error

Types

type ErrorResponse

type ErrorResponse struct {
	Status  string `json:"status"`
	Message string `json:"message"`
	Error   string `json:"error,omitempty"`
}

func NewErrorResponse

func NewErrorResponse(message string, err error) ErrorResponse

type Pagination

type Pagination struct {
	Page     int
	PageSize int
}

func GetPagination

func GetPagination(c *gin.Context) Pagination

type SuccessResponse

type SuccessResponse struct {
	Status  string      `json:"status"`
	Data    interface{} `json:"data"`
	Message string      `json:"message"`
}

func NewSuccessResponse

func NewSuccessResponse(data interface{}, message string) SuccessResponse

Jump to

Keyboard shortcuts

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