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.SysTeacherCourse;
import com.srs.teacher.service.ISysTeacherCourseService;
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;

/**
 * courseController
 *
 * @author srs
 * @date 2024-06-05
 */
@RestController
@RequestMapping("/teacher/course")
@Api(value = "辅导员课程教学管理", tags = "辅导员课程教学管理")
public class SysTeacherCourseController extends BaseController {
    @Autowired
    private ISysTeacherCourseService sysTeacherCourseService;

    /**
     * 查询course列表
     */
@PreAuthorize("@ss.hasPermi('teacher:course:list')")
@GetMapping("/list")
@ApiOperation("查询course列表")
    public TableDataInfo list(SysTeacherCourse sysTeacherCourse)
    {
        startPage();
        List<SysTeacherCourse> list = sysTeacherCourseService.selectSysTeacherCourseList(sysTeacherCourse);
        return getDataTable(list);
    }

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

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

    /**
     * 新增course
     */
    @PreAuthorize("@ss.hasPermi('teacher:course:add')")
    @Log(title = "course", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增course")
    public AjaxResult add(@RequestBody SysTeacherCourse sysTeacherCourse)
    {
        return toAjax(sysTeacherCourseService.insertSysTeacherCourse(sysTeacherCourse));
    }

    /**
     * 修改course
     */
    @PreAuthorize("@ss.hasPermi('teacher:course:edit')")
    @Log(title = "course", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改course")
    public AjaxResult edit(@RequestBody SysTeacherCourse sysTeacherCourse)
    {
        return toAjax(sysTeacherCourseService.updateSysTeacherCourse(sysTeacherCourse));
    }

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