package com.ruoyi.web.controller.course;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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 com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CourseTableTime;
import com.ruoyi.system.service.ICourseTableTimeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程-时间Controller
 * 
 * @author ruoyi
 * @date 2023-05-24
 */
@RestController
@RequestMapping("/course/time")
public class CourseTableTimeController extends BaseController
{
    @Autowired
    private ICourseTableTimeService courseTableTimeService;

    /**
     * 查询课程-时间列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CourseTableTime courseTableTime)
    {
        startPage();
        List<CourseTableTime> list = courseTableTimeService.selectCourseTableTimeList(courseTableTime);
        return getDataTable(list);
    }

    /**
     * 导出课程-时间列表
     */
    @PreAuthorize("@ss.hasPermi('course:time:export')")
    @Log(title = "课程-时间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CourseTableTime courseTableTime)
    {
        List<CourseTableTime> list = courseTableTimeService.selectCourseTableTimeList(courseTableTime);
        ExcelUtil<CourseTableTime> util = new ExcelUtil<CourseTableTime>(CourseTableTime.class);
        util.exportExcel(response, list, "课程-时间数据");
    }

    /**
     * 获取课程-时间详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(courseTableTimeService.selectCourseTableTimeById(id));
    }

    /**
     * 新增课程-时间
     */
    @PreAuthorize("@ss.hasPermi('course:time:add')")
    @Log(title = "课程-时间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CourseTableTime courseTableTime)
    {
        return toAjax(courseTableTimeService.insertCourseTableTime(courseTableTime));
    }

    /**
     * 修改课程-时间
     */
    @PreAuthorize("@ss.hasPermi('course:time:edit')")
    @Log(title = "课程-时间", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody CourseTableTime courseTableTime)
    {
        return toAjax(courseTableTimeService.updateCourseTableTime(courseTableTime));
    }

    /**
     * 删除课程-时间
     */
    @PreAuthorize("@ss.hasPermi('course:time:remove')")
    @Log(title = "课程-时间", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(courseTableTimeService.deleteCourseTableTimeByIds(ids));
    }
}
