Documentation
¶
Index ¶
- type BaseController
- func (c *BaseController) BuildPaginationResponse(data []interface{}, pageNumber, pageSize int, total int64) response.SimplePaginationResponse
- func (c *BaseController) CheckUserHasRole(userRoles []string, requiredRoles []string) bool
- func (c *BaseController) GetCurrentUserID(ctx *gin.Context) (string, bool)
- func (c *BaseController) GetIDFromParam(ctx *gin.Context, paramName string, serviceCode string) (string, bool)
- func (c *BaseController) GetIDFromRequestOrParam(ctx *gin.Context, reqID string, paramName string, serviceCode string) (string, bool)
- func (c *BaseController) HandleServiceError(ctx *gin.Context, serviceCode string, err error, notFoundMessages ...string) bool
- func (c *BaseController) HandleValidationError(ctx *gin.Context, serviceCode string, err error)
- func (c *BaseController) NormalizePagination(pageNumber, pageSize int) (int, int)
- func (c *BaseController) ValidateReqParams(ctx *gin.Context, requestParams interface{}) error
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
Click to show internal directories.
Click to hide internal directories.