package com.srs.web.controller.diagnostic;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
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.DiaReports;
import com.srs.diagnostic.service.IDiaReportsService;
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-21
 */
@RestController
@RequestMapping("/diagnostic/reports")
@Api(value = "诊断报告基础信息管理", tags = "诊断报告基础信息管理")
public class DiaReportsController extends BaseController {
    @Autowired
    private IDiaReportsService diaReportsService;

    /**
     * 查询诊断报告基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:reports:list')")
    @GetMapping("/list")
    @ApiOperation("查询诊断报告基础信息列表")
    public AjaxResult list(DiaReports diaReports) {
        List<DiaReports> list = diaReportsService.selectDiaReportsList(diaReports);
        return success(list);
    }

    /**
     * 查询下拉框的值
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:reports:list')")
    @GetMapping("/xlklist")
    @ApiOperation("查询下拉框")
    public AjaxResult xlklist() {
        List<DiaReports> list = diaReportsService.xlkList();
        return success(list);
    }

    /**
     * 导出诊断报告基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:reports:export')")
    @Log(title = "诊断报告基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出诊断报告基础信息列表")
    public void export(HttpServletResponse response, DiaReports diaReports) {
        List<DiaReports> list = diaReportsService.selectDiaReportsList(diaReports);
        ExcelUtil<DiaReports> util = new ExcelUtil<DiaReports>(DiaReports.class);
        util.exportExcel(response, list, "诊断报告基础信息数据");
    }

    /**
     * 获取诊断报告基础信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:reports:query')")
    @GetMapping(value = "/{reportId}")
    @ApiOperation("获取诊断报告基础信息详细信息")
    public AjaxResult getInfo(@PathVariable("reportId") int reportId)
    {
        return success(diaReportsService.selectDiaReportsByReportId(reportId));
    }

    /**
     * 新增诊断报告基础信息
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:reports:add')")
    @Log(title = "诊断报告基础信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增诊断报告基础信息")
    public AjaxResult add(@RequestBody DiaReports diaReports) {
        return toAjax(diaReportsService.insertDiaReports(diaReports));
    }

    /**
     * 修改诊断报告基础信息
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:reports:edit')")
    @Log(title = "诊断报告基础信息", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改诊断报告基础信息")
    public AjaxResult edit(@RequestBody DiaReports diaReports) {
        return toAjax(diaReportsService.updateDiaReports(diaReports));
    }

    /**
     * 删除诊断报告基础信息
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:reports:remove')")
    @Log(title = "诊断报告基础信息", businessType = BusinessType.DELETE)
    @PostMapping("/{reportIds}")
    @ApiOperation("删除诊断报告基础信息")
    public AjaxResult remove(@PathVariable int[] reportIds)
    {
        return toAjax(diaReportsService.deleteDiaReportsByReportIds(reportIds));
    }

    /**
     * 查询诊断报告基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:reports:list')")
    @GetMapping("/GetNames")
    @ApiOperation("查询诊断报告基础信息列表")
    public AjaxResult getNames(DiaReports diaReports) {
        List<DiaReports> list = diaReportsService.getNameList(diaReports);
        return success(list);
    }
}
