fix: 统一分页请求的 offset 语义
This commit is contained in:
@@ -37,8 +37,8 @@ func NewListOrdersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListOr
|
||||
|
||||
func (l *ListOrdersLogic) ListOrders(req *types.OrderListReq) (resp *types.OrderListResp, err error) {
|
||||
searchReq := &orderservice.SearchOrdersReq{
|
||||
Page: req.Offset,
|
||||
Limit: req.Limit,
|
||||
Offset: req.Offset,
|
||||
Limit: req.Limit,
|
||||
}
|
||||
if req.Status != "" {
|
||||
searchReq.Status = &req.Status
|
||||
@@ -84,7 +84,7 @@ func (l *ListOrdersLogic) ListOrders(req *types.OrderListReq) (resp *types.Order
|
||||
searchReq.PlayerId = &player.Id
|
||||
case "owner":
|
||||
shops, shopErr := l.svcCtx.ShopRpc.SearchShops(l.ctx, &shopservice.SearchShopsReq{
|
||||
Page: 0,
|
||||
Offset: 0,
|
||||
Limit: 100,
|
||||
OwnerId: uid,
|
||||
})
|
||||
@@ -96,7 +96,7 @@ func (l *ListOrdersLogic) ListOrders(req *types.OrderListReq) (resp *types.Order
|
||||
for _, shop := range shops.GetShops() {
|
||||
shopID := shop.GetId()
|
||||
q := &orderservice.SearchOrdersReq{
|
||||
Page: req.Offset,
|
||||
Offset: req.Offset,
|
||||
Limit: req.Limit,
|
||||
ShopId: &shopID,
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func (l *SearchOrderStateLogsLogic) SearchOrderStateLogs(in *pb.SearchOrderState
|
||||
query = query.Where(orderstatelogs.And(preds...))
|
||||
}
|
||||
|
||||
items, err := query.Offset(int(in.Page * in.Limit)).Limit(int(in.Limit)).All(l.ctx)
|
||||
items, err := query.Offset(int(in.Offset)).Limit(int(in.Limit)).All(l.ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ func (l *SearchOrdersLogic) SearchOrders(in *pb.SearchOrdersReq) (*pb.SearchOrde
|
||||
query = query.Where(orders.And(preds...))
|
||||
}
|
||||
|
||||
items, err := query.Offset(int(in.Page * in.Limit)).Limit(int(in.Limit)).All(l.ctx)
|
||||
items, err := query.Offset(int(in.Offset)).Limit(int(in.Limit)).All(l.ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc v6.33.5
|
||||
// protoc v7.34.1
|
||||
// source: order.proto
|
||||
|
||||
package pb
|
||||
@@ -788,7 +788,7 @@ func (x *GetOrdersByIdResp) GetOrders() *Orders {
|
||||
|
||||
type SearchOrdersReq 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,oneof" json:"id,omitempty"` //id
|
||||
ConsumerId *int64 `protobuf:"varint,4,opt,name=consumerId,proto3,oneof" json:"consumerId,omitempty"` //consumerId
|
||||
@@ -841,9 +841,9 @@ func (*SearchOrdersReq) Descriptor() ([]byte, []int) {
|
||||
return file_order_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
func (x *SearchOrdersReq) GetPage() int64 {
|
||||
func (x *SearchOrdersReq) GetOffset() int64 {
|
||||
if x != nil {
|
||||
return x.Page
|
||||
return x.Offset
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -1585,7 +1585,7 @@ func (x *GetOrderStateLogsByIdResp) GetOrderStateLogs() *OrderStateLogs {
|
||||
|
||||
type SearchOrderStateLogsReq 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,oneof" json:"id,omitempty"` //id
|
||||
OrderId *int64 `protobuf:"varint,4,opt,name=orderId,proto3,oneof" json:"orderId,omitempty"` //orderId
|
||||
@@ -1630,9 +1630,9 @@ func (*SearchOrderStateLogsReq) Descriptor() ([]byte, []int) {
|
||||
return file_order_proto_rawDescGZIP(), []int{20}
|
||||
}
|
||||
|
||||
func (x *SearchOrderStateLogsReq) GetPage() int64 {
|
||||
func (x *SearchOrderStateLogsReq) GetOffset() int64 {
|
||||
if x != nil {
|
||||
return x.Page
|
||||
return x.Offset
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -1890,9 +1890,9 @@ const file_order_proto_rawDesc = "" +
|
||||
"\x02id\x18\x01 \x01(\x03R\x02id\"7\n" +
|
||||
"\x11GetOrdersByIdResp\x12\"\n" +
|
||||
"\x06orders\x18\x01 \x01(\v2\n" +
|
||||
".pb.OrdersR\x06orders\"\xed\x06\n" +
|
||||
"\x0fSearchOrdersReq\x12\x12\n" +
|
||||
"\x04page\x18\x01 \x01(\x03R\x04page\x12\x14\n" +
|
||||
".pb.OrdersR\x06orders\"\xf1\x06\n" +
|
||||
"\x0fSearchOrdersReq\x12\x16\n" +
|
||||
"\x06offset\x18\x01 \x01(\x03R\x06offset\x12\x14\n" +
|
||||
"\x05limit\x18\x02 \x01(\x03R\x05limit\x12\x13\n" +
|
||||
"\x02id\x18\x03 \x01(\x03H\x00R\x02id\x88\x01\x01\x12#\n" +
|
||||
"\n" +
|
||||
@@ -2006,9 +2006,9 @@ const file_order_proto_rawDesc = "" +
|
||||
"\x18GetOrderStateLogsByIdReq\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\x03R\x02id\"W\n" +
|
||||
"\x19GetOrderStateLogsByIdResp\x12:\n" +
|
||||
"\x0eorderStateLogs\x18\x01 \x01(\v2\x12.pb.OrderStateLogsR\x0eorderStateLogs\"\xcf\x03\n" +
|
||||
"\x17SearchOrderStateLogsReq\x12\x12\n" +
|
||||
"\x04page\x18\x01 \x01(\x03R\x04page\x12\x14\n" +
|
||||
"\x0eorderStateLogs\x18\x01 \x01(\v2\x12.pb.OrderStateLogsR\x0eorderStateLogs\"\xd3\x03\n" +
|
||||
"\x17SearchOrderStateLogsReq\x12\x16\n" +
|
||||
"\x06offset\x18\x01 \x01(\x03R\x06offset\x12\x14\n" +
|
||||
"\x05limit\x18\x02 \x01(\x03R\x05limit\x12\x13\n" +
|
||||
"\x02id\x18\x03 \x01(\x03H\x00R\x02id\x88\x01\x01\x12\x1d\n" +
|
||||
"\aorderId\x18\x04 \x01(\x03H\x01R\aorderId\x88\x01\x01\x12#\n" +
|
||||
|
||||
Reference in New Issue
Block a user