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

import cn.com.victorysoft.business.condition.entity.ConditionUnit;
import cn.com.victorysoft.business.condition.service.ConditionUnitService;
import cn.com.victorysoft.business.sys.entity.ExportResult;
import cn.com.victorysoft.business.sys.param.UnitDatePageExportParam;
import cn.com.victorysoft.business.sys.param.UnitDatePageParam;
import cn.com.victorysoft.business.util.ExcelUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "注水井工况单位统计")
@RestController
@RequestMapping("condition/conditionUnit")
public class ConditionUnitController {
    @Resource
    private ConditionUnitService unitDailyService;

    @GetMapping("/list")
    @ApiOperation("查询本单位及子单位数据")
    public List<ConditionUnit> list(UnitDatePageParam param) {
        return unitDailyService.selectUnitChildren(param);
    }

    @PostMapping("/export")
    @ApiOperation("导出数据")
    public ExportResult export(@RequestBody UnitDatePageExportParam param) {
        List<ConditionUnit> list = unitDailyService.selectUnitChildren(param);
        return ExcelUtils.export(param.getColumnConfig(), list, param.getFileName());
    }

}
