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.SysPerformanceRw;
import com.srs.teacher.service.ISysPerformanceRwService;
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/rw")
@Api(value = "综合素质-承担任务管理", tags = "综合素质-承担任务管理")
public class SysPerformanceRwController extends BaseController {
    @Autowired
    private ISysPerformanceRwService sysPerformanceRwService;

    /**
     * 查询综合素质-承担任务列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:rw:list')")
    @GetMapping("/list")
    @ApiOperation("查询综合素质-承担任务列表")
    public TableDataInfo list(SysPerformanceRw sysPerformanceRw) {
        startPage();
        List<SysPerformanceRw> list = sysPerformanceRwService.selectSysPerformanceRwList(sysPerformanceRw);
        return getDataTable(list);
    }

    /**
     * 导出综合素质-承担任务列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:rw:export')")
    @Log(title = "综合素质-承担任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出综合素质-承担任务列表")
    public void export(HttpServletResponse response, SysPerformanceRw sysPerformanceRw) {
        List<SysPerformanceRw> list = sysPerformanceRwService.selectSysPerformanceRwList(sysPerformanceRw);
        ExcelUtil<SysPerformanceRw> util = new ExcelUtil<SysPerformanceRw>(SysPerformanceRw.class);
        util.exportExcel(response, list, "综合素质-承担任务数据");
    }

    /**
     * 获取综合素质-承担任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:rw:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取综合素质-承担任务详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysPerformanceRwService.selectSysPerformanceRwById(id));
    }

    /**
     * 获取综合素质-承担任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:rw:query')")
    @GetMapping(value = "/getInfoByFdNameAndYears")
    @ApiOperation("根据填报人和年份获取综合素质-承担任务详细信息")
    public AjaxResult getInfoByFdNameAndYears(@RequestParam String fdName, @RequestParam String years) {
        return success(sysPerformanceRwService.selectSysPerformanceRwByFdyName(fdName, years));
    }

    /**
     * 新增综合素质-承担任务
     */
    @PreAuthorize("@ss.hasPermi('teacher:rw:add')")
    @Log(title = "综合素质-承担任务", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增综合素质-承担任务")
    public AjaxResult add(@RequestBody SysPerformanceRw sysPerformanceRw) {
        return toAjax(sysPerformanceRwService.insertSysPerformanceRw(sysPerformanceRw));
    }

    /**
     * 修改综合素质-承担任务
     */
    @PreAuthorize("@ss.hasPermi('teacher:rw:edit')")
    @Log(title = "综合素质-承担任务", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改综合素质-承担任务")
    public AjaxResult edit(@RequestBody SysPerformanceRw sysPerformanceRw) {
        return toAjax(sysPerformanceRwService.updateSysPerformanceRw(sysPerformanceRw));
    }

    /**
     * 删除综合素质-承担任务
     */
    @PreAuthorize("@ss.hasPermi('teacher:rw:remove')")
    @Log(title = "综合素质-承担任务", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除综合素质-承担任务")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysPerformanceRwService.deleteSysPerformanceRwByIds(ids));
    }
}
