package com.fs.qw;

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.core.security.LoginUser;
import com.fs.core.web.service.TokenService;
import com.fs.sop.domain.QwSopLogs;
import com.fs.sop.params.QwSopLogsParam;
import com.fs.sop.service.IQwSopLogsService;
import com.fs.sop.vo.QwSopLogsListCVO;
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-08-05
 */
@RestController
@RequestMapping("/qw/sopLogs")
public class QwSopLogsController extends BaseController
{
    @Autowired
    private IQwSopLogsService iQwSopLogsService;

    @Autowired
    private TokenService tokenService;

    /**
     * 查询企业微信SOP  定时任务列表
     */
    @PreAuthorize("@ss.hasPermi('qw:sop:list')")
    @GetMapping("/listCVO")
    public TableDataInfo listCVO(QwSopLogsParam param)
    {
        startPage();

        List<QwSopLogsListCVO> list = iQwSopLogsService.selectQwSopLogsListBySopId(param);
        return getDataTable(list);
    }


    /**
     * 查询企业微信SOP  定时任务列表
     */
    @PreAuthorize("@ss.hasPermi('qw:sopLogs:myList')")
    @GetMapping("/myListCVO")
    public TableDataInfo myListCVO(QwSopLogsParam param)
    {
        startPage();

        List<QwSopLogsListCVO> list = iQwSopLogsService.selectQwSopLogsListBySopId(param);
        return getDataTable(list);
    }

    /**
     * 导出企业微信SOP  定时任务列表
     */
    @PreAuthorize("@ss.hasPermi('qw:sopLogs:export')")
    @Log(title = "企业微信SOP  定时任务", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QwSopLogsParam param)
    {
        List<QwSopLogsListCVO> list = iQwSopLogsService.selectQwSopLogsListBySopId(param);
        ExcelUtil<QwSopLogsListCVO> util = new ExcelUtil<QwSopLogsListCVO>(QwSopLogsListCVO.class);
        return util.exportExcel(list, "企业微信SOP  定时任务数据");
    }


    /**
     * 导出企业微信SOP  定时任务列表
     */
    @PreAuthorize("@ss.hasPermi('qw:sopLogs:myExport')")
    @Log(title = "企业微信SOP  定时任务", businessType = BusinessType.EXPORT)
    @GetMapping("/myExport")
    public AjaxResult myExport(QwSopLogsParam param)
    {
        List<QwSopLogsListCVO> list = iQwSopLogsService.selectQwSopLogsListBySopId(param);
        ExcelUtil<QwSopLogsListCVO> util = new ExcelUtil<>(QwSopLogsListCVO.class);
        return util.exportExcel(list, "企业微信SOP  定时任务数据");
    }

    /**
     * 获取企业微信SOP  定时任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('qw:sopLogs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(iQwSopLogsService.selectQwSopLogsById(id));
    }

    /**
     * 新增企业微信SOP  定时任务
     */
    @PreAuthorize("@ss.hasPermi('qw:sopLogs:add')")
    @Log(title = "企业微信SOP  定时任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwSopLogs QwSopLogs)
    {
        return toAjax(iQwSopLogsService.insertQwSopLogs(QwSopLogs));
    }

    /**
     * 修改企业微信SOP  定时任务
     */
    @PreAuthorize("@ss.hasPermi('qw:sopLogs:edit')")
    @Log(title = "企业微信SOP  定时任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwSopLogs QwSopLogs)
    {
        return toAjax(iQwSopLogsService.updateQwSopLogs(QwSopLogs));
    }

    /**
     * 删除企业微信SOP  定时任务
     */
    @PreAuthorize("@ss.hasPermi('qw:sopLogs:remove')")
    @Log(title = "企业微信SOP  定时任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(iQwSopLogsService.deleteQwSopLogsByIds(ids));
    }
}
