feat: add release date sorting options and internationalization support

This commit is contained in:
2025-12-07 20:41:49 +08:00
parent 5a5c2edfda
commit 2767f8a30f
6 changed files with 15 additions and 1 deletions

View File

@@ -109,7 +109,7 @@ func handleListResources(c fiber.Ctx) error {
if err != nil {
return model.NewRequestError("Invalid sort parameter")
}
if sortInt < 0 || sortInt > 5 {
if sortInt < 0 || sortInt > 7 {
return model.NewRequestError("Sort parameter out of range")
}
sort := model.RSort(sortInt)

View File

@@ -99,6 +99,10 @@ func GetResourceList(page, pageSize int, sort model.RSort) ([]model.Resource, in
order = "downloads ASC"
case model.RSortDownloadsDesc:
order = "downloads DESC"
case model.RSortReleaseDateAsc:
order = "release_date ASC"
case model.RSortReleaseDateDesc:
order = "release_date DESC"
default:
order = "modified_time DESC" // Default sort order
}

View File

@@ -9,4 +9,6 @@ const (
RSortViewsDesc
RSortDownloadsAsc
RSortDownloadsDesc
RSortReleaseDateAsc
RSortReleaseDateDesc
)