package com.ruoyi.system.controller;

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.DailySys;
import com.ruoyi.system.service.IDailySysService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 记录系统每天需要统计的任务Controller
 * 
 * @author haoitan
 * @date 2024-11-07
 */
@RestController
@RequestMapping("/system/sys")
public class DailySysController extends BaseController
{
    @Autowired
    private IDailySysService dailySysService;

    /**
     * 查询记录系统每天需要统计的任务列表
     */
    @PreAuthorize("@ss.hasPermi('system:sys:list')")
    @GetMapping("/list")
    public TableDataInfo list(DailySys dailySys)
    {
        startPage();
        List<DailySys> list = dailySysService.selectDailySysList(dailySys);
        return getDataTable(list);
    }

    /**
     * 导出记录系统每天需要统计的任务列表
     */
    @PreAuthorize("@ss.hasPermi('system:sys:export')")
    @Log(title = "记录系统每天需要统计的任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DailySys dailySys)
    {
        List<DailySys> list = dailySysService.selectDailySysList(dailySys);
        ExcelUtil<DailySys> util = new ExcelUtil<DailySys>(DailySys.class);
        util.exportExcel(response, list, "记录系统每天需要统计的任务数据");
    }

    /**
     * 获取记录系统每天需要统计的任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:sys:query')")
    @GetMapping(value = "/{dailySysId}")
    public AjaxResult getInfo(@PathVariable("dailySysId") Long dailySysId)
    {
        return success(dailySysService.selectDailySysByDailySysId(dailySysId));
    }

    /**
     * 新增记录系统每天需要统计的任务
     */
    @PreAuthorize("@ss.hasPermi('system:sys:add')")
    @Log(title = "记录系统每天需要统计的任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DailySys dailySys)
    {
        return toAjax(dailySysService.insertDailySys(dailySys));
    }

    /**
     * 修改记录系统每天需要统计的任务
     */
    @PreAuthorize("@ss.hasPermi('system:sys:edit')")
    @Log(title = "记录系统每天需要统计的任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DailySys dailySys)
    {
        return toAjax(dailySysService.updateDailySys(dailySys));
    }

    /**
     * 删除记录系统每天需要统计的任务
     */
    @PreAuthorize("@ss.hasPermi('system:sys:remove')")
    @Log(title = "记录系统每天需要统计的任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dailySysIds}")
    public AjaxResult remove(@PathVariable Long[] dailySysIds)
    {
        return toAjax(dailySysService.deleteDailySysByDailySysIds(dailySysIds));
    }
}
