package com.ningdatech.carapi.industry.controller;


import com.ningdatech.basic.model.PageVo;
import com.ningdatech.carapi.industry.manage.PurchaseRawMaterialManage;
import com.ningdatech.carapi.industry.model.req.PurchaseRawMaterialListReq;
import com.ningdatech.carapi.industry.model.vo.PurchaseRawMaterialListVo;
import com.ningdatech.carapi.industry.service.IPurchaseRawMaterialService;
import com.ningdatech.log.annotation.WebLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 原材料采购信息表 前端控制器
 * </p>
 *
 * @author WendyYang
 * @since 2022-11-09
 */
@Validated
@Api(tags = "行业服务-采购服务-原材料信息")
@RestController
@AllArgsConstructor
@RequestMapping("/api/v1/industry/purchase-raw-material")
public class PurchaseRawMaterialController {

    private final PurchaseRawMaterialManage purchaseRawMaterialManage;
    private final IPurchaseRawMaterialService purchaseRawMaterialService;

    @ApiOperation("列表查询")
    @GetMapping("/list")
    public PageVo<PurchaseRawMaterialListVo> list(PurchaseRawMaterialListReq req) {
        return purchaseRawMaterialManage.list(req);
    }

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

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

}
