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.SysPerformanceTask;
import com.srs.teacher.service.ISysPerformanceTaskService;
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-20
 */
@RestController
@RequestMapping("/teacher/task")
@Api(value = "综合测试-最大奖励管理", tags = "综合测试-最大奖励管理")
public class SysPerformanceTaskController extends BaseController {
    @Autowired
    private ISysPerformanceTaskService sysPerformanceTaskService;

    /**
     * 查询综合测试-最大奖励列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:task:list')")
    @GetMapping("/list")
    @ApiOperation("查询综合测试-最大奖励列表")
    public TableDataInfo list(SysPerformanceTask sysPerformanceTask) {
        startPage();
        List<SysPerformanceTask> list = sysPerformanceTaskService.selectSysPerformanceTaskList(sysPerformanceTask);
        return getDataTable(list);
    }

    /**
     * 导出综合测试-最大奖励列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:task:export')")
    @Log(title = "综合测试-最大奖励", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出综合测试-最大奖励列表")
    public void export(HttpServletResponse response, SysPerformanceTask sysPerformanceTask) {
        List<SysPerformanceTask> list = sysPerformanceTaskService.selectSysPerformanceTaskList(sysPerformanceTask);
        ExcelUtil<SysPerformanceTask> util = new ExcelUtil<SysPerformanceTask>(SysPerformanceTask.class);
        util.exportExcel(response, list, "综合测试-最大奖励数据");
    }

    /**
     * 获取综合测试-最大奖励详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:task:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取综合测试-最大奖励详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysPerformanceTaskService.selectSysPerformanceTaskById(id));
    }

    /**
     * 获取综合测试-最大奖励详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:task:query')")
    @GetMapping(value = "/getInfoByFdNameAndYears")
    @ApiOperation("根据填报人和年份获取综合测试-最大奖励详细信息")
    public AjaxResult getInfoByFdNameAndYears(@RequestParam String fdName, @RequestParam String years) {
        return success(sysPerformanceTaskService.selectSysPerformanceTaskByFdyName(fdName, years));
    }

    /**
     * 新增综合测试-最大奖励
     */
    @PreAuthorize("@ss.hasPermi('teacher:task:add')")
    @Log(title = "综合测试-最大奖励", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增综合测试-最大奖励")
    public AjaxResult add(@RequestBody SysPerformanceTask sysPerformanceTask) {
        return toAjax(sysPerformanceTaskService.insertSysPerformanceTask(sysPerformanceTask));
    }

    /**
     * 修改综合测试-最大奖励
     */
    @PreAuthorize("@ss.hasPermi('teacher:task:edit')")
    @Log(title = "综合测试-最大奖励", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改综合测试-最大奖励")
    public AjaxResult edit(@RequestBody SysPerformanceTask sysPerformanceTask) {
        return toAjax(sysPerformanceTaskService.updateSysPerformanceTask(sysPerformanceTask));
    }

    /**
     * 删除综合测试-最大奖励
     */
    @PreAuthorize("@ss.hasPermi('teacher:task:remove')")
    @Log(title = "综合测试-最大奖励", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除综合测试-最大奖励")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysPerformanceTaskService.deleteSysPerformanceTaskByIds(ids));
    }
}
