package com.ruoyi.project.system.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.system.domain.TUploadhistory;
import com.ruoyi.project.system.service.ITUploadhistoryService;
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;

/**
 * 上传数据历史Controller
 *
 * @author ruoyi
 * @date 2021-03-24
 */
@RestController
@RequestMapping("/system/uploadhistory")
public class TUploadhistoryController extends BaseController
{
    @Autowired
    private ITUploadhistoryService tUploadhistoryService;

    /**
     * 查询上传数据历史列表
     */
    @PreAuthorize("@ss.hasPermi('system:uploadhistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(TUploadhistory tUploadhistory)
    {
        startPage();
        List<TUploadhistory> list = tUploadhistoryService.selectTUploadhistoryList(tUploadhistory);
        return getDataTable(list);
    }

    /**
     * 导出上传数据历史列表
     */
    @PreAuthorize("@ss.hasPermi('system:uploadhistory:export')")
    @Log(title = "上传数据历史", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TUploadhistory tUploadhistory)
    {
        List<TUploadhistory> list = tUploadhistoryService.selectTUploadhistoryList(tUploadhistory);
        ExcelUtil<TUploadhistory> util = new ExcelUtil<TUploadhistory>(TUploadhistory.class);
        return util.exportExcel(list, "uploadhistory");
    }

    /**
     * 获取上传数据历史详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:uploadhistory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tUploadhistoryService.selectTUploadhistoryById(id));
    }

    /**
     * 新增上传数据历史
     */
    @PreAuthorize("@ss.hasPermi('system:uploadhistory:add')")
    @Log(title = "上传数据历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TUploadhistory tUploadhistory)
    {
        return toAjax(tUploadhistoryService.insertTUploadhistory(tUploadhistory));
    }

    /**
     * 修改上传数据历史
     */
    @PreAuthorize("@ss.hasPermi('system:uploadhistory:edit')")
    @Log(title = "上传数据历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TUploadhistory tUploadhistory)
    {
        return toAjax(tUploadhistoryService.updateTUploadhistory(tUploadhistory));
    }
}
