utils

package
v0.0.0-...-192c46a Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DateParser

func DateParser(dateStr string) time.Time

func ExtractJWTClaims

func ExtractJWTClaims(c *fiber.Ctx) (*types.JWT, error)

func GenerateStateString

func GenerateStateString() string

GenerateStateString generates a secure random state string for OAuth.

func GetCategoryIDFormFiberCtx

func GetCategoryIDFormFiberCtx(c *fiber.Ctx) (uint, error)

func GetDateRange

func GetDateRange(dateRange string) (start time.Time, end time.Time)

GetDateRange Searching Service Utils GetDateRange converts a predefined date range string into a start and end time.

func GetEventIDFormFiberCtx

func GetEventIDFormFiberCtx(c *fiber.Ctx) (uint, error)

func GetJWTFromLocals

func GetJWTFromLocals(c *fiber.Ctx, key string) (jwt.MapClaims, error)

func GetJobIDFormFiberCtx

func GetJobIDFormFiberCtx(c *fiber.Ctx) (uint, error)

func GetOrgIDFormFiberCtx

func GetOrgIDFormFiberCtx(c *fiber.Ctx) (uint, error)

func GetParamFormFiberCtx

func GetParamFormFiberCtx(c *fiber.Ctx, param, field string) (uint, error)

func GetPrerequisiteIDFormFiberCtx

func GetPrerequisiteIDFormFiberCtx(c *fiber.Ctx) (uint, error)

func GetStringOfEventIDFormFiberCtx

func GetStringOfEventIDFormFiberCtx(c *fiber.Ctx) (string, error)

func GetStringOfOrgIDFormFiberCtx

func GetStringOfOrgIDFormFiberCtx(c *fiber.Ctx) (string, error)

func GetStringOfParamFormFiberCtx

func GetStringOfParamFormFiberCtx(c *fiber.Ctx, param, field string) (string, error)

func GetStructFromLocals

func GetStructFromLocals[T any](ctx *fiber.Ctx, key string) (T, error)

func GetUserIDFormFiberCtx

func GetUserIDFormFiberCtx(c *fiber.Ctx) (uuid.UUID, error)

func GormErrorAndRowsAffected

func GormErrorAndRowsAffected(result *gorm.DB) error

func ISO8601Parser

func ISO8601Parser(isoStr string) time.Time

func InitConfig

func InitConfig()

func ListStringToListUuid

func ListStringToListUuid(ids []string) []uuid.UUID

func ParseJSONAndValidate

func ParseJSONAndValidate(c *fiber.Ctx, body interface{}) error

func SeparateName

func SeparateName(fullName string) (string, string)

func TimeParser

func TimeParser(timeStr string) time.Time

func UnmarshalAndValidateJSON

func UnmarshalAndValidateJSON(jsonStr string, dest interface{}) error

func UploadBackgroundImage

func UploadBackgroundImage(c *fiber.Ctx) (multipart.File, *multipart.FileHeader, error)

func UploadImage

func UploadImage(c *fiber.Ctx) (multipart.File, *multipart.FileHeader, error)

func ValidateStruct

func ValidateStruct(data interface{}) []types.ValidationError

Types

type DateOnly

type DateOnly struct {
	time.Time
}

func (DateOnly) MarshalJSON

func (d DateOnly) MarshalJSON() ([]byte, error)

func (*DateOnly) Scan

func (d *DateOnly) Scan(value interface{}) error
func (d *DateOnly) Scan(value interface{}) error {
	if v, ok := value.(time.Time); ok {
		d.Time = v
		return nil
	}
	return fmt.Errorf("cannot convert %v to DateOnly", value)
}

func (*DateOnly) UnmarshalJSON

func (d *DateOnly) UnmarshalJSON(b []byte) error

func (DateOnly) Value

func (d DateOnly) Value() (driver.Value, error)

type Paginate

type Paginate struct {
	// contains filtered or unexported fields
}

func NewPaginate

func NewPaginate(page, limit int) *Paginate

func (*Paginate) PaginatedResult

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

type TimeOnly

type TimeOnly struct {
	time.Time
}

func (TimeOnly) MarshalJSON

func (t TimeOnly) MarshalJSON() ([]byte, error)

func (*TimeOnly) Scan

func (t *TimeOnly) Scan(value interface{}) error

Convert from database value to struct

func (t *TimeOnly) Scan(value interface{}) error {
	if v, ok := value.(time.Time); ok {
		t.Time = v
		return nil
	}
	return fmt.Errorf("cannot convert %v to TimeOnly", value)
}

Ensure TimeOnly implements sql.Scanner

func (*TimeOnly) UnmarshalJSON

func (t *TimeOnly) UnmarshalJSON(b []byte) error

func (TimeOnly) Value

func (t TimeOnly) Value() (driver.Value, error)

Value Convert to a database value (for GORM)

Jump to

Keyboard shortcuts

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