package com.ningdatech.carapi.industry.controller;


import com.ningdatech.basic.model.PageVo;
import com.ningdatech.carapi.industry.manage.PurchaseVehicleManage;
import com.ningdatech.carapi.industry.model.req.PurchaseVehicleListReq;
import com.ningdatech.carapi.industry.model.vo.PurchaseVehicleListVo;
import com.ningdatech.carapi.industry.service.IPurchaseVehicleService;
import com.ningdatech.log.annotation.WebLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 车辆采购信息表 前端控制器
 * </p>
 *
 * @author WendyYang
 * @since 2022-11-09
 */
@RestController
@Api(tags = "行业服务-采购服务-车辆采购信息")
@AllArgsConstructor
@RequestMapping("/api/v1/industry/purchase-vehicle")
public class PurchaseVehicleController {

    private final IPurchaseVehicleService purchaseVehicleService;
    private final PurchaseVehicleManage purchaseVehicleManage;

    @DeleteMapping("/del/{id}")
    @ApiOperation("删除")
    @WebLog(value = "删除")
    public void delete(@PathVariable Long id) {
        purchaseVehicleService.removeById(id);
    }

    @GetMapping("/list")
    @ApiOperation("列表")
    public PageVo<PurchaseVehicleListVo> list(PurchaseVehicleListReq req) {
        return purchaseVehicleManage.purchaseWheelList(req);
    }

    @PostMapping("/saveOrUpdate")
    @ApiOperation("保存/修改")
    @WebLog(value = "保存/修改")
    public void saveOrUpdate(@Valid @RequestBody PurchaseVehicleListVo req) {
        purchaseVehicleManage.saveOrUpdate(req);
    }

}
