controllers

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 4 Imported by: 0

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