package cn.com.victorysoft.business.technology.controller;

import cn.com.victorysoft.business.sys.dto.Result;
import cn.com.victorysoft.business.sys.entity.ExportResult;
import cn.com.victorysoft.business.technology.entity.TechJobFee;
import cn.com.victorysoft.business.technology.param.TechJobFeeExportParam;
import cn.com.victorysoft.business.technology.param.TechJobFeeParam;
import cn.com.victorysoft.business.technology.service.TechJobFeeService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.List;

@Api(tags = "历年作业费用")
@RestController
@RequestMapping("technology/techjobFee")
public class TechJobFeeController {
    @Resource
    private TechJobFeeService techJobFeeService;

    @GetMapping("/list")
    @ApiOperation("查询数据")
    public PageInfo<TechJobFee> searchList(TechJobFeeParam param) {
        return techJobFeeService.selectPage(param);
    }

    @GetMapping("/dwList")
    @ApiOperation("查询单位")
    public List<TechJobFee> dwList() {
        return techJobFeeService.selectdwList();
    }

    @GetMapping("/dyList")
    @ApiOperation("查询单元")
    public List<TechJobFee> dyList() {
        return techJobFeeService.selectdyList();
    }

    @GetMapping("/jhList")
    @ApiOperation("查询井号")
    public List<TechJobFee> jhList() {
        return techJobFeeService.selectjhList();
    }

    @GetMapping("/sglbList")
    @ApiOperation("查询施工类别")
    public List<TechJobFee> sglbList() {
        return techJobFeeService.selectsglbList();
    }

    @GetMapping("/sgmdList")
    @ApiOperation("查询施工目的")
    public List<TechJobFee> sgmdList() {
        return techJobFeeService.selectsgmdList();
    }

    @GetMapping("/template")
    @ApiOperation("模板下载")
    public void template(HttpServletResponse response) throws IOException {
        techJobFeeService.downloadTemplate("历年作业费用导入模板.xlsx", response);
    }

    @PostMapping("/upload")
    @ApiOperation("导入")
    public Result upload(MultipartFile file,String dwdm) {
        return techJobFeeService.upload(file,dwdm);
    }

    @PostMapping("/export")
    @ApiOperation("导出数据")
    public ExportResult export(@RequestBody TechJobFeeExportParam param) {
        ExportResult exportResult = techJobFeeService.selectSearchList(param);
        return exportResult;
    }


}
