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.SysPerformanceActive;
import com.srs.teacher.service.ISysPerformanceActiveService;
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/active")
@Api(value = "综合绩效-辅导员工作室管理", tags = "综合绩效-辅导员工作室管理")
public class SysPerformanceActiveController extends BaseController {
    @Autowired
    private ISysPerformanceActiveService sysPerformanceActiveService;

    /**
     * 查询综合绩效-辅导员工作室列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:active:list')")
    @GetMapping("/list")
    @ApiOperation("查询综合绩效-辅导员工作室列表")
    public TableDataInfo list(SysPerformanceActive sysPerformanceActive) {
        startPage();
        List<SysPerformanceActive> list = sysPerformanceActiveService.selectSysPerformanceActiveList(sysPerformanceActive);
        return getDataTable(list);
    }


    /**
     * 导出综合绩效-辅导员工作室列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:active:export')")
    @Log(title = "综合绩效-辅导员工作室", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出综合绩效-辅导员工作室列表")
    public void export(HttpServletResponse response, SysPerformanceActive sysPerformanceActive) {
        List<SysPerformanceActive> list = sysPerformanceActiveService.selectSysPerformanceActiveList(sysPerformanceActive);
        ExcelUtil<SysPerformanceActive> util = new ExcelUtil<SysPerformanceActive>(SysPerformanceActive.class);
        util.exportExcel(response, list, "综合绩效-辅导员工作室数据");
    }

    /**
     * 获取综合绩效-辅导员工作室详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:active:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取综合绩效-辅导员工作室详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysPerformanceActiveService.selectSysPerformanceActiveById(id));
    }

    /**
     * 获取综合绩效-辅导员工作室详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:active:query')")
    @GetMapping(value = "/getInfoByFdNameAndYears")
    @ApiOperation("根据填报人和年份获取综合绩效-辅导员工作室详细信息")
    public AjaxResult getInfoByFdNameAndYears(@RequestParam String fdName, @RequestParam String years) {
        return success(sysPerformanceActiveService.selectSysPerformanceActiveByFdyName(fdName, years));
    }


    /**
     * 新增综合绩效-辅导员工作室
     */
    @PreAuthorize("@ss.hasPermi('teacher:active:add')")
    @Log(title = "综合绩效-辅导员工作室", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增综合绩效-辅导员工作室")
    public AjaxResult add(@RequestBody SysPerformanceActive sysPerformanceActive) {
        return toAjax(sysPerformanceActiveService.insertSysPerformanceActive(sysPerformanceActive));
    }

    /**
     * 修改综合绩效-辅导员工作室
     */
    @PreAuthorize("@ss.hasPermi('teacher:active:edit')")
    @Log(title = "综合绩效-辅导员工作室", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改综合绩效-辅导员工作室")
    public AjaxResult edit(@RequestBody SysPerformanceActive sysPerformanceActive) {
        return toAjax(sysPerformanceActiveService.updateSysPerformanceActive(sysPerformanceActive));
    }

    /**
     * 删除综合绩效-辅导员工作室
     */
    @PreAuthorize("@ss.hasPermi('teacher:active:remove')")
    @Log(title = "综合绩效-辅导员工作室", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除综合绩效-辅导员工作室")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysPerformanceActiveService.deleteSysPerformanceActiveByIds(ids));
    }
}
