package cn.ezhizao.project.business.controller;

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

import cn.ezhizao.common.utils.poi.ExcelUtil;
import cn.ezhizao.framework.aspectj.lang.annotation.Log;
import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
import cn.ezhizao.framework.web.controller.BaseController;
import cn.ezhizao.framework.web.domain.AjaxResult;
import cn.ezhizao.framework.web.page.TableDataInfo;
import cn.ezhizao.project.business.domain.BizTaksStockStorageRetrieval;
import cn.ezhizao.project.business.service.IBizTaksStockStorageRetrievalService;
import org.springframework.security.access.prepost.PreAuthorize;
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;


/**
 * 盘点零存零取Controller
 *
 * @author ezhizao
 * @date 2024-10-14
 */
@RestController
@RequestMapping("/business/taksStockStorageRetrieval")
public class BizTaksStockStorageRetrievalController extends BaseController
{
    @Resource
    private IBizTaksStockStorageRetrievalService bizTaksStockStorageRetrievalService;

    /**
     * 查询盘点零存零取列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BizTaksStockStorageRetrieval bizTaksStockStorageRetrieval) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTaksStockStorageRetrieval);
        startPage();
        List<BizTaksStockStorageRetrieval> list = bizTaksStockStorageRetrievalService.getList(bizTaksStockStorageRetrieval);
        return getDataTable(list);
    }

    /**
     * 导出盘点零存零取列表
     */
    @Log(title = "盘点零存零取", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizTaksStockStorageRetrieval bizTaksStockStorageRetrieval) throws NoSuchFieldException, IllegalAccessException
    {
        List<BizTaksStockStorageRetrieval> list = bizTaksStockStorageRetrievalService.getList(bizTaksStockStorageRetrieval);
        ExcelUtil<BizTaksStockStorageRetrieval> util = new ExcelUtil<BizTaksStockStorageRetrieval>(BizTaksStockStorageRetrieval.class);
        util.exportExcel(response, list, "盘点零存零取数据");
    }

    /**
     * 获取盘点零存零取详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizTaksStockStorageRetrievalService.getById(id));
    }

    /**
     * 新增盘点零存零取
     */
    @Log(title = "盘点零存零取", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizTaksStockStorageRetrieval bizTaksStockStorageRetrieval) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTaksStockStorageRetrieval);
        return toAjax(bizTaksStockStorageRetrievalService.save(bizTaksStockStorageRetrieval));
    }

    /**
     * 修改盘点零存零取
     */
    @Log(title = "盘点零存零取", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizTaksStockStorageRetrieval bizTaksStockStorageRetrieval) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTaksStockStorageRetrieval);
        return toAjax(bizTaksStockStorageRetrievalService.updateById(bizTaksStockStorageRetrieval));
    }

    /**
     * 删除盘点零存零取
     */
    @Log(title = "盘点零存零取", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(bizTaksStockStorageRetrievalService.removeBatchByIds(ids));
    }
}
