package com.ruoyi.system.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.ActHistoryDataDAO;
import com.ruoyi.system.dto.Pagination;
import com.ruoyi.system.service.IActHistoryDataService;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * @author haiwe
 * @date 2024/7/24
 * 材料、工资、电力历史数据
 */
@RestController
@RequestMapping("/history")
@RequiredArgsConstructor
public class ActWagesElectricityHistoryDataController {
    private static final Logger log = LoggerFactory.getLogger(ActWagesElectricityHistoryDataController.class);
    private final IActHistoryDataService actHistoryDataService;


    @PostMapping("/save")
    public AjaxResult save(@RequestBody ActHistoryDataDAO actHistoryDataDAO) {
        actHistoryDataService.insert(actHistoryDataDAO);
        return AjaxResult.success("添加成功", null);
    }

    @GetMapping("/getDataById/{id}")
    public AjaxResult getDataById(@PathVariable("id") Integer id) {
        return AjaxResult.success("成功", actHistoryDataService.getById(id));
    }

    @PostMapping("/getData")
    public AjaxResult getData(@RequestBody Pagination pagination) {
        return AjaxResult.success("成功", actHistoryDataService.getData(pagination));
    }
}
