修复编译问题和版本兼容问题
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"net"
|
||||
|
||||
"github.com/cloudprint/cloudprint-backend/internal/grpc/interceptor"
|
||||
pb "github.com/cloudprint/cloudprint-backend/proto/generated"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
)
|
||||
@@ -45,7 +44,7 @@ func (s *Server) Start() error {
|
||||
}
|
||||
|
||||
s.grpcServer = grpc.NewServer(
|
||||
grpc.UnaryInterceptor(interceptor.AuthInterceptor{}.UnaryServerInterceptor()),
|
||||
grpc.UnaryInterceptor((&interceptor.AuthInterceptor{}).UnaryServerInterceptor()),
|
||||
)
|
||||
|
||||
// Register reflection service for debugging
|
||||
|
||||
@@ -58,11 +58,11 @@ func (s *AdminServiceServer) GetStatistics(ctx context.Context, req *pb.GetStati
|
||||
}
|
||||
|
||||
return &pb.Statistics{
|
||||
TotalUsers: totalUsers,
|
||||
TotalOrders: totalOrders,
|
||||
TodayOrders: todayOrders,
|
||||
TotalUsers: int32(totalUsers),
|
||||
TotalOrders: int32(totalOrders),
|
||||
TodayOrders: int32(todayOrders),
|
||||
TodayRevenue: todayRevenue,
|
||||
PendingOrders: pendingOrders,
|
||||
PendingOrders: int32(pendingOrders),
|
||||
ActivePrinters: int32(activePrinters),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ func NewFileServiceServer(fileService *service.FileService) *FileServiceServer {
|
||||
func (s *FileServiceServer) Upload(stream pb.FileService_UploadServer) (*pb.UploadResponse, error) {
|
||||
var fileName, fileType, uploaderType string
|
||||
var uploaderID int32
|
||||
var totalSize int64
|
||||
var chunks [][]byte
|
||||
|
||||
for {
|
||||
@@ -41,7 +40,6 @@ func (s *FileServiceServer) Upload(stream pb.FileService_UploadServer) (*pb.Uplo
|
||||
fileType = req.FileType
|
||||
uploaderType = "user" // Extract from context in production
|
||||
uploaderID = 1 // Extract from context in production
|
||||
totalSize = req.FileSize
|
||||
}
|
||||
|
||||
chunks = append(chunks, req.Data)
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func NewPayServiceServer(
|
||||
}
|
||||
|
||||
func (s *PayServiceServer) CreateWxPayOrder(ctx context.Context, req *pb.WxPayRequest) (*pb.WxPayResponse, error) {
|
||||
resp, err := s.weChatPay.UnifiedOrder(ctx, req.OrderNo, req.Amount, req.Description, req.Openid, req.ClientIp)
|
||||
resp, err := s.weChatPay.UnifiedOrder(req.OrderNo, req.Amount, req.Description, req.Openid, req.ClientIp)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "create pay order failed: %v", err)
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func (s *PayServiceServer) CreateWxPayOrder(ctx context.Context, req *pb.WxPayRe
|
||||
}
|
||||
|
||||
func (s *PayServiceServer) QueryPayStatus(ctx context.Context, req *pb.QueryPayStatusRequest) (*pb.PayStatusResponse, error) {
|
||||
tradeState, _, err := s.weChatPay.QueryOrder(ctx, req.OrderNo)
|
||||
tradeState, _, err := s.weChatPay.QueryOrder(req.OrderNo)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "query pay status failed: %v", err)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudprint/cloudprint-backend/internal/model"
|
||||
"github.com/cloudprint/cloudprint-backend/internal/repository"
|
||||
pb "github.com/cloudprint/cloudprint-backend/proto/generated"
|
||||
"google.golang.org/grpc/codes"
|
||||
|
||||
Reference in New Issue
Block a user