package com.fs.course.controller;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.course.domain.FsCourseSopLogs;
import com.fs.course.service.IFsCourseSopLogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 看课SOP  定时任务Controller
 *
 * @author fs
 * @date 2024-09-04
 */
@RestController
@RequestMapping("/course/sopLogs")
public class FsCourseSopLogsController extends BaseController
{
    @Autowired
    private IFsCourseSopLogsService fsSopLogsService;

    /**
     * 查询看课SOP  定时任务列表
     */
    @PreAuthorize("@ss.hasPermi('course:sopLogs:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsCourseSopLogs fsSopLogs)
    {
        startPage();
        List<FsCourseSopLogs> list = fsSopLogsService.selectFsCourseSopLogsList(fsSopLogs);
        return getDataTable(list);
    }

    /**
     * 导出看课SOP  定时任务列表
     */
    @PreAuthorize("@ss.hasPermi('course:sopLogs:export')")
    @Log(title = "看课SOP  定时任务", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsCourseSopLogs fsSopLogs)
    {
        List<FsCourseSopLogs> list = fsSopLogsService.selectFsCourseSopLogsList(fsSopLogs);
        ExcelUtil<FsCourseSopLogs> util = new ExcelUtil<FsCourseSopLogs>(FsCourseSopLogs.class);
        return util.exportExcel(list, "看课SOP  定时任务数据");
    }

    /**
     * 获取看课SOP  定时任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:sopLogs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsSopLogsService.selectFsCourseSopLogsById(id));
    }

    /**
     * 新增看课SOP  定时任务
     */
    @PreAuthorize("@ss.hasPermi('course:sopLogs:add')")
    @Log(title = "看课SOP  定时任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsCourseSopLogs fsSopLogs)
    {
        return toAjax(fsSopLogsService.insertFsCourseSopLogs(fsSopLogs));
    }

    /**
     * 修改看课SOP  定时任务
     */
    @PreAuthorize("@ss.hasPermi('course:sopLogs:edit')")
    @Log(title = "看课SOP  定时任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsCourseSopLogs fsSopLogs)
    {
        return toAjax(fsSopLogsService.updateFsCourseSopLogs(fsSopLogs));
    }

    /**
     * 删除看课SOP  定时任务
     */
    @PreAuthorize("@ss.hasPermi('course:sopLogs:remove')")
    @Log(title = "看课SOP  定时任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsSopLogsService.deleteFsCourseSopLogsByIds(ids));
    }
}
