package com.sqx.modules.driver.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.driver.entity.DriverRoute;
import com.sqx.modules.driver.service.DriverRouteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@Api(value = "司机发布-管理端", tags = {"司机发布-管理端"})
@RequestMapping("/driverRoute")
public class DriverRouteController {

    @Autowired
    private DriverRouteService driverRouteService;


    @PostMapping("/insertDriverRoute")
    @ApiOperation("司机发布")
    public Result insertDriverRoute(@RequestBody DriverRoute driverRoute){
        return driverRouteService.insertDriverRoute(driverRoute);
    }

    @PostMapping("/updateDriverRoute")
    @ApiOperation("司机修改")
    public Result updateDriverRoute(@RequestBody DriverRoute driverRoute){
        driverRouteService.updateById(driverRoute);
        return Result.success();
    }

    @PostMapping("/deleteDriverRoute")
    @ApiOperation("删除发布")
    public Result deleteDriverRoute(Long driverRouteId){
        driverRouteService.removeById(driverRouteId);
        return Result.success();
    }

    @GetMapping("/selectDriverRouteListByUserId")
    @ApiOperation("查询自己发布")
    public Result selectDriverRouteByUserId(Integer page,Integer limit,Long userId){
        return Result.success().put("data",driverRouteService.selectDriverRouteListByUserId(page,limit,userId));
    }

    @GetMapping("/selectDriverRouteList")
    @ApiOperation("查询发布列表")
    public Result selectDriverRouteList(Integer page,Integer limit,String shipProvince,String shipCity,String shipDistrict,String shipAddress,
                                        String deliveryProvince,String deliveryCity, String deliveryDistrict,String deliveryAddress,
                                        String userName,String phone,Long ordersId,Long userId,Integer status,String driverName,Integer isHighSpeedPrice){
        return driverRouteService.selectDriverRouteList(page, limit, shipProvince, shipCity, shipDistrict, shipAddress, deliveryProvince,
                deliveryCity, deliveryDistrict, deliveryAddress, userName, phone,ordersId,userId,status,driverName,isHighSpeedPrice);
    }


    @PostMapping("/insertMessageByDriver")
    @ApiOperation("邀请司机接单")
    public Result insertMessageByDriver(Long ordersId,Long driverRouteId){
        return driverRouteService.insertMessageByDriver(ordersId, driverRouteId);
    }



}