课程名称:多端全栈项目实战:商业级代驾全流程落地
课程章节: 华夏代驾全栈小程序实战
课程讲师: 神思者
课程内容:
前端实时上传gps定位
课程收获:
昨天添加了五个参数 所以要编写form类
@Data@Schema(description = "查询符合某个订单接单的司机列表的表单")public class SearchBefittingDriverAboutOrderForm { @NotBlank(message = "startPlaceLatitude不能为空") @Pattern(regexp = "^(([1-8]\\d?)|([1-8]\\d))(\\.\\d{1,18})|90|0(\\.\\d{1,18})?$", message = "startPlaceLatitude内容不正确") @Schema(description = "订单起点的纬度") private String startPlaceLatitude; @NotBlank(message = "startPlaceLongitude不能为空") @Pattern(regexp = "^(([1-9]\\d?)|(1[0-7]\\d))(\\.\\d{1,18})|180|0(\\.\\d{1,18})?$", message = "startPlaceLongitude内容不正确") @Schema(description = "订单起点的经度") private String startPlaceLongitude; @NotBlank(message = "endPlaceLatitude不能为空") @Pattern(regexp = "^(([1-8]\\d?)|([1-8]\\d))(\\.\\d{1,18})|90|0(\\.\\d{1,18})?$", message = "endPlaceLatitude内容不正确") @Schema(description = "订单终点的纬度") private String endPlaceLatitude; @NotBlank(message = "endPlaceLongitude不能为空") @Pattern(regexp = "^(([1-9]\\d?)|(1[0-7]\\d))(\\.\\d{1,18})|180|0(\\.\\d{1,18})?$", message = "endPlaceLongitude内容不正确") @Schema(description = "订单起点的经度") private String endPlaceLongitude; @NotBlank(message = "mileage不能为空") @Pattern(regexp = "^[1-9]\\d*\\.\\d+$|^0\\.\\d*[1-9]\\d*$|^[1-9]\\d*$", message = "mileage内容不正确") @Schema(description = "预估里程") private String mileage;}
分别是上车点得定位,下车点得定位,还有预估里程
因为form里面得经纬度是字符串类型得,所以我们需要在controller里面将他转换成bouble
所以要进行数据类型得转换
double startPlaceLatitude = Double.parseDouble(form.getStartPlaceLatitude());
double startPlaceLongitude = Double.parseDouble(form.getStartPlaceLongitude());
double endPlaceLatitude = Double.parseDouble(form.getEndPlaceLatitude());
double endPlaceLongitude = Double.parseDouble(form.getEndPlaceLongitude());
double mileage = Double.parseDouble(form.getMileage());
@PostMapping("/searchBefittingDriverAboutOrder") @Operation(summary = "查询符合某个订单接单的司机列表") public R searchBefittingDriverAboutOrder(@RequestBody @Valid SearchBefittingDriverAboutOrderForm form) { double startPlaceLatitude = Double.parseDouble(form.getStartPlaceLatitude()); double startPlaceLongitude = Double.parseDouble(form.getStartPlaceLongitude()); double endPlaceLatitude = Double.parseDouble(form.getEndPlaceLatitude()); double endPlaceLongitude = Double.parseDouble(form.getEndPlaceLongitude()); double mileage = Double.parseDouble(form.getMileage()); ArrayList list = driverLocationService.searchBefittingDriverAboutOrder(startPlaceLatitude, startPlaceLongitude, endPlaceLatitude, endPlaceLongitude, mileage); return R.ok().put("result", list); }
接下来就需要打开所有得后端项目包,在司机小程序上进行登录,同时保持上传实际得gps
通过fastRequset进行测试