package com.srs.web.controller.teacher;

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

import com.srs.common.annotation.RepeatSubmit;
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.SysTeacherCadreMeetingMaterials;
import com.srs.teacher.service.ISysTeacherCadreMeetingMaterialsService;
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-05
 */
@RestController
@RequestMapping("/teacher/caderMeetingMaterials")
@Api(value = "团干部会议佐证材料管理", tags = "团干部会议佐证材料管理")
public class SysTeacherCadreMeetingMaterialsController extends BaseController {
    @Autowired
    private ISysTeacherCadreMeetingMaterialsService sysTeacherCadreMeetingMaterialsService;

    /**
     * 查询团干部会议佐证材料列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:caderMeetingMaterials:list')")
    @GetMapping("/list")
    @ApiOperation("查询团干部会议佐证材料列表")
    public TableDataInfo list(SysTeacherCadreMeetingMaterials sysTeacherCadreMeetingMaterials) {
        startPage();
        List<SysTeacherCadreMeetingMaterials> list = sysTeacherCadreMeetingMaterialsService.selectSysTeacherCadreMeetingMaterialsList(sysTeacherCadreMeetingMaterials);
        return getDataTable(list);
    }

    /**
     * 导出团干部会议佐证材料列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:caderMeetingMaterials:export')")
    @Log(title = "团干部会议佐证材料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出团干部会议佐证材料列表")
    public void export(HttpServletResponse response, SysTeacherCadreMeetingMaterials sysTeacherCadreMeetingMaterials) {
        List<SysTeacherCadreMeetingMaterials> list = sysTeacherCadreMeetingMaterialsService.selectSysTeacherCadreMeetingMaterialsList(sysTeacherCadreMeetingMaterials);
        ExcelUtil<SysTeacherCadreMeetingMaterials> util = new ExcelUtil<SysTeacherCadreMeetingMaterials>(SysTeacherCadreMeetingMaterials.class);
        util.exportExcel(response, list, "团干部会议佐证材料数据");
    }

    /**
     * 获取团干部会议佐证材料详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:caderMeetingMaterials:list')")
    @GetMapping(value = "/{id}")
    @ApiOperation("根据名称年月获取团干部会议佐证材料列表")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysTeacherCadreMeetingMaterialsService.selectSysTeacherCadreMeetingMaterialsById(id));
    }

    /**
     * 根据辅导员名称、年份 月份 查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:caderMeetingMaterials:query')")
    @GetMapping(value = "/getByFdyNameAndYearAndMonth")
    @ApiOperation("获取团干部会议佐证材料详细信息")
    public TableDataInfo getByFdyNameAndYearAndMonth(@RequestParam String fdyName,@RequestParam String fillingYear,@RequestParam String fillingMonth) {
        startPage();
        List<SysTeacherCadreMeetingMaterials> sysTeacherCadreMeetingMaterials = sysTeacherCadreMeetingMaterialsService.selectSysTeacherCadreMeetingMaterialsByFdyName(fdyName, fillingYear, fillingMonth);
        return getDataTable(sysTeacherCadreMeetingMaterials);
    }

    /**
     * 新增团干部会议佐证材料
     */
    @PreAuthorize("@ss.hasPermi('teacher:caderMeetingMaterials:add')")
    @Log(title = "团干部会议佐证材料", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增团干部会议佐证材料")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult add(@RequestBody SysTeacherCadreMeetingMaterials sysTeacherCadreMeetingMaterials) {
        return toAjax(sysTeacherCadreMeetingMaterialsService.insertSysTeacherCadreMeetingMaterials(sysTeacherCadreMeetingMaterials));
    }

    /**
     * 修改团干部会议佐证材料
     */
    @PreAuthorize("@ss.hasPermi('teacher:caderMeetingMaterials:edit')")
    @Log(title = "团干部会议佐证材料", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改团干部会议佐证材料")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult edit(@RequestBody SysTeacherCadreMeetingMaterials sysTeacherCadreMeetingMaterials) {
        return toAjax(sysTeacherCadreMeetingMaterialsService.updateSysTeacherCadreMeetingMaterials(sysTeacherCadreMeetingMaterials));
    }

    /**
     * 删除团干部会议佐证材料
     */
    @PreAuthorize("@ss.hasPermi('teacher:caderMeetingMaterials:remove')")
    @Log(title = "团干部会议佐证材料", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除团干部会议佐证材料")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysTeacherCadreMeetingMaterialsService.deleteSysTeacherCadreMeetingMaterialsByIds(ids));
    }
}
