fix: 统一分页请求的 offset 语义
This commit is contained in:
@@ -43,7 +43,7 @@ func (l *ListTransactionsLogic) ListTransactions(req *types.PageReq) (resp *type
|
||||
}
|
||||
|
||||
out, err := l.svcCtx.WalletRpc.SearchWalletTransactions(l.ctx, &pb.SearchWalletTransactionsReq{
|
||||
Page: req.Offset / req.Limit,
|
||||
Offset: req.Offset,
|
||||
Limit: req.Limit,
|
||||
UserId: &userID,
|
||||
})
|
||||
|
||||
@@ -75,7 +75,7 @@ func (l *SearchWalletTransactionsLogic) SearchWalletTransactions(in *pb.SearchWa
|
||||
}
|
||||
|
||||
list, err := query.
|
||||
Offset(int(in.Page * in.Limit)).
|
||||
Offset(int(in.Offset)).
|
||||
Limit(int(in.Limit)).
|
||||
All(l.ctx)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc v5.29.6
|
||||
// protoc v7.34.1
|
||||
// source: wallet.proto
|
||||
|
||||
package pb
|
||||
@@ -580,7 +580,7 @@ func (x *GetWalletTransactionsByIdResp) GetWalletTransactions() *WalletTransacti
|
||||
|
||||
type SearchWalletTransactionsReq struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Page int64 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` //page
|
||||
Offset int64 `protobuf:"varint,1,opt,name=offset,proto3" json:"offset,omitempty"` //offset
|
||||
Limit int64 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` //limit
|
||||
Id int64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` //id
|
||||
UserId *int64 `protobuf:"varint,4,opt,name=userId,proto3,oneof" json:"userId,omitempty"` //userId
|
||||
@@ -625,9 +625,9 @@ func (*SearchWalletTransactionsReq) Descriptor() ([]byte, []int) {
|
||||
return file_wallet_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
func (x *SearchWalletTransactionsReq) GetPage() int64 {
|
||||
func (x *SearchWalletTransactionsReq) GetOffset() int64 {
|
||||
if x != nil {
|
||||
return x.Page
|
||||
return x.Offset
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -1209,7 +1209,7 @@ func (x *GetWalletsByIdResp) GetWallets() *Wallets {
|
||||
|
||||
type SearchWalletsReq struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Page int64 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` //page
|
||||
Offset int64 `protobuf:"varint,1,opt,name=offset,proto3" json:"offset,omitempty"` //offset
|
||||
Limit int64 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` //limit
|
||||
UserId int64 `protobuf:"varint,3,opt,name=userId,proto3" json:"userId,omitempty"` //userId
|
||||
Balance *string `protobuf:"bytes,4,opt,name=balance,proto3,oneof" json:"balance,omitempty"` //balance
|
||||
@@ -1249,9 +1249,9 @@ func (*SearchWalletsReq) Descriptor() ([]byte, []int) {
|
||||
return file_wallet_proto_rawDescGZIP(), []int{20}
|
||||
}
|
||||
|
||||
func (x *SearchWalletsReq) GetPage() int64 {
|
||||
func (x *SearchWalletsReq) GetOffset() int64 {
|
||||
if x != nil {
|
||||
return x.Page
|
||||
return x.Offset
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -1393,9 +1393,9 @@ const file_wallet_proto_rawDesc = "" +
|
||||
"\x1cGetWalletTransactionsByIdReq\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\x03R\x02id\"g\n" +
|
||||
"\x1dGetWalletTransactionsByIdResp\x12F\n" +
|
||||
"\x12walletTransactions\x18\x01 \x01(\v2\x16.pb.WalletTransactionsR\x12walletTransactions\"\xca\x03\n" +
|
||||
"\x1bSearchWalletTransactionsReq\x12\x12\n" +
|
||||
"\x04page\x18\x01 \x01(\x03R\x04page\x12\x14\n" +
|
||||
"\x12walletTransactions\x18\x01 \x01(\v2\x16.pb.WalletTransactionsR\x12walletTransactions\"\xce\x03\n" +
|
||||
"\x1bSearchWalletTransactionsReq\x12\x16\n" +
|
||||
"\x06offset\x18\x01 \x01(\x03R\x06offset\x12\x14\n" +
|
||||
"\x05limit\x18\x02 \x01(\x03R\x05limit\x12\x0e\n" +
|
||||
"\x02id\x18\x03 \x01(\x03R\x02id\x12\x1b\n" +
|
||||
"\x06userId\x18\x04 \x01(\x03H\x00R\x06userId\x88\x01\x01\x12\x17\n" +
|
||||
@@ -1453,9 +1453,9 @@ const file_wallet_proto_rawDesc = "" +
|
||||
"\x11GetWalletsByIdReq\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\x03R\x02id\";\n" +
|
||||
"\x12GetWalletsByIdResp\x12%\n" +
|
||||
"\awallets\x18\x01 \x01(\v2\v.pb.WalletsR\awallets\"\xed\x01\n" +
|
||||
"\x10SearchWalletsReq\x12\x12\n" +
|
||||
"\x04page\x18\x01 \x01(\x03R\x04page\x12\x14\n" +
|
||||
"\awallets\x18\x01 \x01(\v2\v.pb.WalletsR\awallets\"\xf1\x01\n" +
|
||||
"\x10SearchWalletsReq\x12\x16\n" +
|
||||
"\x06offset\x18\x01 \x01(\x03R\x06offset\x12\x14\n" +
|
||||
"\x05limit\x18\x02 \x01(\x03R\x05limit\x12\x16\n" +
|
||||
"\x06userId\x18\x03 \x01(\x03R\x06userId\x12\x1d\n" +
|
||||
"\abalance\x18\x04 \x01(\tH\x00R\abalance\x88\x01\x01\x12)\n" +
|
||||
|
||||
Reference in New Issue
Block a user