Refactor User Response Handling in API Endpoints
- Updated user-related API handlers to return user entities directly instead of using the ToResponse method, simplifying response structures. - Modified service methods to return UserResponse types instead of User, enhancing consistency in response formats. - Improved pagination handling in the response package by setting default values for sorting parameters, ensuring more predictable behavior in API responses.
This commit is contained in:
@@ -191,11 +191,21 @@ func NewPagination(c echo.Context) *Pagination {
|
||||
offset = 0
|
||||
}
|
||||
|
||||
sortBy := c.QueryParam("sort_by")
|
||||
if sortBy == "" {
|
||||
sortBy = "created_at"
|
||||
}
|
||||
|
||||
sortOrder := c.QueryParam("sort_order")
|
||||
if sortOrder == "" {
|
||||
sortOrder = "desc"
|
||||
}
|
||||
|
||||
return &Pagination{
|
||||
Limit: limit,
|
||||
Offset: offset,
|
||||
SortBy: c.QueryParam("sort_by"),
|
||||
SortOrder: c.QueryParam("sort_order"),
|
||||
SortBy: sortBy,
|
||||
SortOrder: sortOrder,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user