课程名称:多端全栈项目实战:商业级代驾全流程落地
课程章节: 华夏代驾全栈小程序实战
课程讲师: 神思者
课程内容:
位置服务缓存司机定时定位
课程收获:
上节课写了 更新司机Gps定位缓存 和 删除司机定位缓存
接下来需要调用bff-driver子系统 fegin
首先需要 创建一个form类
用于接收数据
@Data@Schema(description = "更新司机GPS坐标缓存的表单")public class UpdateLocationCacheForm {
@Schema(description = "司机ID")
private Long driverId;
@NotBlank(message = "latitude不能为空")
@Pattern(regexp = "^(([1-8]\\d?)|([1-8]\\d))(\\.\\d{1,18})|90|0(\\.\\d{1,18})?$", message = "latitude内容不正确")
@Schema(description = "纬度")
private String latitude;
@NotBlank(message = "longitude不能为空")
@Pattern(regexp = "^(([1-9]\\d?)|(1[0-7]\\d))(\\.\\d{1,18})|180|0(\\.\\d{1,18})?$", message = "longitude内容不正确")
@Schema(description = "经度")
private String longitude;
@NotNull(message = "rangeDistance不能为空")
@Range(min = 1, max = 5, message = "rangeDistance范围错误")
@Schema(description = "接收几公里内的订单")
private Integer rangeDistance;
@NotNull(message = "orderDistance不能为空")
@Schema(description = "接收代驾里程几公里以上的订单")
@Range(min = 0, max = 30, message = "orderDistance范围错误")
private Integer orderDistance;
@Pattern(regexp = "^(([1-9]\\d?)|(1[0-7]\\d))(\\.\\d{1,18})|180|0(\\.\\d{1,18})?$", message = "orientateLongitude内容不正确")
@Schema(description = "定向接单的经度")
private String orientateLongitude;
@Pattern(regexp = "^(([1-8]\\d?)|([1-8]\\d))(\\.\\d{1,18})|90|0(\\.\\d{1,18})?$", message = "orientateLatitude内容不正确")
@Schema(description = "定向接单的纬度")
private String orientateLatitude;}编写fegin
@PostMapping("/driver/location/updateLocationCache")
public R updateLocationCache(UpdateLocationCacheForm form);
@PostMapping("/driver/location/removeLocationCache")
public R removeLocationCache(RemoveLocationCacheForm form);
编写service.impl
@Override
public void updateLocationCache(UpdateLocationCacheForm form) {
mpsServiceApi.updateLocationCache(form);
}
@Override
public void removeLocationCache(RemoveLocationCacheForm form) {
mpsServiceApi.removeLocationCache(form);
}再接着 就是写controller了 更新司机缓存gps定位
@PostMapping("/updateLocationCache")
@Operation(summary = "更新司机缓存GPS定位")
@SaCheckLogin
public R updateLocationCache(@RequestBody @Valid UpdateLocationCacheForm form) {
long driverId = StpUtil.getLoginIdAsLong();
form.setDriverId(driverId);
locationService.updateLocationCache(form);
return R.ok();
}