P11.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. package query
  2. import (
  3. "context"
  4. "gd_adm_data/apis"
  5. "gd_adm_data/errors"
  6. jsoniter "github.com/json-iterator/go"
  7. "gorm.io/gorm"
  8. "git.getensh.com/common/gopkgsv2/database"
  9. )
  10. type p11Request struct {
  11. Vin string `json:"vin"`
  12. }
  13. type p11Response struct {
  14. Vin string `json:"vin"`
  15. SySeriesId string `json:"sy_series_id"`
  16. VehicleSeries string `json:"vehicle_series"`
  17. SyStyleId string `json:"sy_style_id"`
  18. VehicleStyle string `json:"vehicle_style"`
  19. VehicleBrand string `json:"vehicle_brand"`
  20. VehicleConfigDetail string `json:"vehicle_config_detail"`
  21. BodyStruct string `json:"body_struct"`
  22. BrandId string `json:"brand_id"`
  23. BrandName string `json:"brand_name"`
  24. SeriesId string `json:"series_id"`
  25. SeriesName string `json:"series_name"`
  26. StyleId string `json:"style_id"`
  27. StyleName string `json:"style_name"`
  28. ModelYear string `json:"model_year"`
  29. AutoPrice string `json:"auto_price"`
  30. DriveWay string `json:"drive_way"`
  31. EngineNo string `json:"engine_no"`
  32. EngineType string `json:"engine_type"`
  33. BodyColorDetail string `json:"body_color_detail"`
  34. ReleaseDate string `json:"release_date"`
  35. EmissionStandard string `json:"emission_standard"`
  36. ApprovedLoad string `json:"approved_load"`
  37. ApprovedNumber string `json:"approved_number"`
  38. AxleNumber string `json:"axle_number"`
  39. FrontWheelDistance string `json:"front_wheel_distance"`
  40. BackWheelDistance string `json:"back_wheel_distance"`
  41. Displacement string `json:"displacement"`
  42. DisplacementL string `json:"displacement_l"`
  43. AirIntakForm string `json:"air_intak_form"`
  44. FuelTypeDetail string `json:"fuel_type_detail"`
  45. High string `json:"high"`
  46. Wide string `json:"wide"`
  47. Long string `json:"long"`
  48. GrossMass string `json:"gross_mass"`
  49. ModelNo string `json:"model_no"`
  50. OilWear string `json:"oil_wear"`
  51. RatedPower string `json:"rated_power"`
  52. TractionMass string `json:"traction_mass"`
  53. TyreNumber string `json:"tyre_number"`
  54. TyreSize string `json:"tyre_size"`
  55. UnladenMass string `json:"unladen_mass"`
  56. WheelBase string `json:"wheel_base"`
  57. VehicleTypeDetail string `json:"vehicle_type_detail"`
  58. }
  59. func P11(ctx context.Context, params string) (reply *apis.QueryResponse, err error) {
  60. reply = &apis.QueryResponse{}
  61. var req p11Request
  62. err = jsoniter.UnmarshalFromString(params, &req)
  63. if err != nil || len(req.Vin) == 0 {
  64. return nil, errors.ParamsError
  65. }
  66. sql := "SELECT * FROM v_adm_vin_style WHERE vin = ?"
  67. var p11resp p11Response
  68. err = database.DB().Raw(sql, req.Vin).Find(&p11resp).Error
  69. if err != nil {
  70. if err == gorm.ErrRecordNotFound {
  71. return reply, errors.DataNotExistError
  72. }
  73. return reply, errors.SystemError
  74. }
  75. p11str, _ := jsoniter.MarshalToString(p11resp)
  76. p11Map := make(map[string]interface{})
  77. jsoniter.Unmarshal([]byte(p11str), &p11Map)
  78. //formatData(p11Map)
  79. reply.Data, _ = jsoniter.MarshalToString(p11Map)
  80. /*response := p11Response{}
  81. err = jsoniter.UnmarshalFromString(reply.Data, &response)
  82. err = insertTable("P11", "VIN唯一定型", "32,35,37,38,51", req, response)
  83. if err != nil {
  84. return nil, err
  85. }*/
  86. return reply, nil
  87. }