package com.zhyc.module.biosafety.controller;

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

import com.zhyc.module.biosafety.domain.QuarantineReport;
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.zhyc.common.annotation.Log;
import com.zhyc.common.core.controller.BaseController;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.module.biosafety.service.IQuarantineReportService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;

/**
 * 检疫记录Controller
 * 
 * @author ruoyi
 * @date 2025-07-14
 */
@RestController
@RequestMapping("/biosafety/quarantine")
public class QuarantineReportController extends BaseController
{
    @Autowired
    private IQuarantineReportService quarantineReportService;

    /**
     * 查询检疫记录列表
     */
    @PreAuthorize("@ss.hasPermi('biosafety:quarantine:list')")
    @GetMapping("/list")
    public TableDataInfo list(QuarantineReport quarantineReport)
    {
        startPage();
        List<QuarantineReport> list = quarantineReportService.selectQuarantineReportList(quarantineReport);
        return getDataTable(list);
    }

    /**
     * 导出检疫记录列表
     */
    @PreAuthorize("@ss.hasPermi('biosafety:quarantine:export')")
    @Log(title = "检疫记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QuarantineReport quarantineReport)
    {
        List<QuarantineReport> list = quarantineReportService.selectQuarantineReportList(quarantineReport);
        ExcelUtil<QuarantineReport> util = new ExcelUtil<QuarantineReport>(QuarantineReport.class);
        util.exportExcel(response, list, "检疫记录数据");
    }

    /**
     * 获取检疫记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('bisosafety:quarantine:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(quarantineReportService.selectQuarantineReportById(id));
    }

    /**
     * 新增检疫记录
     */
    @PreAuthorize("@ss.hasPermi('biosafety:quarantine:add')")
    @Log(title = "检疫记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QuarantineReport quarantineReport)
    {
        quarantineReport.setDeptId(getDeptId());
        quarantineReport.setUserId(getUserId());
        return toAjax(quarantineReportService.insertQuarantineReport(quarantineReport));
    }

    /**
     * 修改检疫记录
     */
    @PreAuthorize("@ss.hasPermi('biosafety:quarantine:edit')")
    @Log(title = "检疫记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QuarantineReport quarantineReport)
    {
        return toAjax(quarantineReportService.updateQuarantineReport(quarantineReport));
    }

    /**
     * 删除检疫记录
     */
    @PreAuthorize("@ss.hasPermi('biosafety:quarantine:remove')")
    @Log(title = "检疫记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(quarantineReportService.deleteQuarantineReportByIds(ids));
    }
}
