package com.ruoyi.project.aspen.controller;

import java.util.List;
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.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.aspen.domain.TDashboardday;
import com.ruoyi.project.aspen.service.ITDashboarddayService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * DASHBOARD每日抓取数据Controller
 *
 * @author ruoyi
 * @date 2022-02-11
 */
@RestController
@RequestMapping("/aspen/dashboardday")
public class TDashboarddayController extends BaseController
{
    @Autowired
    private ITDashboarddayService tDashboarddayService;

    /**
     * 查询DASHBOARD每日抓取数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TDashboardday tDashboardday)
    {
        startPage();
        List<TDashboardday> list = tDashboarddayService.selectTDashboarddayList(tDashboardday);
        return getDataTable(list);
    }

    /**
     * 查询最近31条DASHBOARD每日抓取数据列表
     */
    @GetMapping("/month")
    public AjaxResult selectLast(TDashboardday tDashboardday)
    {
        List<TDashboardday> list = tDashboarddayService.selectLast(tDashboardday);
        return AjaxResult.success(list);
    }

    /**
     * 导出DASHBOARD每日抓取数据列表
     */
    @Log(title = "DASHBOARD每日抓取数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TDashboardday tDashboardday)
    {
        List<TDashboardday> list = tDashboarddayService.selectTDashboarddayList(tDashboardday);
        ExcelUtil<TDashboardday> util = new ExcelUtil<TDashboardday>(TDashboardday.class);
        return util.exportExcel(list, "dashboardday");
    }

    /**
     * 获取DASHBOARD每日抓取数据详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tDashboarddayService.selectTDashboarddayById(id));
    }

    /**
     * 新增DASHBOARD每日抓取数据
     */
    @Log(title = "DASHBOARD每日抓取数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDashboardday tDashboardday)
    {
        return toAjax(tDashboarddayService.insertTDashboardday(tDashboardday));
    }

    /**
     * 修改DASHBOARD每日抓取数据
     */
    @Log(title = "DASHBOARD每日抓取数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDashboardday tDashboardday)
    {
        return toAjax(tDashboarddayService.updateTDashboardday(tDashboardday));
    }

    /**
     * 删除DASHBOARD每日抓取数据
     */
    @Log(title = "DASHBOARD每日抓取数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tDashboarddayService.deleteTDashboarddayByIds(ids));
    }
}
