mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-05 16:56:22 +00:00
⚡️ feat: refactor sorting parameters in post listing API and components
- Renamed `orderedBy` to `orderBy` and `reverse` to `desc` in ListPostsParams interface and related functions. - Updated all usages of the sorting parameters in the post listing logic to reflect the new naming convention. feat: add user-related API functions - Implemented `getLoginUser` and `getUserById` functions in the user API to fetch user details. - Enhanced user model to include `language` property. feat: integrate next-intl for internationalization - Added `next-intl` plugin to Next.js configuration for improved localization support. - Removed previous i18n implementation and replaced it with a new structure using JSON files for translations. - Created locale files for English, Japanese, and Chinese with basic translations. - Implemented a request configuration to handle user locales and messages dynamically. fix: clean up unused imports and code - Removed unused i18n utility functions and language settings from device context. - Cleaned up commented-out code in blog card component and sidebar. chore: update dependencies - Added `deepmerge` for merging locale messages. - Updated package.json and pnpm-lock.yaml to reflect new dependencies.
This commit is contained in:
@ -6,28 +6,28 @@ import (
|
||||
)
|
||||
|
||||
type PaginationParams struct {
|
||||
Page uint64
|
||||
Size uint64
|
||||
OrderedBy string
|
||||
Reverse bool // 默认是从大值到小值
|
||||
Page uint64
|
||||
Size uint64
|
||||
OrderBy string
|
||||
Desc bool // 默认是从大值到小值
|
||||
}
|
||||
|
||||
func GetPaginationParams(c *app.RequestContext) *PaginationParams {
|
||||
page := c.Query("page")
|
||||
size := c.Query("size")
|
||||
orderedBy := c.Query("ordered_by")
|
||||
reverse := c.Query("reverse")
|
||||
orderBy := c.Query("order_by")
|
||||
desc := c.Query("desc")
|
||||
if page == "" {
|
||||
page = "1"
|
||||
}
|
||||
if size == "" {
|
||||
size = "10"
|
||||
}
|
||||
var reverseBool bool
|
||||
if reverse == "" || reverse == "false" || reverse == "0" {
|
||||
reverseBool = false
|
||||
var descBool bool
|
||||
if desc == "" || desc == "false" || desc == "0" {
|
||||
descBool = false
|
||||
} else {
|
||||
reverseBool = true
|
||||
descBool = true
|
||||
}
|
||||
pageNum, err := strconv.ParseUint(page, 10, 64)
|
||||
if err != nil || pageNum < 1 {
|
||||
@ -38,9 +38,9 @@ func GetPaginationParams(c *app.RequestContext) *PaginationParams {
|
||||
sizeNum = 10
|
||||
}
|
||||
return &PaginationParams{
|
||||
Page: pageNum,
|
||||
Size: sizeNum,
|
||||
OrderedBy: orderedBy,
|
||||
Reverse: reverseBool,
|
||||
Page: pageNum,
|
||||
Size: sizeNum,
|
||||
OrderBy: orderBy,
|
||||
Desc: descBool,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user