package com.bohuikeji.delivery.backstage.controller.api.courier;


import com.bohuikeji.delivery.backstage.entity.TTrack;
import com.bohuikeji.delivery.backstage.service.ITTrackService;
import com.bohuikeji.frame.module.admin.base.ApiController;
import com.bohuikeji.frame.module.admin.entity.back.APIEntity;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * 派送员跟踪记录
 */
@Api(tags = {"派送员跟踪记录相关接口"})
@RestController
@RequestMapping("/api/track")
public class TrackApi extends ApiController {

    @Autowired
    ITTrackService trackService;

    /**
     * 获取经纬度生成派送员跟踪记录
     * @return
     */
    @ApiOperation("派送端:获取经纬度生成派送员跟踪记录")
    @PostMapping("/saveTrack")
    @ApiOperationSupport(ignoreParameters = {"id","records","total","searchCount"})
    @ApiImplicitParams({
            @ApiImplicitParam(name="lon",value="经度",dataType="String", paramType = "query"),
            @ApiImplicitParam(name="lat",value="纬度",dataType="String", paramType = "query")})
    public APIEntity saveTrack(@RequestAttribute("JwtUserId") Integer id, String lon, String lat) {
        TTrack tTrack  = new TTrack();
        tTrack.setCourierId(id);
        tTrack.setLon(lon);
        tTrack.setLat(lat);
        tTrack.setTrackTime(LocalDateTime.now());
      return APIEntity.success(trackService.save(tTrack));
    }



}
