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.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;

import com.srs.teacher.domain.SysTeacherResearch;
import com.srs.teacher.service.ISysTeacherResearchService;
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;

/**
 * researchController
 *
 * @author srs
 * @date 2024-06-29
 */
@RestController
@RequestMapping("/teacher/research")
@Api(value = "research管理", tags = "research管理")
public class SysTeacherResearchController extends BaseController {
    @Autowired
    private ISysTeacherResearchService sysTeacherResearchService;

    /**
     * 查询research列表
     */
@PreAuthorize("@ss.hasPermi('teacher:research:list')")
@GetMapping("/list")
@ApiOperation("查询research列表")
    public TableDataInfo list(SysTeacherResearch sysTeacherResearch)
    {
        startPage();
        List<SysTeacherResearch> list = sysTeacherResearchService.selectSysTeacherResearchList(sysTeacherResearch);
        return getDataTable(list);
    }

    /**
     * 导出research列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:research:export')")
    @Log(title = "research", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出research列表")
    public void export(HttpServletResponse response, SysTeacherResearch sysTeacherResearch)
    {
        List<SysTeacherResearch> list = sysTeacherResearchService.selectSysTeacherResearchList(sysTeacherResearch);
        ExcelUtil<SysTeacherResearch> util = new ExcelUtil<SysTeacherResearch>(SysTeacherResearch.class);
        util.exportExcel(response, list, "research数据");
    }

    /**
     * 获取research详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:research:query')")
    @GetMapping(value = "/{researchId}")
    @ApiOperation("获取research详细信息")
    public AjaxResult getInfo(@PathVariable("researchId") Long researchId)
    {
        return success(sysTeacherResearchService.selectSysTeacherResearchByResearchId(researchId));
    }

    /**
     * 新增research
     */
    @PreAuthorize("@ss.hasPermi('teacher:research:add')")
    @Log(title = "research", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增research")
    public AjaxResult add(@RequestBody SysTeacherResearch sysTeacherResearch)
    {
        return toAjax(sysTeacherResearchService.insertSysTeacherResearch(sysTeacherResearch));
    }

    /**
     * 修改research
     */
    @PreAuthorize("@ss.hasPermi('teacher:research:edit')")
    @Log(title = "research", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改research")
    public AjaxResult edit(@RequestBody SysTeacherResearch sysTeacherResearch)
    {
        return toAjax(sysTeacherResearchService.updateSysTeacherResearch(sysTeacherResearch));
    }

    /**
     * 删除research
     */
    @PreAuthorize("@ss.hasPermi('teacher:research:remove')")
    @Log(title = "research", businessType = BusinessType.DELETE)
    @PostMapping("/{researchIds}")
    @ApiOperation("删除research")
    public AjaxResult remove(@PathVariable Long[] researchIds)
    {
        return toAjax(sysTeacherResearchService.deleteSysTeacherResearchByResearchIds(researchIds));
    }
}
