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.SysTeacherExercise;
import com.srs.teacher.service.ISysTeacherExerciseService;
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;

/**
 * exerciseController
 *
 * @author srs
 * @date 2024-06-05
 */
@RestController
@RequestMapping("/teacher/exercise")
@Api(value = "辅导员岗位锻炼管理", tags = "辅导员岗位锻炼管理")
public class SysTeacherExerciseController extends BaseController {
    @Autowired
    private ISysTeacherExerciseService sysTeacherExerciseService;

    /**
     * 查询exercise列表
     */
@PreAuthorize("@ss.hasPermi('teacher:exercise:list')")
@GetMapping("/list")
@ApiOperation("查询exercise列表")
    public TableDataInfo list(SysTeacherExercise sysTeacherExercise)
    {
        startPage();
        List<SysTeacherExercise> list = sysTeacherExerciseService.selectSysTeacherExerciseList(sysTeacherExercise);
        return getDataTable(list);
    }

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

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

    /**
     * 新增exercise
     */
    @PreAuthorize("@ss.hasPermi('teacher:exercise:add')")
    @Log(title = "exercise", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增exercise")
    public AjaxResult add(@RequestBody SysTeacherExercise sysTeacherExercise)
    {
        return toAjax(sysTeacherExerciseService.insertSysTeacherExercise(sysTeacherExercise));
    }

    /**
     * 修改exercise
     */
    @PreAuthorize("@ss.hasPermi('teacher:exercise:edit')")
    @Log(title = "exercise", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改exercise")
    public AjaxResult edit(@RequestBody SysTeacherExercise sysTeacherExercise)
    {
        return toAjax(sysTeacherExerciseService.updateSysTeacherExercise(sysTeacherExercise));
    }

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