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.ServletUtils;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.core.security.LoginUser;
import com.fs.course.domain.FsCourseSopLogs;
import com.fs.course.param.FsCourseSopLogsParam;
import com.fs.course.service.IFsCourseSopLogsService;
import com.fs.course.vo.FsCourseSopLogsCVOList;
import com.fs.common.annotation.Log;
import com.fs.core.web.service.TokenService;
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;

    @Autowired
    private TokenService tokenService;

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

    /**
     * 查询看课SOP  定时任务列表
     */
    @PreAuthorize("@ss.hasPermi('course:sopLogs:CVOList')")
    @GetMapping("/CVOList")
    public TableDataInfo selectFsCourseSopLogsCVOList(FsCourseSopLogsParam param)
    {
        startPage();
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.setCompanyId( loginUser.getCompany().getCompanyId());

        List<FsCourseSopLogsCVOList> list = fsSopLogsService.selectFsCourseSopLogsCVOList(param);

        return getDataTable(list);
    }

    /**
     * 查询看课SOP  定时任务列表
     */
    @PreAuthorize("@ss.hasPermi('course:sopLogs:myCVOList')")
    @GetMapping("/myCVOList")
    public TableDataInfo selectFsCourseSopLogsMyCVOList(FsCourseSopLogsParam param)
    {
        startPage();
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.setCompanyId( loginUser.getCompany().getCompanyId());
        param.setQwUserid(1L);
        List<FsCourseSopLogsCVOList> list = fsSopLogsService.selectFsCourseSopLogsCVOList(param);

        return getDataTable(list);
    }


    /**
     * 导出看课SOP  定时任务列表
     */
    @PreAuthorize("@ss.hasPermi('course:sopLogs:export')")
    @Log(title = "看课SOP  定时任务", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsCourseSopLogsParam param)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.setCompanyId( loginUser.getCompany().getCompanyId());

        List<FsCourseSopLogsCVOList> list = fsSopLogsService.selectFsCourseSopLogsCVOList(param);
        ExcelUtil<FsCourseSopLogsCVOList> util = new ExcelUtil<FsCourseSopLogsCVOList>(FsCourseSopLogsCVOList.class);
        return util.exportExcel(list, "看课SOP  定时任务数据");
    }

    /**
     * 导出看课SOP  定时任务列表
     */
    @PreAuthorize("@ss.hasPermi('course:sopLogs:myExport')")
    @Log(title = "看课SOP  定时任务", businessType = BusinessType.EXPORT)
    @GetMapping("/myExport")
    public AjaxResult myExport(FsCourseSopLogsParam param)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.setCompanyId( loginUser.getCompany().getCompanyId());
        param.setQwUserid(1L);
        List<FsCourseSopLogsCVOList> list = fsSopLogsService.selectFsCourseSopLogsCVOList(param);
        ExcelUtil<FsCourseSopLogsCVOList> util = new ExcelUtil<FsCourseSopLogsCVOList>(FsCourseSopLogsCVOList.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));
    }
}
