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:
n.nakhostin
2025-09-06 15:59:34 +03:30
parent 38844939b5
commit 05e7b50ec4
3 changed files with 26 additions and 16 deletions
+12 -2
View File
@@ -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,
}
}