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.SysTeacherStuActivityMaterials;
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.SysTeacherStuTalkMaterials;
import com.srs.teacher.service.ISysTeacherStuTalkMaterialsService;
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/stuTalkMaterials")
@Api(value = "与带班学生谈心谈话佐证材料管理", tags = "与带班学生谈心谈话佐证材料管理")
public class SysTeacherStuTalkMaterialsController extends BaseController {
    @Autowired
    private ISysTeacherStuTalkMaterialsService sysTeacherStuTalkMaterialsService;

    /**
     * 查询与带班学生谈心谈话列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:stuTalkMaterials:list')")
    @GetMapping("/list")
    @ApiOperation("查询与带班学生谈心谈话列表")
    public TableDataInfo list(SysTeacherStuTalkMaterials sysTeacherStuTalkMaterials) {
        startPage();
        List<SysTeacherStuTalkMaterials> list = sysTeacherStuTalkMaterialsService.selectSysTeacherStuTalkMaterialsList(sysTeacherStuTalkMaterials);
        return getDataTable(list);
    }

    /**
     * 导出与带班学生谈心谈话列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:stuTalkMaterials:export')")
    @Log(title = "与带班学生谈心谈话", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出与带班学生谈心谈话列表")
    public void export(HttpServletResponse response, SysTeacherStuTalkMaterials sysTeacherStuTalkMaterials) {
        List<SysTeacherStuTalkMaterials> list = sysTeacherStuTalkMaterialsService.selectSysTeacherStuTalkMaterialsList(sysTeacherStuTalkMaterials);
        ExcelUtil<SysTeacherStuTalkMaterials> util = new ExcelUtil<SysTeacherStuTalkMaterials>(SysTeacherStuTalkMaterials.class);
        util.exportExcel(response, list, "与带班学生谈心谈话佐证材料数据");
    }

    /**
     * 根据辅导员名称、年份 月份 查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:stuTalkMaterials:list')")
    @GetMapping("/getByFdyNameAndYearAndMonth")
    @ApiOperation("根据名称年月查询与带班学生谈心谈话列表")
    public TableDataInfo getByFdyNameAndYearAndMonth(@RequestParam String fdyName, @RequestParam String fillingYear, @RequestParam String fillingMonth) {
        startPage();
        List<SysTeacherStuTalkMaterials> list = sysTeacherStuTalkMaterialsService.selectSysTeacherStuTalkMaterialsByFdyName(fdyName, fillingYear, fillingMonth);
        return getDataTable(list);
    }

    /**
     * 获取与带班学生谈心谈话详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:stuTalkMaterials:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取与带班学生谈心谈话详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysTeacherStuTalkMaterialsService.selectSysTeacherStuTalkMaterialsById(id));
    }

    /**
     * 新增与带班学生谈心谈话
     */
    @PreAuthorize("@ss.hasPermi('teacher:stuTalkMaterials:add')")
    @Log(title = "与带班学生谈心谈话", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增与带班学生谈心谈话")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult add(@RequestBody SysTeacherStuTalkMaterials sysTeacherStuTalkMaterials) {
        return toAjax(sysTeacherStuTalkMaterialsService.insertSysTeacherStuTalkMaterials(sysTeacherStuTalkMaterials));
    }

    /**
     * 修改与带班学生谈心谈话
     */
    @PreAuthorize("@ss.hasAnyPermi('teacher:stuTalkMaterials:edit,teacher:stuTalkMaterials:add')")
    @Log(title = "与带班学生谈心谈话", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改与带班学生谈心谈话")
    public AjaxResult edit(@RequestBody SysTeacherStuTalkMaterials sysTeacherStuTalkMaterials) {
        return toAjax(sysTeacherStuTalkMaterialsService.updateSysTeacherStuTalkMaterials(sysTeacherStuTalkMaterials));
    }

    /**
     * 删除与带班学生谈心谈话
     */
    @PreAuthorize("@ss.hasPermi('teacher:stuTalkMaterials:remove')")
    @Log(title = "与带班学生谈心谈话", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除与带班学生谈心谈话")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysTeacherStuTalkMaterialsService.deleteSysTeacherStuTalkMaterialsByIds(ids));
    }
}
