package com.srs.web.controller.teacher;

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

import com.srs.common.annotation.Log;
import com.srs.common.annotation.RepeatSubmit;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.core.page.TableDataInfo;
import com.srs.common.enums.BusinessType;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.teacher.domain.SysTeacherKpiFillingBonusPointsMaterials;
import com.srs.teacher.service.ISysTeacherKpiFillingBonusPointsMaterialsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 业绩考核-个人填报-加分项佐证材料Controller
 *
 * @author Codex
 * @date 2026-03-26
 */
@RestController
@RequestMapping("/teacher/kpiFillingBonusPointsMaterials")
@Api(value = "业绩考核-个人填报-加分项佐证材料管理", tags = "业绩考核-个人填报-加分项佐证材料管理")
public class SysTeacherKpiFillingBonusPointsMaterialsController extends BaseController {
    @Autowired
    private ISysTeacherKpiFillingBonusPointsMaterialsService materialsService;

    @GetMapping("/list")
    @ApiOperation("查询业绩考核-个人填报-加分项佐证材料列表")
    public TableDataInfo list(SysTeacherKpiFillingBonusPointsMaterials materials) {
        startPage();
        List<SysTeacherKpiFillingBonusPointsMaterials> list = materialsService.selectSysTeacherKpiFillingBonusPointsMaterialsList(materials);
        return getDataTable(list);
    }

    @GetMapping("/getByFdyNameAndYearAndMonth")
    @ApiOperation("根据辅导员姓名、年月查询加分项佐证材料列表")
    public TableDataInfo getByFdyNameAndYearAndMonth(@RequestParam String fdyName,
                                                     @RequestParam String fillingYear,
                                                     @RequestParam String fillingMonth,
                                                     @RequestParam(required = false) String classType,
                                                     @RequestParam(required = false) String bonusType) {
        startPage();
        List<SysTeacherKpiFillingBonusPointsMaterials> list = materialsService.selectSysTeacherKpiFillingBonusPointsMaterialsByFdyName(fdyName, fillingYear, fillingMonth, classType, bonusType);
        return getDataTable(list);
    }

    @PostMapping("/export")
    @Log(title = "业绩考核-个人填报-加分项佐证材料", businessType = BusinessType.EXPORT)
    @ApiOperation("导出业绩考核-个人填报-加分项佐证材料列表")
    public void export(HttpServletResponse response, SysTeacherKpiFillingBonusPointsMaterials materials) {
        List<SysTeacherKpiFillingBonusPointsMaterials> list = materialsService.selectSysTeacherKpiFillingBonusPointsMaterialsList(materials);
        ExcelUtil<SysTeacherKpiFillingBonusPointsMaterials> util = new ExcelUtil<>(SysTeacherKpiFillingBonusPointsMaterials.class);
        util.exportExcel(response, list, "业绩考核-个人填报-加分项佐证材料数据");
    }

    @GetMapping(value = "/{id}")
    @ApiOperation("获取业绩考核-个人填报-加分项佐证材料详情")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(materialsService.selectSysTeacherKpiFillingBonusPointsMaterialsById(id));
    }

    @PostMapping("/add")
    @Log(title = "业绩考核-个人填报-加分项佐证材料", businessType = BusinessType.INSERT)
    @ApiOperation("新增业绩考核-个人填报-加分项佐证材料")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult add(@RequestBody SysTeacherKpiFillingBonusPointsMaterials materials) {
        return toAjax(materialsService.insertSysTeacherKpiFillingBonusPointsMaterials(materials));
    }

    @PostMapping("/update")
    @Log(title = "业绩考核-个人填报-加分项佐证材料", businessType = BusinessType.UPDATE)
    @ApiOperation("修改业绩考核-个人填报-加分项佐证材料")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult edit(@RequestBody SysTeacherKpiFillingBonusPointsMaterials materials) {
        return toAjax(materialsService.updateSysTeacherKpiFillingBonusPointsMaterials(materials));
    }

    @PostMapping("/{ids}")
    @Log(title = "业绩考核-个人填报-加分项佐证材料", businessType = BusinessType.DELETE)
    @ApiOperation("删除业绩考核-个人填报-加分项佐证材料")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(materialsService.deleteSysTeacherKpiFillingBonusPointsMaterialsByIds(ids));
    }
}
