mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-22 23:35:26 +00:00
Fix panic in vehicle service (#226)
* fix panic * Commit from GitHub Actions (Publish APIs & Clients) Co-authored-by: domwong <domwong@users.noreply.github.com>
This commit is contained in:
@@ -65,5 +65,5 @@
|
|||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"version": "1.0.542"
|
"version": "1.0.543"
|
||||||
}
|
}
|
||||||
@@ -11,10 +11,10 @@ func CreateArecord() {
|
|||||||
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
|
||||||
rsp, err := dbService.Create(&db.CreateRequest{
|
rsp, err := dbService.Create(&db.CreateRequest{
|
||||||
Record: map[string]interface{}{
|
Record: map[string]interface{}{
|
||||||
"age": 42,
|
|
||||||
"isActive": true,
|
"isActive": true,
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"name": "Jane",
|
"name": "Jane",
|
||||||
|
"age": 42,
|
||||||
},
|
},
|
||||||
Table: "users",
|
Table: "users",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ func PublishAmessage() {
|
|||||||
streamService := stream.NewStreamService(os.Getenv("MICRO_API_TOKEN"))
|
streamService := stream.NewStreamService(os.Getenv("MICRO_API_TOKEN"))
|
||||||
rsp, err := streamService.Publish(&stream.PublishRequest{
|
rsp, err := streamService.Publish(&stream.PublishRequest{
|
||||||
Message: map[string]interface{}{
|
Message: map[string]interface{}{
|
||||||
|
"id": "1",
|
||||||
"type": "signup",
|
"type": "signup",
|
||||||
"user": "john",
|
"user": "john",
|
||||||
"id": "1",
|
|
||||||
},
|
},
|
||||||
Topic: "events",
|
Topic: "events",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package handler
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/micro/services/pkg/api"
|
|
||||||
"github.com/micro/micro/v3/service/errors"
|
"github.com/micro/micro/v3/service/errors"
|
||||||
"github.com/micro/micro/v3/service/logger"
|
"github.com/micro/micro/v3/service/logger"
|
||||||
|
"github.com/micro/services/pkg/api"
|
||||||
pb "github.com/micro/services/vehicle/proto"
|
pb "github.com/micro/services/vehicle/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ var (
|
|||||||
apiURL = "https://driver-vehicle-licensing.api.gov.uk/vehicle-enquiry/v1/vehicles"
|
apiURL = "https://driver-vehicle-licensing.api.gov.uk/vehicle-enquiry/v1/vehicles"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Vehicle struct{
|
type Vehicle struct {
|
||||||
Key string
|
Key string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,26 +39,27 @@ func (v *Vehicle) Lookup(ctx context.Context, req *pb.LookupRequest, rsp *pb.Loo
|
|||||||
return errors.InternalServerError("vehicle.lookup", "Failed to lookup vehicle")
|
return errors.InternalServerError("vehicle.lookup", "Failed to lookup vehicle")
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp.Registration = resp["registrationNumber"].(string)
|
rsp.Registration, _ = resp["registrationNumber"].(string)
|
||||||
rsp.Make = resp["make"].(string)
|
rsp.Make, _ = resp["make"].(string)
|
||||||
rsp.Co2Emissions = resp["co2Emissions"].(float64)
|
rsp.Co2Emissions, _ = resp["co2Emissions"].(float64)
|
||||||
rsp.Colour = resp["colour"].(string)
|
rsp.Colour, _ = resp["colour"].(string)
|
||||||
rsp.YearOfManufacture = int32(resp["yearOfManufacture"].(float64))
|
yom, _ := resp["yearOfManufacture"].(float64)
|
||||||
rsp.EngineCapacity = int32(resp["engineCapacity"].(float64))
|
rsp.YearOfManufacture = int32(yom)
|
||||||
rsp.FuelType = resp["fuelType"].(string)
|
ec, _ := resp["engineCapacity"].(float64)
|
||||||
rsp.MonthOfFirstRegistration = resp["monthOfFirstRegistration"].(string)
|
rsp.EngineCapacity = int32(ec)
|
||||||
rsp.MotStatus = resp["motStatus"].(string)
|
rsp.FuelType, _ = resp["fuelType"].(string)
|
||||||
|
rsp.MonthOfFirstRegistration, _ = resp["monthOfFirstRegistration"].(string)
|
||||||
|
rsp.MotStatus, _ = resp["motStatus"].(string)
|
||||||
|
|
||||||
if v := resp["motExpiryDate"]; v != nil {
|
if v := resp["motExpiryDate"]; v != nil {
|
||||||
rsp.MotExpiry = v.(string)
|
rsp.MotExpiry, _ = v.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp.TaxDueDate = resp["taxDueDate"].(string)
|
rsp.TaxDueDate, _ = resp["taxDueDate"].(string)
|
||||||
rsp.TaxStatus = resp["taxStatus"].(string)
|
rsp.TaxStatus, _ = resp["taxStatus"].(string)
|
||||||
rsp.TypeApproval = resp["typeApproval"].(string)
|
rsp.TypeApproval, _ = resp["typeApproval"].(string)
|
||||||
rsp.Wheelplan = resp["wheelplan"].(string)
|
rsp.Wheelplan, _ = resp["wheelplan"].(string)
|
||||||
rsp.LastV5Issued = resp["dateOfLastV5CIssued"].(string)
|
rsp.LastV5Issued, _ = resp["dateOfLastV5CIssued"].(string)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user