123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- package style
- import (
- "context"
- "encoding/json"
- "fmt"
- "adm-vehicle-style/errors"
- "adm-vehicle-style/model"
- v1 "adm-vehicle-style/pb/v1"
- "git.getensh.com/common/gopkgsv2/database"
- "git.getensh.com/common/gopkgsv2/logger"
- "go.uber.org/zap"
- "google.golang.org/grpc/status"
- )
- func Info(ctx context.Context, req *v1.StyleInfoRequest) (reply *v1.StyleInfoReply, err error) {
- reply = &v1.StyleInfoReply{}
- // 捕获各个task中的异常并返回给调用者
- defer func() {
- if r := recover(); r != nil {
- err = fmt.Errorf("%+v", r)
- e := &status.Status{}
- if er := json.Unmarshal([]byte(err.Error()), e); er != nil {
- logger.Error("err",
- zap.String("system_err", err.Error()),
- zap.Stack("stacktrace"))
- }
- }
- }()
- res, err := model.NewSyStyleModel().Get(database.DB().Where("id = ?", req.Id))
- if err != nil {
- return reply, errors.SystemError
- }
- reply.Aircondition = &v1.StyleInfoReply_Aircondition{
- AirconditionControlType: res.AirconditionControlType,
- CarAirPurifier: res.CarAirPurifier,
- FragranceSystem: res.FragranceSystem,
- NegativeIonGenerator: res.NegativeIonGenerator,
- Pm25Device: res.Pm25Device,
- RearIndependentAirConditioner: res.RearIndependentAirConditioner,
- RearSeatAirOutlet: res.RearSeatAirOutlet,
- Refrigerator: res.Refrigerator,
- TemperatureZoneControl: res.TemperatureZoneControl,
- }
- reply.Basic = &v1.StyleInfoReply_Basic{
- BrandId: res.BrandId,
- Alternator: res.Alternator,
- BrakingDistanceMeasure: res.BrakingDistanceMeasure,
- BrandName: res.BrandName,
- EmissionStandard: res.EmissionStandard,
- Engine: res.Engine,
- FastChargeAmount: res.FastChargeAmount,
- FastChargingTime: res.FastChargingTime,
- FuelTypeDetail: res.FuelTypeDetail,
- GearboxDesc: res.GearboxDesc,
- HundredAccelerate: res.HundredAccelerate,
- HundredAccelerateMeasure: res.HundredAccelerateMeasure,
- Level: res.Level,
- Lwh: res.Lwh,
- Maker: res.Maker,
- MaximumPower: res.MaximumPower,
- MaximumSimulationMilage: res.MaximumSimulationMilage,
- MaximumSimulationMilageMeasure: res.MaximumSimulationMilageMeasure,
- MaximumSpeed: res.MaximumSpeed,
- MaximumTorque: res.MaximumTorque,
- ModelYear: res.ModelYear,
- OilWearComrehensive: res.OilWearComrehensive,
- OilWearMeasure: res.OilWearMeasure,
- Price: res.Price,
- PriceYuan: res.PriceYuan,
- SeriesId: res.SeriesId,
- SeriesName: res.SeriesName,
- SlowChargingTime: res.SlowChargingTime,
- StyleId: res.StyleId,
- StyleName: res.StyleName,
- SubLevel: res.SubLevel,
- VehicleStructure: res.VehicleStructure,
- VehicleWarranty: res.VehicleWarranty,
- }
- reply.Body = &v1.StyleInfoReply_Body{
- BackWheelDistance: res.BackWheelDistance,
- DoorNumber: res.DoorNumber,
- FrontWheelDistance: res.FrontWheelDistance,
- High: res.High,
- Long: res.Long,
- MinimumGroundClearance: res.MinimumGroundClearance,
- OilboxVolume: res.OilboxVolume,
- SeatNumber: res.SeatNumber,
- TrunkVolume: res.TrunkVolume,
- UnladenMass: res.UnladenMass,
- Wheelbase: res.Wheelbase,
- Wide: res.Wide,
- }
- reply.Chassis = &v1.StyleInfoReply_Chassis{
- AssistType: res.AssistType,
- BackSuspentionType: res.BackSuspentionType,
- BodyStructure: res.BodyStructure,
- DriveType: res.DriveType,
- FrontSuspentionType: res.FrontSuspentionType,
- }
- reply.Control = &v1.StyleInfoReply_Control{
- AirSuspension: res.AirSuspension,
- AscentAssist: res.AscentAssist,
- AutoHold: res.AutoHold,
- AutomaticDrivingAssistance: res.AutomaticDrivingAssistance,
- AutomaticParking: res.AutomaticParking,
- BackParkingRador: res.BackParkingRador,
- CentralDiffLock: res.CentralDiffLock,
- CruiseSystem: res.CruiseSystem,
- DrivingModeSelection: res.DrivingModeSelection,
- EInductionSuspension: res.EInductionSuspension,
- Edl: res.Edl,
- EngineStartStopTechnology: res.EngineStartStopTechnology,
- FrontParkingRador: res.FrontParkingRador,
- Hdc: res.Hdc,
- OverallActiveSteeringSystem: res.OverallActiveSteeringSystem,
- ReverseVehicleSideWarningSystem: res.ReverseVehicleSideWarningSystem,
- VariableSteeringRatio: res.VariableSteeringRatio,
- VariableSuspension: res.VariableSuspension,
- WadeSensingSystem: res.WadeSensingSystem,
- }
- reply.Electric = &v1.StyleInfoReply_Electric{
- BackElectricMaximumPower: res.BackElectricMaximumPower,
- BackElectricTorque: res.BackElectricTorque,
- BatteryEnergy: res.BatteryEnergy,
- BatteryPackWarranty: res.BatteryPackWarranty,
- BatteryType: res.BatteryType,
- FrontElectricMaximumPower: res.FrontElectricMaximumPower,
- FrontElectricTorque: res.FrontElectricTorque,
- HundredElectricityConsumption: res.HundredElectricityConsumption,
- MaximumSimulationMilage: res.MaximumSimulationMilage,
- MotorLayout: res.MotorLayout,
- MotorNumber: res.MotorNumber,
- MotorType: res.MotorType,
- SystemIntegratedPower: res.SystemIntegratedPower,
- SystemIntegratedTorque: res.SystemIntegratedTorque,
- TotalMotorPower: res.TotalMotorPower,
- TotalMotorTorque: res.TotalMotorTorque,
- }
- reply.Engine = &v1.StyleInfoReply_Engine{
- AirIntakForm: res.AirIntakForm,
- CylinderArrangement: res.CylinderArrangement,
- CylinderDiameter: res.CylinderDiameter,
- CylinderHeadMaterial: res.CylinderHeadMaterial,
- CylinderMaterial: res.CylinderMaterial,
- CylinderNumber: res.CylinderNumber,
- CylinderValveNumber: res.CylinderValveNumber,
- Displacement: res.Displacement,
- DisplacementL: res.DisplacementL,
- EngineTechnology: res.EngineTechnology,
- EngineType: res.EngineType,
- FuelLable: res.FuelLable,
- FuelTypeDetail: res.FuelTypeDetail,
- MaximumHorsepower: res.MaximumHorsepower,
- MaximumPowerRpm: res.MaximumPowerRpm,
- OilSupplyMode: res.OilSupplyMode,
- PistonStroke: res.PistonStroke,
- ReductionRatio: res.ReductionRatio,
- Rpm: res.Rpm,
- ValveMechanism: res.ValveMechanism,
- }
- reply.External = &v1.StyleInfoReply_External{
- ActiveIntakeGrille: res.ActiveIntakeGrille,
- BatteryPreHeating: res.BatteryPreHeating,
- CentralControlLock: res.CentralControlLock,
- ElectricTrunk: res.ElectricTrunk,
- ElectronicAntiTheft: res.ElectronicAntiTheft,
- Eosd: res.Eosd,
- FramelessDesignDoor: res.FramelessDesignDoor,
- HideElectricDoorHandle: res.HideElectricDoorHandle,
- InductiveTrunk: res.InductiveTrunk,
- KeyType: res.KeyType,
- KeylessEntrySystem: res.KeylessEntrySystem,
- KeylessStartSystem: res.KeylessStartSystem,
- OutsidePedal: res.OutsidePedal,
- RearCompartmentPositionMemory: res.RearCompartmentPositionMemory,
- RemoteStart: res.RemoteStart,
- RimMaterial: res.RimMaterial,
- RoofLuggageRack: res.RoofLuggageRack,
- SideSlidingDoor: res.SideSlidingDoor,
- SkylightType: res.SkylightType,
- SportsAppearanceKit: res.SportsAppearanceKit,
- Tail: res.Tail,
- TheTailgateGlassOpensIndependently: res.TheTailgateGlassOpensIndependently,
- }
- reply.Gearbox = &v1.StyleInfoReply_Gearbox{
- GearNumber: res.GearNumber,
- GearboxDesc: res.GearboxDesc,
- GearboxType: res.GearboxType,
- }
- reply.Internal = &v1.StyleInfoReply_Internal{
- ActiveNoiseReduction: res.ActiveNoiseReduction,
- CarDrivingRecorder: res.CarDrivingRecorder,
- DrivingComputerDisplay: res.DrivingComputerDisplay,
- ElectricallyAdjustablePedal: res.ElectricallyAdjustablePedal,
- FullLcdDashboard: res.FullLcdDashboard,
- FullLcdDashboardSize: res.FullLcdDashboardSize,
- HudRisingNumberDisplay: res.HudRisingNumberDisplay,
- MobilePhoneWirelessCharging: res.MobilePhoneWirelessCharging,
- MultiFunctionalSteeringWheel: res.MultiFunctionalSteeringWheel,
- SteeringWheelAdjustment: res.SteeringWheelAdjustment,
- SteeringWheelHeating: res.SteeringWheelHeating,
- SteeringWheelMaterial: res.SteeringWheelMaterial,
- SteeringWheelRemember: res.SteeringWheelRemember,
- SteeringWheelShift: res.SteeringWheelShift,
- }
- reply.Light = &v1.StyleInfoReply_Light{
- AdaptiveFarNear: res.AdaptiveFarNear,
- Atmosphere: res.Atmosphere,
- AutoHead: res.AutoHead,
- Clean: res.Clean,
- Daytime: res.Daytime,
- Far: res.Far,
- Fog: res.Fog,
- HeadlampDelayOff: res.HeadlampDelayOff,
- HeadlampRainFogMode: res.HeadlampRainFogMode,
- HeightAdjustable: res.HeightAdjustable,
- LightingFeatures: res.LightingFeatures,
- Near: res.Near,
- SideTurn: res.SideTurn,
- SteeringAssistLamp: res.SteeringAssistLamp,
- TouchReadingLamp: res.TouchReadingLamp,
- }
- reply.Media = &v1.StyleInfoReply_Media{
- BackLcd: res.BackLcd,
- CarInternet: res.CarInternet,
- CarPhone: res.CarPhone,
- CarTv: res.CarTv,
- CdDvd: res.CdDvd,
- CenterConsoleLargeScreenSize: res.CenterConsoleLargeScreenSize,
- CentralColourScreen: res.CentralColourScreen,
- CentralLcdSplitScreen: res.CentralLcdSplitScreen,
- ChargingInterface: res.ChargingInterface,
- FaceRecognition: res.FaceRecognition,
- GestureControl: res.GestureControl,
- Gps: res.Gps,
- InterfaceOf12V: res.InterfaceOf12v,
- MobileInternet: res.MobileInternet,
- NavigationTrafficInformationDisplay: res.NavigationTrafficInformationDisplay,
- NumberOfInterfaces: res.NumberOfInterfaces,
- Ota: res.Ota,
- PowerOf220V: res.PowerOf220v,
- RearControlMultimedia: res.RearControlMultimedia,
- RoadRescueCall: res.RoadRescueCall,
- SpeakerBrand: res.SpeakerBrand,
- SpeakerNumber: res.SpeakerNumber,
- VoiceControl: res.VoiceControl,
- }
- reply.Optional = &v1.StyleInfoReply_Optional{
- BodyColour: res.BodyColour,
- InteriorColor: res.InteriorColor,
- }
- reply.Rearview = &v1.StyleInfoReply_Rearview{
- AntiPinchHand: res.AntiPinchHand,
- BackElectricWindow: res.BackElectricWindow,
- BackSidePrivacy: res.BackSidePrivacy,
- BackSideSunshade: res.BackSideSunshade,
- BackSunshade: res.BackSunshade,
- BackWiper: res.BackWiper,
- Cosmetic: res.Cosmetic,
- ExteriorRearviewMirrorFunction: res.ExteriorRearviewMirrorFunction,
- FrontElectricWindow: res.FrontElectricWindow,
- FrontWiper: res.FrontWiper,
- HeatableSprayNozzle: res.HeatableSprayNozzle,
- InteriorRearviewMirrorFunction: res.InteriorRearviewMirrorFunction,
- MultilayerSoundInsulationGlass: res.MultilayerSoundInsulationGlass,
- WindowOneKey: res.WindowOneKey,
- }
- reply.Safety = &v1.StyleInfoReply_Safety{
- Abs: res.Abs,
- ActiveBrake: res.ActiveBrake,
- AsrTcsTrc: res.AsrTcsTrc,
- AuxiliarySeatAirbag: res.AuxiliarySeatAirbag,
- BackBeltAirbag: res.BackBeltAirbag,
- BackHeadAirbag: res.BackHeadAirbag,
- BackSideAirbag: res.BackSideAirbag,
- EbaBasBa: res.EbaBasBa,
- EbdCbc: res.EbdCbc,
- Esp: res.Esp,
- FatigueDrivingWarning: res.FatigueDrivingWarning,
- FontHeadAirbag: res.FontHeadAirbag,
- FrontMiddleAirbag: res.FrontMiddleAirbag,
- FrontSideAirbag: res.FrontSideAirbag,
- IsoFix: res.IsoFix,
- KneeAirbag: res.KneeAirbag,
- LaneDepartureWarningSystem: res.LaneDepartureWarningSystem,
- LaneKeeping: res.LaneKeeping,
- MainSeatAirbag: res.MainSeatAirbag,
- NightVision: res.NightVision,
- ParallelAuxiliary: res.ParallelAuxiliary,
- PassengerSeatCushionAirbag: res.PassengerSeatCushionAirbag,
- PassivePedestrianProtection: res.PassivePedestrianProtection,
- RearCentralAirbag: res.RearCentralAirbag,
- RearSeatAntiSlideAirbag: res.RearSeatAntiSlideAirbag,
- RoadTrafficSignRecognition: res.RoadTrafficSignRecognition,
- RunFlatTire: res.RunFlatTire,
- SeatBeltWarning: res.SeatBeltWarning,
- TirePresureMonitor: res.TirePresureMonitor,
- }
- reply.Seat = &v1.StyleInfoReply_Seat{
- AuxiliaryAdjustableButton: res.AuxiliaryAdjustableButton,
- AuxiliaryElectricAdust: res.AuxiliaryElectricAdust,
- AuxiliarySeatAdjustmentMode: res.AuxiliarySeatAdjustmentMode,
- BackCupHolder: res.BackCupHolder,
- BackDownType: res.BackDownType,
- BackFoldTable: res.BackFoldTable,
- BackHandrail: res.BackHandrail,
- ElectricSeatRemeber: res.ElectricSeatRemeber,
- FrontHandrail: res.FrontHandrail,
- FrontSeatFunction: res.FrontSeatFunction,
- HeatingCoolingCupHolder: res.HeatingCoolingCupHolder,
- MainElectricAdust: res.MainElectricAdust,
- MainSeatAdjustmentMode: res.MainSeatAdjustmentMode,
- RearSeatElectricAdjustment: res.RearSeatElectricAdjustment,
- RearSeatFunction: res.RearSeatFunction,
- RearSeatPowerDown: res.RearSeatPowerDown,
- SeatLayoutForm: res.SeatLayoutForm,
- SeatMaterial: res.SeatMaterial,
- SecondIndependent: res.SecondIndependent,
- SecondRowSeatAdjustment: res.SecondRowSeatAdjustment,
- SportSeat: res.SportSeat,
- }
- reply.Wheelbrake = &v1.StyleInfoReply_Wheelbrake{
- BackBrakeType: res.BackBrakeType,
- BackWheelSpecification: res.BackWheelSpecification,
- FrontBrakeType: res.FrontBrakeType,
- FrontWheelSpecification: res.FrontWheelSpecification,
- ParkingBrakeType: res.ParkingBrakeType,
- SpareWheelSpecification: res.SpareWheelSpecification,
- }
- return reply, nil
- }
|