package com.sckw.driver.controller;

import com.sckw.driver.entity.req.KwBusinessDriverInsertParam;
import com.sckw.driver.entity.req.KwBusinessDriverPageListParam;
import com.sckw.driver.entity.req.KwBusinessDriverUpdateParam;
import com.sckw.driver.service.KwBusinessDriverService;
import com.sckw.core.web.response.HttpResult;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @desc:
 * @author: Lt
 * @date: 2024-04-12
 */
@Validated
@RestController
@RequestMapping(value = "/driver")
public class DriverController {

    @Autowired
    KwBusinessDriverService kwBusinessDriverService;

    /**
    * @Description: 司机新增
    * @Author: Lt
    * @Date: 2024/4/12 13:49
    */
    @PostMapping(value = "/insert")
    public HttpResult driverInsert(@RequestBody @Valid KwBusinessDriverInsertParam kwBusinessDriverInsertParam)
    {
        return kwBusinessDriverService.driverInsert(kwBusinessDriverInsertParam);
    }

    /**
    * @Description: 司机新增
    * @Author: Lt
    * @Date: 2024/4/12 13:49
    */
    @PostMapping(value = "/update")
    public HttpResult driverUpdate(@RequestBody @Valid KwBusinessDriverUpdateParam kwBusinessDriverUpdateParam)
    {
        return kwBusinessDriverService.driverUpdate(kwBusinessDriverUpdateParam);
    }

    /**
    * @Description: 司机删除
    * @Author: Lt
    * @Date: 2024/4/12 13:49
    */
    @PostMapping(value = "/delete")
    public HttpResult driverDelete(@RequestParam("id") String id)
    {
        return kwBusinessDriverService.driverDelete(id);
    }

    /**
    * @Description: 司机详情
    * @Author: Lt
    * @Date: 2024/4/12 17:17
    */
    @GetMapping( "/detail/{id}")
    public HttpResult getDriverDetail(@PathVariable(name = "id") String id)
    {
        return HttpResult.ok(kwBusinessDriverService.driverDetail(id));
    }

    /**
    * @Description: 司机分页查询
    * @Author: Lt
    * @Date: 2024/4/12 17:17
    */
    @PostMapping("/select")
    public HttpResult selectPageList(@RequestBody KwBusinessDriverPageListParam kwBusinessDriverPageListParam)
    {
        return HttpResult.ok(kwBusinessDriverService.driverPageList(kwBusinessDriverPageListParam));
    }



}
