package com.srs.web.controller.teacher;

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

import com.srs.common.annotation.RepeatSubmit;
import com.srs.teacher.domain.SysTeacherKpiFillingAMgt;
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.SysTeacherKpiFillingBusinessWork;
import com.srs.teacher.service.ISysTeacherKpiFillingBusinessWorkService;
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 chc
 * @date 2024-06-07
 */
@RestController
@RequestMapping("/teacher/kpiFillingBusinessWork")
@Api(value = "业绩考核-个人填报-业务工作管理", tags = "业绩考核-个人填报-业务工作管理")
public class SysTeacherKpiFillingBusinessWorkController extends BaseController {
    @Autowired
    private ISysTeacherKpiFillingBusinessWorkService sysTeacherKpiFillingBusinessWorkService;

    /**
     * 查询个人填报-业务工作列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:kpiFillingBusinessWork:list')")
    @GetMapping("/list")
    @ApiOperation("查询个人填报-业务工作列表")
    public TableDataInfo list(SysTeacherKpiFillingBusinessWork sysTeacherKpiFillingBusinessWork) {
        startPage();
        List<SysTeacherKpiFillingBusinessWork> list = sysTeacherKpiFillingBusinessWorkService.selectSysTeacherKpiFillingBusinessWorkList(sysTeacherKpiFillingBusinessWork);
        return getDataTable(list);
    }

    /**
     * 根据辅导员名称、年份 月份 查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:kpiFillingBusinessWork:list')")
    @GetMapping(value = "/getByFdyNameAndYearAndMonth")
    @ApiOperation("根据名称年月查询个人填报-业务工作列表")
    public TableDataInfo getByFdyNameAndYearAndMonth(@RequestParam String fdyName, @RequestParam String fillingYear, @RequestParam String fillingMonth) {
        startPage();
        List<SysTeacherKpiFillingBusinessWork> sysTeacherKpiFillingBusinessWorkList = sysTeacherKpiFillingBusinessWorkService.selectSysTeacherKpiFillingBusinessWorkByFdyName(fdyName, fillingYear, fillingMonth);
        return getDataTable(sysTeacherKpiFillingBusinessWorkList);
    }

    /**
     * 导出个人填报-业务工作列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:kpiFillingBusinessWork:export')")
    @Log(title = "个人填报-业务工作", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出个人填报-业务工作列表")
    public void export(HttpServletResponse response, SysTeacherKpiFillingBusinessWork sysTeacherKpiFillingBusinessWork) {
        List<SysTeacherKpiFillingBusinessWork> list = sysTeacherKpiFillingBusinessWorkService.selectSysTeacherKpiFillingBusinessWorkList(sysTeacherKpiFillingBusinessWork);
        ExcelUtil<SysTeacherKpiFillingBusinessWork> util = new ExcelUtil<SysTeacherKpiFillingBusinessWork>(SysTeacherKpiFillingBusinessWork.class);
        util.exportExcel(response, list, "个人填报-业务工作数据");
    }

    /**
     * 获取个人填报-业务工作详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:kpiFillingBusinessWork:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取个人填报-业务工作详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysTeacherKpiFillingBusinessWorkService.selectSysTeacherKpiFillingBusinessWorkById(id));
    }

    /**
     * 新增个人填报-业务工作
     */
    @PreAuthorize("@ss.hasPermi('teacher:kpiFillingBusinessWork:add')")
    @Log(title = "个人填报-业务工作", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增个人填报-业务工作")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult add(@RequestBody SysTeacherKpiFillingBusinessWork sysTeacherKpiFillingBusinessWork) {
        return toAjax(sysTeacherKpiFillingBusinessWorkService.insertSysTeacherKpiFillingBusinessWork(sysTeacherKpiFillingBusinessWork));
    }

    /**
     * 修改个人填报-业务工作
     */
    @PreAuthorize("@ss.hasPermi('teacher:kpiFillingBusinessWork:edit')")
    @Log(title = "个人填报-业务工作", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改个人填报-业务工作")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult edit(@RequestBody SysTeacherKpiFillingBusinessWork sysTeacherKpiFillingBusinessWork) {
        return toAjax(sysTeacherKpiFillingBusinessWorkService.updateSysTeacherKpiFillingBusinessWork(sysTeacherKpiFillingBusinessWork));
    }

    /**
     * 删除个人填报-业务工作
     */
    @PreAuthorize("@ss.hasPermi('teacher:kpiFillingBusinessWork:remove')")
    @Log(title = "个人填报-业务工作", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除个人填报-业务工作")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysTeacherKpiFillingBusinessWorkService.deleteSysTeacherKpiFillingBusinessWorkByIds(ids));
    }
}
