package com.srs.teacher.controller;

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.SysTeacherStudy;
import com.srs.teacher.service.ISysTeacherStudyService;
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;

/**
 * studyController
 *
 * @author srs
 * @date 2024-05-28
 */
@RestController
@RequestMapping("/teacher/study")
@Api(value = "study管理", tags = "study管理")
public class SysTeacherStudyController extends BaseController {
    @Autowired
    private ISysTeacherStudyService sysTeacherStudyService;

    /**
     * 查询study列表
     */
@PreAuthorize("@ss.hasPermi('teacher:study:list')")
@GetMapping("/list")
@ApiOperation("查询study列表")
    public TableDataInfo list(SysTeacherStudy sysTeacherStudy)
    {
        startPage();
        List<SysTeacherStudy> list = sysTeacherStudyService.selectSysTeacherStudyList(sysTeacherStudy);
        return getDataTable(list);
    }

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

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

    /**
     * 新增study
     */
    @PreAuthorize("@ss.hasPermi('teacher:study:add')")
    @Log(title = "study", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增study")
    public AjaxResult add(@RequestBody SysTeacherStudy sysTeacherStudy)
    {
        return toAjax(sysTeacherStudyService.insertSysTeacherStudy(sysTeacherStudy));
    }

    /**
     * 修改study
     */
    @PreAuthorize("@ss.hasPermi('teacher:study:edit')")
    @Log(title = "study", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改study")
    public AjaxResult edit(@RequestBody SysTeacherStudy sysTeacherStudy)
    {
        return toAjax(sysTeacherStudyService.updateSysTeacherStudy(sysTeacherStudy));
    }

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