controllers

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseController

type BaseController struct {
}

func (*BaseController) BuildPaginationResponse

func (c *BaseController) BuildPaginationResponse(data []interface{}, pageNumber, pageSize int, total int64) response.SimplePaginationResponse

BuildPaginationResponse builds a paginated response from data

func (*BaseController) CheckUserHasRole

func (c *BaseController) CheckUserHasRole(userRoles []string, requiredRoles []string) bool

CheckAdminHasRole checks if admin has any of the required roles

func (*BaseController) GetCurrentUserID

func (c *BaseController) GetCurrentUserID(ctx *gin.Context) (string, bool)

GetCurrentAdminID extracts admin ID from context

func (*BaseController) GetIDFromParam

func (c *BaseController) GetIDFromParam(ctx *gin.Context, paramName string, serviceCode string) (string, bool)

GetIDFromParam extracts ID from URL parameter, validates it, and returns error response if missing

func (*BaseController) GetIDFromRequestOrParam

func (c *BaseController) GetIDFromRequestOrParam(ctx *gin.Context, reqID string, paramName string, serviceCode string) (string, bool)

GetIDFromRequestOrParam extracts ID from request body or URL parameter

func (*BaseController) HandleServiceError

func (c *BaseController) HandleServiceError(ctx *gin.Context, serviceCode string, err error, notFoundMessages ...string) bool

HandleServiceError handles service errors with appropriate HTTP status codes

func (*BaseController) HandleValidationError

func (c *BaseController) HandleValidationError(ctx *gin.Context, serviceCode string, err error)

HandleValidationError handles validation errors and returns Laravel-style response

func (*BaseController) NormalizePagination

func (c *BaseController) NormalizePagination(pageNumber, pageSize int) (int, int)

NormalizePagination normalizes pagination parameters with defaults and limits

func (*BaseController) ValidateReqParams

func (c *BaseController) ValidateReqParams(ctx *gin.Context, requestParams interface{}) error

Jump to

Keyboard shortcuts

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