helpers

package
v0.0.0-...-b9171e1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageBadRequest                 = "Bad Request"
	MessageBadRequestInsufficientData = "Bad Request insufficient data"
	MessageInvalidBody                = "Invalid Body"
	MessageTemplateInvalidValue       = "Invalid %s, please check"
	MessageError                      = "Message"
)
View Source
const PAGINATION_DEFAULT_LIMIT = 20

Variables

View Source
var NilUUID = uuid.Nil

Functions

func BadRequest

func BadRequest(c *gin.Context, message string)

func GetReturningColumnNames

func GetReturningColumnNames(db *gorm.DB, _DataEntity interface{}, config models.Config) []string

func GetStructName

func GetStructName(dataEntity interface{}) string

func IfElementExists

func IfElementExists(arr []string, e string) bool

func InfoHandler

func InfoHandler(info map[string]interface{}) gin.HandlerFunc

func InternalServerError

func InternalServerError(c *gin.Context)

func IsUUIDValid

func IsUUIDValid(u string) bool

func NewUUID

func NewUUID() uuid.UUID

func NewUUIDStr

func NewUUIDStr() string

func ParseBody

func ParseBody(c *gin.Context, strict bool, keys []string) map[string]interface{}

func ParseBodyNonStrict

func ParseBodyNonStrict(c *gin.Context, keys ...string) map[string]interface{}

func ParseBodyStrict

func ParseBodyStrict(c *gin.Context, keys ...string) map[string]interface{}

func PgErrorCodeAndMessage

func PgErrorCodeAndMessage(err error) (string, string)

func ReturningColumnsCalculator

func ReturningColumnsCalculator(db *gorm.DB, _DataEntity interface{}, config models.Config) clause.Returning

func SetDefaultConfig

func SetDefaultConfig(dEName string, config *models.Config)

func StatusOK

func StatusOK(c *gin.Context, data interface{}, message string)

func StatusOKPag

func StatusOKPag(c *gin.Context, data interface{}, pag Pagination, message string)

func StrToUUID

func StrToUUID(s string) uuid.UUID

func TimeNow

func TimeNow(args ...interface{}) interface{}

func ToCamel

func ToCamel(str string) string

func ToEndpointNameCase

func ToEndpointNameCase(str string) string

func ToSnake

func ToSnake(str string) string

func UUIDToStr

func UUIDToStr(id uuid.UUID) string

Types

type Pagination

type Pagination struct {
	TotalRecords int64
	CurrentPage  int
	TotalPages   int
	NextPage     int
	PrevPage     int
	Limit        int
	Offset       int
}

func NewPagination

func NewPagination(pageString string, args ...int) Pagination

func (*Pagination) ParseString

func (pag *Pagination) ParseString(pageString string)

func (*Pagination) Set

func (pag *Pagination) Set(current int, totalRec int64) *Pagination

func (*Pagination) Validate

func (pag *Pagination) Validate() *Pagination

Jump to

Keyboard shortcuts

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