package com.ningdatech.carapi.industry.controller;


import com.ningdatech.basic.model.PageVo;
import com.ningdatech.carapi.industry.manage.PurchaseOilManage;
import com.ningdatech.carapi.industry.model.req.PurchaseOilListReq;
import com.ningdatech.carapi.industry.model.vo.PurchaseOilListVo;
import com.ningdatech.carapi.industry.service.IPurchaseOilService;
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
 */
@Api(tags = "行业服务-采购信息-油品采购信息")
@RestController
@AllArgsConstructor
@RequestMapping("/api/v1/industry/purchase-oil")
public class PurchaseOilController {

    private final IPurchaseOilService purchaseOilService;
    private final PurchaseOilManage purchaseOilManage;


    @GetMapping("/list")
    @ApiOperation("列表")
    public PageVo<PurchaseOilListVo> list(PurchaseOilListReq req) {
        return purchaseOilManage.purchaseOilList(req);
    }

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

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

}
