package com.srs.web.controller.diagnostic;

import java.util.ArrayList;
import java.util.List;

import com.srs.common.core.domain.model.LoginUser;
import com.srs.common.utils.SecurityUtils;
import com.srs.comprehensive.domain.SrsStudent;
import com.srs.comprehensive.service.ISrsStudentService;
import com.srs.diagnostic.domain.DiaFillOutReport;
import com.srs.diagnostic.service.impl.DiaFillOutReportServiceImpl;
import com.srs.diagnostic.service.IDiaFillOutReportService;
import com.srs.framework.web.domain.server.Sys;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;

import com.srs.diagnostic.domain.DiaReportDetails;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.enums.BusinessType;
import com.srs.common.annotation.Log;
import com.srs.common.core.page.TableDataInfo;

/**
 * 诊断报告Controller
 *
 * @author srs
 * @date 2025-05-08
 */
@RestController
@RequestMapping("/diagnostic/diafilloutreport")
@Api(value = "报表填写", tags = "报表填写")
public class DiaFillOutReportController extends BaseController {

    @Autowired
    private IDiaFillOutReportService diaFillOutReportService;

    @Autowired
    private ISrsStudentService srsStudentService;


    /**
     * 查询诊断报告列表
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:diafilloutreport:list') || @ss.hasPermi('diagnostic:diafilloutreport:studentlist')")
    @GetMapping("/list")
    @ApiOperation("查询报表填写列表")
    public TableDataInfo list(DiaFillOutReport diaFillOutReport) {
        List<DiaFillOutReport> list = diaFillOutReportService.selectDiaFillOutReportList(diaFillOutReport);
        return getDataTable(list);
    }

    /**
     * 查询学生填写详情
     */
    @PreAuthorize("@ss.hasPermi('diagnostic:diafilloutreport:list')")
    @PostMapping("/listinfo")
    @ApiOperation("查询学生填写详情")
    public TableDataInfo listinfo(@RequestBody DiaFillOutReport diaFillOutReport) {

        List<DiaFillOutReport> list = diaFillOutReportService.selectDiaFillOutReportListUser(diaFillOutReport.getStuNo());
        return getDataTable(list);
    }

    ///      批量插入方法
    @PreAuthorize("@ss.hasPermi('diagnostic:diafilloutreport:add')")
    @Log(title = "报表填写", businessType = BusinessType.INSERT)
    @PostMapping("/Add")
    @ApiOperation("批量新增报表填写")
    public AjaxResult Add(@RequestBody DiaFillOutReport diaFillOutReport) {

        return toAjax(diaFillOutReportService.insertDiaFillOutReport(diaFillOutReport));
    }

    //批量修改
    @PreAuthorize("@ss.hasPermi('diagnostic:diafilloutreport:edit')")
    @Log(title = "报表填写", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ApiOperation("批量修改报表填写")
    public AjaxResult edit(@RequestBody List<DiaFillOutReport> list) {
        return toAjax(diaFillOutReportService.updateDiaFillOutReportList(list));
    }

    ///      批量插入数据
    @PreAuthorize("@ss.hasPermi('diagnostic:diafilloutreport:Addtype')")
    @Log(title = "报表填写", businessType = BusinessType.INSERT)
    @PostMapping("/Addtype")
    @ApiOperation("批量插入报表填写")
    public AjaxResult Addtype(@RequestBody List<DiaFillOutReport> list) {

        return toAjax(diaFillOutReportService.insertDiaFillOutReportList(list));
    }

}
