package com.example.demo.Controller;

import com.alibaba.fastjson.JSON;
import com.example.demo.repo.ExporTexcelRepo;
import com.example.demo.util.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

/**
 * @Project : huimv.shiwan
 * @Package : com.huimv.exportexcel
 * @Description : TODO
 * @Author : yuxuexuan
 * @Create : 2021/1/27 0027 18:41
 **/
@RestController
@RequestMapping("/exportexcel")
public class ExportexcelController {
    @Autowired
    private ExporTexcelRepo exporTexcelRepo;


    @GetMapping("/first")
    public void exportexcel(HttpServletResponse response){
        List<String> titleList = Arrays.asList("序号","姓名", "进/出", "时间");
        List dataList =(List) JSON.parse( exporTexcelRepo.findById(1).get().getTrip());
        ExcelUtil.uploadExcelAboutUser(response,"人员进出记录.xlsx",titleList,dataList);
    }

}
