修复编译问题和版本兼容问题
This commit is contained in:
@@ -3,10 +3,12 @@ package service
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudprint/cloudprint-backend/internal/model"
|
||||
"github.com/cloudprint/cloudprint-backend/internal/service"
|
||||
pb "github.com/cloudprint/cloudprint-backend/proto/generated"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
type OrderServiceServer struct {
|
||||
@@ -57,7 +59,7 @@ func (s *OrderServiceServer) GetOrder(ctx context.Context, req *pb.GetOrderReque
|
||||
}
|
||||
|
||||
func (s *OrderServiceServer) GetOrderList(ctx context.Context, req *pb.GetOrderListRequest) (*pb.OrderListResponse, error) {
|
||||
orders, total, err := s.orderService.GetOrderList(ctx, req.UserId, req.Status, int(req.Page), int(req.PageSize))
|
||||
orders, total, err := s.orderService.GetOrderList(ctx, req.UserId, int8(req.Status), int(req.Page), int(req.PageSize))
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "get order list failed: %v", err)
|
||||
}
|
||||
@@ -91,8 +93,17 @@ func (s *OrderServiceServer) CancelOrder(ctx context.Context, req *pb.CancelOrde
|
||||
return &pb.Empty{}, nil
|
||||
}
|
||||
|
||||
func convertOrderToPB(order *service.Order) *pb.Order {
|
||||
// Note: This is a simplified conversion. In production, you would need to handle all fields properly.
|
||||
// The service.Order type here is the model, not the protobuf type.
|
||||
return nil // Placeholder
|
||||
func convertOrderToPB(order *model.Order) *pb.Order {
|
||||
if order == nil {
|
||||
return nil
|
||||
}
|
||||
return &pb.Order{
|
||||
Id: order.ID,
|
||||
OrderNo: order.OrderNo,
|
||||
UserId: order.UserID,
|
||||
Status: int32(order.Status),
|
||||
TotalAmount: order.TotalAmount,
|
||||
Remark: order.Remark,
|
||||
CreatedAt: timestamppb.New(order.CreatedAt),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user