package com.sqx.modules.fixedStroke.controller;

import com.sqx.common.utils.DateUtils;
import com.sqx.common.utils.PageUtils;
import com.sqx.common.utils.Result;
import com.sqx.modules.driver.entity.Driver;
import com.sqx.modules.driver.service.DriverService;
import com.sqx.modules.fixedStroke.entity.FixedStroke;
import com.sqx.modules.fixedStroke.service.FixedStrokeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;


@RestController
@Api(value = "一口价行程-管理端", tags = {"一口价行程-管理端"})
@RequestMapping("/fixedStroke")
public class FixedStrokeController {

    @Autowired
    private FixedStrokeService fixedStrokeService;

    @PostMapping("/insertFixedStroke")
    @ApiOperation("添加一口价行程")
    public Result insertFixedStroke(@RequestBody FixedStroke fixedStroke){
        fixedStroke.setCreateTime(DateUtils.format(new Date()));
        fixedStrokeService.save(fixedStroke);
        return Result.success();
    }

    @PostMapping("/updateFixedStroke")
    @ApiOperation("修改一口价行程")
    public Result updateFixedStroke(@RequestBody FixedStroke fixedStroke){
        fixedStrokeService.updateById(fixedStroke);
        return Result.success();
    }

    @PostMapping("/deleteFixedStroke")
    @ApiOperation("删除一口价行程")
    public Result deleteFixedStroke(Long fixedStrokeId){
        fixedStrokeService.removeById(fixedStrokeId);
        return Result.success();
    }

    @GetMapping("/selectFixedStrokeList")
    @ApiOperation("查询一口价行程列表")
    public Result selectFixedStrokeList(Integer page,Integer limit,String shipProvince,String shipCity,String shipDistrict,String shipAddress,
                                        String deliveryProvince,String deliveryCity,String deliveryDistrict,String deliveryAddress,Integer status){
        return Result.success().put("data",new PageUtils(fixedStrokeService.selectFixedStrokeList(page, limit, shipProvince, shipCity, shipDistrict,
                shipAddress, deliveryProvince, deliveryCity, deliveryDistrict, deliveryAddress, status)));
    }




}