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.SysPerformanceServing;
import com.srs.teacher.service.ISysPerformanceServingService;
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/serving")
@Api(value = "综合绩效-担任职务管理", tags = "综合绩效-担任职务管理")
public class SysPerformanceServingController extends BaseController {
    @Autowired
    private ISysPerformanceServingService sysPerformanceServingService;

    /**
     * 查询综合绩效-担任职务列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:serving:list')")
    @GetMapping("/list")
    @ApiOperation("查询综合绩效-担任职务列表")
    public TableDataInfo list(SysPerformanceServing sysPerformanceServing) {
        startPage();
        List<SysPerformanceServing> list = sysPerformanceServingService.selectSysPerformanceServingList(sysPerformanceServing);
        return getDataTable(list);
    }

    /**
     * 导出综合绩效-担任职务列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:serving:export')")
    @Log(title = "综合绩效-担任职务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出综合绩效-担任职务列表")
    public void export(HttpServletResponse response, SysPerformanceServing sysPerformanceServing) {
        List<SysPerformanceServing> list = sysPerformanceServingService.selectSysPerformanceServingList(sysPerformanceServing);
        ExcelUtil<SysPerformanceServing> util = new ExcelUtil<SysPerformanceServing>(SysPerformanceServing.class);
        util.exportExcel(response, list, "综合绩效-担任职务数据");
    }

    /**
     * 获取综合绩效-担任职务详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:serving:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取综合绩效-担任职务详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysPerformanceServingService.selectSysPerformanceServingById(id));
    }

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

    /**
     * 新增综合绩效-担任职务
     */
    @PreAuthorize("@ss.hasPermi('teacher:serving:add')")
    @Log(title = "综合绩效-担任职务", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增综合绩效-担任职务")
    public AjaxResult add(@RequestBody SysPerformanceServing sysPerformanceServing) {
        return toAjax(sysPerformanceServingService.insertSysPerformanceServing(sysPerformanceServing));
    }

    /**
     * 修改综合绩效-担任职务
     */
    @PreAuthorize("@ss.hasPermi('teacher:serving:edit')")
    @Log(title = "综合绩效-担任职务", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改综合绩效-担任职务")
    public AjaxResult edit(@RequestBody SysPerformanceServing sysPerformanceServing) {
        return toAjax(sysPerformanceServingService.updateSysPerformanceServing(sysPerformanceServing));
    }

    /**
     * 删除综合绩效-担任职务
     */
    @PreAuthorize("@ss.hasPermi('teacher:serving:remove')")
    @Log(title = "综合绩效-担任职务", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除综合绩效-担任职务")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysPerformanceServingService.deleteSysPerformanceServingByIds(ids));
    }
}
