package com.srs.web.controller.teacher;

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

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.teacher.domain.SysPerformancePass;
import com.srs.teacher.service.ISysPerformancePassService;
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 2024-06-17
 */
@RestController
@RequestMapping("/teacher/pass")
@Api(value = "综合测试-第二课堂及格人数管理", tags = "综合测试-第二课堂及格人数管理")
public class SysPerformancePassController extends BaseController {
    @Autowired
    private ISysPerformancePassService sysPerformancePassService;

    /**
     * 查询综合测试-第二课堂及格人数列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:pass:list')")
    @GetMapping("/list")
    @ApiOperation("查询综合测试-第二课堂及格人数列表")
    public TableDataInfo list(SysPerformancePass sysPerformancePass) {
        startPage();
        List<SysPerformancePass> list = sysPerformancePassService.selectSysPerformancePassList(sysPerformancePass);
        return getDataTable(list);
    }

    /**
     * 导出综合测试-第二课堂及格人数列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:pass:export')")
    @Log(title = "综合测试-第二课堂及格人数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出综合测试-第二课堂及格人数列表")
    public void export(HttpServletResponse response, SysPerformancePass sysPerformancePass) {
        List<SysPerformancePass> list = sysPerformancePassService.selectSysPerformancePassList(sysPerformancePass);
        ExcelUtil<SysPerformancePass> util = new ExcelUtil<SysPerformancePass>(SysPerformancePass.class);
        util.exportExcel(response, list, "综合测试-第二课堂及格人数数据");
    }

    /**
     * 获取综合测试-第二课堂及格人数详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:pass:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取综合测试-第二课堂及格人数详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysPerformancePassService.selectSysPerformancePassById(id));
    }

    /**
     * 获取综合测试-第二课堂及格人数详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:pass:query')")
    @GetMapping(value = "/getInfoByFdNameAndYears")
    @ApiOperation("根据填报人和年份获取综合测试-第二课堂及格人数详细信息")
    public AjaxResult getInfoByFdNameAndYears(@RequestParam String fdName, @RequestParam String years) {
        return success(sysPerformancePassService.selectSysPerformancePassByFdyName(fdName, years));
    }

    /**
     * 新增综合测试-第二课堂及格人数
     */
    @PreAuthorize("@ss.hasPermi('teacher:pass:add')")
    @Log(title = "综合测试-第二课堂及格人数", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增综合测试-第二课堂及格人数")
    public AjaxResult add(@RequestBody SysPerformancePass sysPerformancePass) {
        return toAjax(sysPerformancePassService.insertSysPerformancePass(sysPerformancePass));
    }

    /**
     * 修改综合测试-第二课堂及格人数
     */
    @PreAuthorize("@ss.hasPermi('teacher:pass:edit')")
    @Log(title = "综合测试-第二课堂及格人数", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改综合测试-第二课堂及格人数")
    public AjaxResult edit(@RequestBody SysPerformancePass sysPerformancePass) {
        return toAjax(sysPerformancePassService.updateSysPerformancePass(sysPerformancePass));
    }

    /**
     * 删除综合测试-第二课堂及格人数
     */
    @PreAuthorize("@ss.hasPermi('teacher:pass:remove')")
    @Log(title = "综合测试-第二课堂及格人数", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除综合测试-第二课堂及格人数")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysPerformancePassService.deleteSysPerformancePassByIds(ids));
    }
}
