package com.bonus.sgzb.material.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.bonus.sgzb.material.service.IPurchaseMacodeInfoService;
import com.bonus.sgzb.material.domain.PurchaseMacodeInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;

/**
 * 新购验收编号管理
 * 
 * @author bonus
 * @date 2023-12-10
 */
@RestController
@Api(value = "新购验收编号管理")
@RequestMapping("/purchaseMacode")
public class PurchaseMacodeInfoController extends BaseController
{
    @Autowired
    private IPurchaseMacodeInfoService purchaseMacodeInfoService;

    /**
     * 查询新购验收编号管理列表
     */
    @ApiOperation(value = "查询新购验收编号管理列表")
    @GetMapping("/list")
    public TableDataInfo list(PurchaseMacodeInfo purchaseMacodeInfo)
    {
        startPage();
        List<PurchaseMacodeInfo> list = purchaseMacodeInfoService.selectPurchaseMacodeInfoList(purchaseMacodeInfo);
        return getDataTable(list);
    }

    /**
     * 导出新购验收编号管理列表
     */
    @ApiOperation(value = "导出新购验收编号管理列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, PurchaseMacodeInfo purchaseMacodeInfo)
    {
        List<PurchaseMacodeInfo> list = purchaseMacodeInfoService.selectPurchaseMacodeInfoList(purchaseMacodeInfo);
        ExcelUtil<PurchaseMacodeInfo> util = new ExcelUtil<PurchaseMacodeInfo>(PurchaseMacodeInfo.class);
        util.exportExcel(response, list, "新购验收编号管理数据");
    }

    /**
     * 获取新购验收编号管理详细信息
     */
    @ApiOperation(value = "获取新购验收编号管理详细信息")
    @GetMapping(value = "/{taskId}")
    public AjaxResult getInfo(@PathVariable("taskId") Long taskId)
    {
        return success(purchaseMacodeInfoService.selectPurchaseMacodeInfoByTaskId(taskId));
    }

    /**
     * 新增新购验收编号管理
     */
    @ApiOperation(value = "新增新购验收编号管理")
    @PostMapping
    public AjaxResult add(@RequestBody PurchaseMacodeInfo purchaseMacodeInfo)
    {
        return toAjax(purchaseMacodeInfoService.insertPurchaseMacodeInfo(purchaseMacodeInfo));
    }

    /**
     * 修改新购验收编号管理
     */
    @ApiOperation(value = "修改新购验收编号管理")
    @PutMapping
    public AjaxResult edit(@RequestBody PurchaseMacodeInfo purchaseMacodeInfo)
    {
        return toAjax(purchaseMacodeInfoService.updatePurchaseMacodeInfo(purchaseMacodeInfo));
    }

    /**
     * 删除新购验收编号管理
     */
    @ApiOperation(value = "删除新购验收编号管理")
	@DeleteMapping("/{taskIds}")
    public AjaxResult remove(@PathVariable Long[] taskIds)
    {
        return toAjax(purchaseMacodeInfoService.deletePurchaseMacodeInfoByTaskIds(taskIds));
    }
}
