package com.yanzhu.jh.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.yanzhu.jh.project.domain.SurProjectCheckDetection;
import com.yanzhu.jh.project.service.ISurProjectCheckDetectionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 材料送检Controller
 * 
 * @author JiangYuQi
 * @date 2023-08-26
 */
@RestController
@RequestMapping("/project/checkDetection")
public class SurProjectCheckDetectionController extends BaseController
{
    @Autowired
    private ISurProjectCheckDetectionService surProjectCheckDetectionService;

    /**
     * 查询材料送检列表
     */
    @PreAuthorize("@ss.hasPermi('project:checkDetection:list')")
    @GetMapping("/list")
    public TableDataInfo list(SurProjectCheckDetection surProjectCheckDetection)
    {
        startPage();
        List<SurProjectCheckDetection> list = surProjectCheckDetectionService.selectSurProjectCheckDetectionList(surProjectCheckDetection);
        return getDataTable(list);
    }

    /**
     * 导出材料送检列表
     */
    @PreAuthorize("@ss.hasPermi('project:checkDetection:export')")
    @Log(title = "材料送检", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SurProjectCheckDetection surProjectCheckDetection)
    {
        List<SurProjectCheckDetection> list = surProjectCheckDetectionService.selectSurProjectCheckDetectionList(surProjectCheckDetection);
        ExcelUtil<SurProjectCheckDetection> util = new ExcelUtil<SurProjectCheckDetection>(SurProjectCheckDetection.class);
        util.exportExcel(response, list, "材料送检数据");
    }

    /**
     * 获取材料送检详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:checkDetection:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(surProjectCheckDetectionService.selectSurProjectCheckDetectionById(id));
    }

    /**
     * 新增材料送检
     */
    @PreAuthorize("@ss.hasPermi('project:checkDetection:add')")
    @Log(title = "材料送检", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SurProjectCheckDetection surProjectCheckDetection)
    {
        return toAjax(surProjectCheckDetectionService.insertSurProjectCheckDetection(surProjectCheckDetection));
    }

    /**
     * 修改材料送检
     */
    @PreAuthorize("@ss.hasPermi('project:checkDetection:edit')")
    @Log(title = "材料送检", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SurProjectCheckDetection surProjectCheckDetection)
    {
        return toAjax(surProjectCheckDetectionService.updateSurProjectCheckDetection(surProjectCheckDetection));
    }

    /**
     * 删除材料送检
     */
    @PreAuthorize("@ss.hasPermi('project:checkDetection:remove')")
    @Log(title = "材料送检", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(surProjectCheckDetectionService.deleteSurProjectCheckDetectionByIds(ids));
    }
}
