package com.ruoyi.project.aspen.controller;

import java.util.List;

import org.springframework.cache.annotation.Cacheable;
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.TDashboarddata;
import com.ruoyi.project.aspen.service.ITDashboarddataService;
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-01-06
 */
@RestController
@RequestMapping("/aspen/dashboarddata")
public class TDashboarddataController extends BaseController
{
    @Autowired
    private ITDashboarddataService tDashboarddataService;

    /**
     * 查询dashboard抓取数据列表
     */
    @GetMapping("/list")
    public List<TDashboarddata> list(TDashboarddata tDashboarddata)
    {
        List<TDashboarddata> list = tDashboarddataService.selectTDashboarddataList(tDashboarddata);
        return list;
    }

    /**
     * 查询最后一条dashboard抓取数据
     */
    @GetMapping("/selectLast")
    public AjaxResult selectLast(TDashboarddata tDashboarddata)
    {
        TDashboarddata dashboarddata = tDashboarddataService.selectLast(tDashboarddata);
        return AjaxResult.success(dashboarddata);
    }

    /**
     * 导出dashboard抓取数据列表
     */
    @Log(title = "dashboard抓取数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TDashboarddata tDashboarddata)
    {
        List<TDashboarddata> list = tDashboarddataService.selectTDashboarddataList(tDashboarddata);
        ExcelUtil<TDashboarddata> util = new ExcelUtil<TDashboarddata>(TDashboarddata.class);
        return util.exportExcel(list, "dashboarddata");
    }

    /**
     * 获取dashboard抓取数据详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tDashboarddataService.selectTDashboarddataById(id));
    }

    /**
     * 新增dashboard抓取数据
     */
    @Log(title = "dashboard抓取数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDashboarddata tDashboarddata)
    {
        return toAjax(tDashboarddataService.insertTDashboarddata(tDashboarddata));
    }

    /**
     * 修改dashboard抓取数据
     */
    @Log(title = "dashboard抓取数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDashboarddata tDashboarddata)
    {
        return toAjax(tDashboarddataService.updateTDashboarddata(tDashboarddata));
    }

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