package com.zhyc.module.biosafety.controller;

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

import com.zhyc.module.biosafety.domain.QuarantineItems;
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.IQuarantineItemsService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;

/**
 * 检疫项目Controller
 * 
 * @author ruoyi
 * @date 2025-07-14
 */
@RestController
@RequestMapping("/biosafety/items")
public class QuarantineItemsController extends BaseController
{
    @Autowired
    private IQuarantineItemsService quarantineItemsService;

    /**
     * 查询检疫项目列表
     */
    @PreAuthorize("@ss.hasPermi('biosafety:items:list')")
    @GetMapping("/list")
    public TableDataInfo list(QuarantineItems quarantineItems)
    {
        startPage();
        List<QuarantineItems> list = quarantineItemsService.selectQuarantineItemsList(quarantineItems);
        return getDataTable(list);
    }

    /**
     * 导出检疫项目列表
     */
    @PreAuthorize("@ss.hasPermi('biosafety:items:export')")
    @Log(title = "检疫项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QuarantineItems quarantineItems)
    {
        List<QuarantineItems> list = quarantineItemsService.selectQuarantineItemsList(quarantineItems);
        ExcelUtil<QuarantineItems> util = new ExcelUtil<QuarantineItems>(QuarantineItems.class);
        util.exportExcel(response, list, "检疫项目数据");
    }

    /**
     * 获取检疫项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('biosafety:items:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(quarantineItemsService.selectQuarantineItemsById(id));
    }

    /**
     * 新增检疫项目
     */
    @PreAuthorize("@ss.hasPermi('biosafety:items:add')")
    @Log(title = "检疫项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QuarantineItems quarantineItems)
    {
        return toAjax(quarantineItemsService.insertQuarantineItems(quarantineItems));
    }

    /**
     * 修改检疫项目
     */
    @PreAuthorize("@ss.hasPermi('biosafety:items:edit')")
    @Log(title = "检疫项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QuarantineItems quarantineItems)
    {
        return toAjax(quarantineItemsService.updateQuarantineItems(quarantineItems));
    }

    /**
     * 删除检疫项目
     */
    @PreAuthorize("@ss.hasPermi('biosafety:items:remove')")
    @Log(title = "检疫项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(quarantineItemsService.deleteQuarantineItemsByIds(ids));
    }
}
