helper

package
v0.0.0-...-6082db2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertEpochToTime

func ConvertEpochToTime(epochTime int64) string

func Decrypt

func Decrypt(data string, key []byte, iv []byte) (string, error)

func Encrypt

func Encrypt(data []byte, key []byte, iv []byte) (string, error)

func GenerateOrderID

func GenerateOrderID() string

generate a random numbers with a prefix of "KC-" and a length of 8

func GenerateQRCode

func GenerateQRCode(encryptedData string) ([]byte, error)

func GenerateQRCodeWithEncryptedData

func GenerateQRCodeWithEncryptedData(qrCodeDetails QRCodeDetails, key, iv []byte, smallImage []byte) ([]byte, error)

func GenerateRandomInt

func GenerateRandomInt(n int) int

generate a random int with a max of n

func GenerateRandomString

func GenerateRandomString(n int) string

generate a random string with a length of n

func Paginate

func Paginate(p *Pagination) func(db *gorm.DB) *gorm.DB

Types

type ApiError

type ApiError struct {
	Field string
	Error string
}

type AuthClaims

type AuthClaims struct {
	UserID     uuid.UUID
	BusinessID uuid.UUID
	RoleID     uuid.UUID
	FirstName  string
	LastName   string
	Email      string
	Phone      string
}

func GetAuthClaims

func GetAuthClaims(ctx *gin.Context) *AuthClaims

type HTTPError

type HTTPError struct {
	Code            int        `json:"code"`
	Message         string     `json:"message,omitempty"`
	Messages        []ApiError `json:"messages,omitempty"`
	InternalError   error      `json:"-"`
	InternalMessage string     `json:"-"`
	ErrorID         string     `json:"error_id,omitempty"`
}

func BadRequestError

func BadRequestError(fmtString string, args ...interface{}) *HTTPError

func ConflictError

func ConflictError(fmtString string, args ...interface{}) *HTTPError

func CreatedOK

func CreatedOK(fmtString string, args ...interface{}) *HTTPError

func ExpiredTokenError

func ExpiredTokenError(fmtString string, args ...interface{}) *HTTPError

func ForbiddenError

func ForbiddenError(fmtString string, args ...interface{}) *HTTPError

func InternalServerError

func InternalServerError(fmtString string, args ...interface{}) *HTTPError

func NoContent

func NoContent(fmtString string, args ...interface{}) *HTTPError

func NotFoundError

func NotFoundError(fmtString string, args ...interface{}) *HTTPError

func NotImplemented

func NotImplemented(fmtString string, args ...interface{}) *HTTPError

func OK

func OK(fmtString string, args ...interface{}) *HTTPError

func PrettyORMErr

func PrettyORMErr(err error) *HTTPError

func TooManyRequestsError

func TooManyRequestsError(fmtString string, args ...interface{}) *HTTPError

func UnauthorizedError

func UnauthorizedError(fmtString string, args ...interface{}) *HTTPError

func UnprocessableEntityError

func UnprocessableEntityError(fmtString string, args ...interface{}) *HTTPError

func (*HTTPError) Cause

func (e *HTTPError) Cause() error

Cause returns the root cause error

func (*HTTPError) Error

func (e *HTTPError) Error() string

func (*HTTPError) Is

func (e *HTTPError) Is(target error) bool

func (*HTTPError) WithInternalError

func (e *HTTPError) WithInternalError(err error) *HTTPError

WithInternalError adds internal error information to the error

func (*HTTPError) WithInternalMessage

func (e *HTTPError) WithInternalMessage(fmtString string, args ...interface{}) *HTTPError

WithInternalMessage adds internal message information to the error

type IDQueryString

type IDQueryString struct {
	ID string `uri:"id" binding:"required,uuid"`
}

type Pagination

type Pagination struct {
	Page        int64 `json:"page,omitempty"`
	PageSize    int64 `json:"pageSize,omitempty"`
	TotalRecord int64 `json:"totalRecord,omitempty"`
}

type QRCodeDetails

type QRCodeDetails struct {
	UserID               string
	ProductID            string
	TransactionID        string
	TransactionType      string
	UserName             string
	UserEmail            string
	UserZipCode          string
	IsUserEarlyAccess    bool
	ProductName          string
	Description          string
	Package              string
	BasePrice            string
	PriceWithDiscount    string
	DiscountInPercentage string
	Date                 string
}

Jump to

Keyboard shortcuts

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