123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- package query
- import (
- "context"
- "gd_adm_data/apis"
- "gd_adm_data/errors"
- jsoniter "github.com/json-iterator/go"
- "gorm.io/gorm"
- "git.getensh.com/common/gopkgsv2/database"
- )
- type p11Request struct {
- Vin string `json:"vin"`
- }
- type p11Response struct {
- Vin string `json:"vin"`
- SySeriesId string `json:"sy_series_id"`
- VehicleSeries string `json:"vehicle_series"`
- SyStyleId string `json:"sy_style_id"`
- VehicleStyle string `json:"vehicle_style"`
- VehicleBrand string `json:"vehicle_brand"`
- VehicleConfigDetail string `json:"vehicle_config_detail"`
- BodyStruct string `json:"body_struct"`
- BrandId string `json:"brand_id"`
- BrandName string `json:"brand_name"`
- SeriesId string `json:"series_id"`
- SeriesName string `json:"series_name"`
- StyleId string `json:"style_id"`
- StyleName string `json:"style_name"`
- ModelYear string `json:"model_year"`
- AutoPrice string `json:"auto_price"`
- DriveWay string `json:"drive_way"`
- EngineNo string `json:"engine_no"`
- EngineType string `json:"engine_type"`
- BodyColorDetail string `json:"body_color_detail"`
- ReleaseDate string `json:"release_date"`
- EmissionStandard string `json:"emission_standard"`
- ApprovedLoad string `json:"approved_load"`
- ApprovedNumber string `json:"approved_number"`
- AxleNumber string `json:"axle_number"`
- FrontWheelDistance string `json:"front_wheel_distance"`
- BackWheelDistance string `json:"back_wheel_distance"`
- Displacement string `json:"displacement"`
- DisplacementL string `json:"displacement_l"`
- AirIntakForm string `json:"air_intak_form"`
- FuelTypeDetail string `json:"fuel_type_detail"`
- High string `json:"high"`
- Wide string `json:"wide"`
- Long string `json:"long"`
- GrossMass string `json:"gross_mass"`
- ModelNo string `json:"model_no"`
- OilWear string `json:"oil_wear"`
- RatedPower string `json:"rated_power"`
- TractionMass string `json:"traction_mass"`
- TyreNumber string `json:"tyre_number"`
- TyreSize string `json:"tyre_size"`
- UnladenMass string `json:"unladen_mass"`
- WheelBase string `json:"wheel_base"`
- VehicleTypeDetail string `json:"vehicle_type_detail"`
- }
- func P11(ctx context.Context, params string) (reply *apis.QueryResponse, err error) {
- reply = &apis.QueryResponse{}
- var req p11Request
- err = jsoniter.UnmarshalFromString(params, &req)
- if err != nil || len(req.Vin) == 0 {
- return nil, errors.ParamsError
- }
- sql := "SELECT * FROM v_adm_vin_style WHERE vin = ?"
- var p11resp p11Response
- err = database.DB().Raw(sql, req.Vin).Find(&p11resp).Error
- if err != nil {
- if err == gorm.ErrRecordNotFound {
- return reply, errors.DataNotExistError
- }
- return reply, errors.SystemError
- }
- p11str, _ := jsoniter.MarshalToString(p11resp)
- p11Map := make(map[string]interface{})
- jsoniter.Unmarshal([]byte(p11str), &p11Map)
- //formatData(p11Map)
- reply.Data, _ = jsoniter.MarshalToString(p11Map)
- /*response := p11Response{}
- err = jsoniter.UnmarshalFromString(reply.Data, &response)
- err = insertTable("P11", "VIN唯一定型", "32,35,37,38,51", req, response)
- if err != nil {
- return nil, err
- }*/
- return reply, nil
- }
|