jaryhe преди 1 година
родител
ревизия
7021d4fb84
променени са 1 файла, в които са добавени 11 реда и са изтрити 3 реда
  1. 11 3
      impl/v1/query/IS01.go

+ 11 - 3
impl/v1/query/IS01.go

@@ -14,7 +14,9 @@ import (
 )
 
 type is01Request struct {
-	Vin string `json:"vin"`
+	Vin       string `json:"vin"`
+	PlateNo   string `json:"plate_no"`
+	PlateType string `json:"plate_type"`
 }
 
 type is01Response struct {
@@ -30,7 +32,7 @@ func IS01(ctx context.Context, params string) (reply *apis.QueryResponse, err er
 
 	var req is01Request
 	err = jsoniter.UnmarshalFromString(params, &req)
-	if err != nil || req.Vin == "" {
+	if err != nil {
 		return nil, errors.ParamsError
 	}
 
@@ -38,7 +40,13 @@ func IS01(ctx context.Context, params string) (reply *apis.QueryResponse, err er
 
 	db := database.DB()
 
-	err = db.Raw("select insurance_first_date, updated_at, use_property_detail from t_adm_dws6 where vin = ? ", req.Vin).Find(&res).Error
+	if req.Vin != "" {
+		err = db.Raw("select insurance_first_date, updated_at, use_property_detail from t_adm_dws6 where vin = ? ", req.Vin).Find(&res).Error
+	} else if req.PlateNo != "" && req.PlateType != "" {
+		err = db.Raw("select insurance_first_date, updated_at, use_property_detail from t_adm_dws6 where plate_no = ? and plate_type= ? ", req.PlateNo, req.PlateType).Find(&res).Error
+	} else {
+		return nil, errors.ParamsError
+	}
 
 	list, err := model.NewDws8Model().List(database.DB().Where("vin = ?", req.Vin))