package transformer import ( "go-backend-template/internal/contract" "math" ) func PaginationToRequest(page, limit int) (int, int) { if page < 1 { page = 1 } if limit < 1 { limit = 10 } if limit > 100 { limit = 100 } return page, limit } func CreatePaginationResponse(totalCount, page, limit int) contract.PaginationResponse { totalPages := int(math.Ceil(float64(totalCount) / float64(limit))) if totalPages < 1 { totalPages = 1 } return contract.PaginationResponse{ TotalCount: totalCount, Page: page, Limit: limit, TotalPages: totalPages, } } func CreateErrorResponse(message string, code int) *contract.ErrorResponse { return &contract.ErrorResponse{ Error: "error", Message: message, Code: code, } } func CreateValidationErrorResponse(message string, details map[string]string) *contract.ValidationErrorResponse { return &contract.ValidationErrorResponse{ Error: "validation_error", Message: message, Details: details, Code: 400, } } func CreateSuccessResponse(message string, data interface{}) *contract.SuccessResponse { return &contract.SuccessResponse{ Message: message, Data: data, } }