package cn.ezhizao.project.business.processErrorStatistics.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.processErrorStatistics.domain.BizProcessDocumentsErrorStatistics;
import cn.ezhizao.project.business.processErrorStatistics.service.IBizProcessDocumentsErrorStatisticsService;
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-08-02
 */
@RestController
@RequestMapping("/business/ProcessErrorStatistics")
public class BizProcessDocumentsErrorStatisticsController extends BaseController
{
    @Resource
    private IBizProcessDocumentsErrorStatisticsService bizProcessDocumentsErrorStatisticsService;

    /**
     * 查询工艺文件制作错误次数统计列表
     */
    @Log(title = "工艺文件制作错误次数统计查询", businessType = BusinessType.SELECT)
    @GetMapping("/list")
    public TableDataInfo list(BizProcessDocumentsErrorStatistics bizProcessDocumentsErrorStatistics) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizProcessDocumentsErrorStatistics);
        startPage();
        List<BizProcessDocumentsErrorStatistics> list = bizProcessDocumentsErrorStatisticsService.getList(bizProcessDocumentsErrorStatistics);
        return getDataTable(list);
    }

    /**
     * 导出工艺文件制作错误次数统计列表
     */
    @PreAuthorize("@ss.hasPermi('business:ProcessErrorStatistics:export')")
    @Log(title = "工艺文件制作错误次数统计导出", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizProcessDocumentsErrorStatistics bizProcessDocumentsErrorStatistics) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizProcessDocumentsErrorStatistics);
        List<BizProcessDocumentsErrorStatistics> list = bizProcessDocumentsErrorStatisticsService.getList(bizProcessDocumentsErrorStatistics);
        ExcelUtil<BizProcessDocumentsErrorStatistics> util = new ExcelUtil<BizProcessDocumentsErrorStatistics>(BizProcessDocumentsErrorStatistics.class);
        util.exportExcel(response, list, "工艺文件制作错误次数统计数据");
    }

    /**
     * 获取工艺文件制作错误次数统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:ProcessErrorStatistics:query')")
    @Log(title = "工艺文件制作错误次数统计查询详细信息", businessType = BusinessType.SELECT)
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizProcessDocumentsErrorStatisticsService.getById(id));
    }

    /**
     * 新增工艺文件制作错误次数统计
     */
    @Log(title = "工艺文件制作错误次数统计新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizProcessDocumentsErrorStatistics bizProcessDocumentsErrorStatistics) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizProcessDocumentsErrorStatistics);
        return toAjax(bizProcessDocumentsErrorStatisticsService.save(bizProcessDocumentsErrorStatistics));
    }

    /**
     * 修改工艺文件制作错误次数统计
     */
    @Log(title = "工艺文件制作错误次数统计修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizProcessDocumentsErrorStatistics bizProcessDocumentsErrorStatistics) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizProcessDocumentsErrorStatistics);
        return toAjax(bizProcessDocumentsErrorStatisticsService.updateById(bizProcessDocumentsErrorStatistics));
    }

    /**
     * 删除工艺文件制作错误次数统计
     */
    @Log(title = "工艺文件制作错误次数统计删除", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(bizProcessDocumentsErrorStatisticsService.removeBatchByIds(ids));
    }
}
