fix: 统一所有 RPC 分页校验为 max=100 并补齐默认值

This commit is contained in:
zetaloop
2026-04-24 06:31:40 +08:00
parent 37faf1c920
commit 809dbf2cac
15 changed files with 85 additions and 16 deletions
@@ -2,6 +2,7 @@ package logic
import (
"context"
"errors"
"juwan-backend/app/community/rpc/internal/svc"
"juwan-backend/app/community/rpc/pb"
@@ -28,6 +29,9 @@ func (l *SearchCommentLikesLogic) SearchCommentLikes(in *pb.SearchCommentLikesRe
if limit <= 0 {
limit = 20
}
if limit > 100 {
return nil, errors.New("limit too large")
}
offset := in.GetOffset()
if offset < 0 {
offset = 0
@@ -2,6 +2,7 @@ package logic
import (
"context"
"errors"
"strings"
"juwan-backend/app/community/rpc/internal/svc"
@@ -29,6 +30,9 @@ func (l *SearchCommentsLogic) SearchComments(in *pb.SearchCommentsReq) (*pb.Sear
if limit <= 0 {
limit = 20
}
if limit > 100 {
return nil, errors.New("limit too large")
}
offset := in.GetOffset()
if offset < 0 {
offset = 0
@@ -2,6 +2,7 @@ package logic
import (
"context"
"errors"
"juwan-backend/app/community/rpc/internal/svc"
"juwan-backend/app/community/rpc/pb"
@@ -28,6 +29,9 @@ func (l *SearchPostLikesLogic) SearchPostLikes(in *pb.SearchPostLikesReq) (*pb.S
if limit <= 0 {
limit = 20
}
if limit > 100 {
return nil, errors.New("limit too large")
}
offset := in.GetOffset()
if offset < 0 {
offset = 0
@@ -2,6 +2,7 @@ package logic
import (
"context"
"errors"
"strings"
"juwan-backend/app/community/rpc/internal/svc"
@@ -29,6 +30,9 @@ func (l *SearchPostsLogic) SearchPosts(in *pb.SearchPostsReq) (*pb.SearchPostsRe
if limit <= 0 {
limit = 20
}
if limit > 100 {
return nil, errors.New("limit too large")
}
offset := in.GetOffset()
if offset < 0 {
offset = 0