package com.srs.web.controller.diagnostic;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;

import com.srs.diagnostic.domain.DiaEligibility;
import com.srs.diagnostic.service.IDiaEligibilityService;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.enums.BusinessType;
import com.srs.common.annotation.Log;
import com.srs.common.core.page.TableDataInfo;

/**
 * 合格标准Controller
 *
 * @author srs
 * @date 2025-03-25
 */
@RestController
@RequestMapping("/diagnostic/eligibility")
@Api(value = "合格标准管理", tags = "合格标准管理")
public class DiaEligibilityController extends BaseController {
    @Autowired
    private IDiaEligibilityService diaEligibilityService;

    /**
     * 查询合格标准列表
     */
@PreAuthorize("@ss.hasPermi('diagnostic:eligibility:list')")
@GetMapping("/list")
@ApiOperation("查询合格标准列表")
    public TableDataInfo list(DiaEligibility diaEligibility)
    {
        startPage();
        List<DiaEligibility> list = diaEligibilityService.selectDiaEligibilityList(diaEligibility);
        return getDataTable(list);
    }

    /**
     * 导出合格标准列表
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:eligibility:export')")
    @Log(title = "合格标准", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出合格标准列表")
    public void export(HttpServletResponse response, DiaEligibility diaEligibility)
    {
        List<DiaEligibility> list = diaEligibilityService.selectDiaEligibilityList(diaEligibility);
        ExcelUtil<DiaEligibility> util = new ExcelUtil<DiaEligibility>(DiaEligibility.class);
        util.exportExcel(response, list, "合格标准数据");
    }

    /**
     * 获取合格标准详细信息
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:eligibility:query')")
    @GetMapping(value = "/{eliId}")
    @ApiOperation("获取合格标准详细信息")
    public AjaxResult getInfo(@PathVariable("eliId") Long eliId)
    {
        return success(diaEligibilityService.selectDiaEligibilityByEliId(eliId));
    }

    /**
     * 新增合格标准
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:eligibility:add')")
    @Log(title = "合格标准", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增合格标准")
    public AjaxResult add(@RequestBody DiaEligibility diaEligibility)
    {
        return toAjax(diaEligibilityService.insertDiaEligibility(diaEligibility));
    }

    /**
     * 修改合格标准
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:eligibility:edit')")
    @Log(title = "合格标准", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改合格标准")
    public AjaxResult edit(@RequestBody DiaEligibility diaEligibility)
    {
        return toAjax(diaEligibilityService.updateDiaEligibility(diaEligibility));
    }

    /**
     * 删除合格标准
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:eligibility:remove')")
    @Log(title = "合格标准", businessType = BusinessType.DELETE)
    @PostMapping("/{eliIds}")
    @ApiOperation("删除合格标准")
    public AjaxResult remove(@PathVariable Long[] eliIds)
    {
        return toAjax(diaEligibilityService.deleteDiaEligibilityByEliIds(eliIds));
    }
}
