package com.bonus.sgzb.material.controller;

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

import com.bonus.sgzb.material.service.IPurchaseCheckInfoService;
import com.bonus.sgzb.material.domain.PurchaseCheckInfo;
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.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
import com.bonus.sgzb.common.security.annotation.RequiresPermissions;
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("/purchaseCheckInfo")
public class PurchaseCheckInfoController extends BaseController
{
    @Autowired
    private IPurchaseCheckInfoService purchaseCheckInfoService;

    /**
     * 查询新购验收任务列表
     */
    @ApiOperation("查询新购验收任务列表")
    @GetMapping("/list")
    public TableDataInfo list(PurchaseCheckInfo purchaseCheckInfo)
    {
        startPage();
        List<PurchaseCheckInfo> list = purchaseCheckInfoService.selectPurchaseCheckInfoList(purchaseCheckInfo);
        return getDataTable(list);
    }

    /**
     * 导出新购验收任务列表
     */
    @RequiresPermissions("domain:info:export")
    @Log(title = "新购验收任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PurchaseCheckInfo purchaseCheckInfo)
    {
        List<PurchaseCheckInfo> list = purchaseCheckInfoService.selectPurchaseCheckInfoList(purchaseCheckInfo);
        ExcelUtil<PurchaseCheckInfo> util = new ExcelUtil<PurchaseCheckInfo>(PurchaseCheckInfo.class);
        util.exportExcel(response, list, "新购验收任务数据");
    }

    /**
     * 获取新购验收任务详细信息
     */
    @RequiresPermissions("domain:info:query")
    @GetMapping(value = "/{taskId}")
    public AjaxResult getInfo(@PathVariable("taskId") Long taskId)
    {
        return success(purchaseCheckInfoService.selectPurchaseCheckInfoByTaskId(taskId));
    }

    /**
     * 新增新购验收任务
     */
    @RequiresPermissions("domain:info:add")
    @Log(title = "新购验收任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PurchaseCheckInfo purchaseCheckInfo)
    {
        return toAjax(purchaseCheckInfoService.insertPurchaseCheckInfo(purchaseCheckInfo));
    }

    /**
     * 修改新购验收任务
     */
    @RequiresPermissions("domain:info:edit")
    @Log(title = "新购验收任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PurchaseCheckInfo purchaseCheckInfo)
    {
        return toAjax(purchaseCheckInfoService.updatePurchaseCheckInfo(purchaseCheckInfo));
    }

    /**
     * 删除新购验收任务
     */
    @RequiresPermissions("domain:info:remove")
    @Log(title = "新购验收任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{taskIds}")
    public AjaxResult remove(@PathVariable Long[] taskIds)
    {
        return toAjax(purchaseCheckInfoService.deletePurchaseCheckInfoByTaskIds(taskIds));
    }
}
