package cn.cecep.talroad.controller;

import cn.cecep.talroad.common.core.utils.poi.ExcelUtil;
import cn.cecep.talroad.common.core.web.controller.BasesController;
import cn.cecep.talroad.common.core.web.domain.AjaxResults;
import cn.cecep.talroad.common.log.annotation.Log;
import cn.cecep.talroad.common.log.enums.BusinessType;
import cn.cecep.talroad.domain.SMainDynamicControlFactory;
import cn.cecep.talroad.service.ISMainDynamicControlFactoryService;
import cn.cecep.talroad.vo.query.SMainDynamicControlFactoryQuery;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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


/**
 * * 开发公司：中节能天融科技有限公司
 * 基本信息-废气、废水排口档案-动态管控信息调整 -参数与企业关联Controller 控制层
 *
 * @author szhpt
 * @date 2023-02-02*/
@Api(tags = "基本信息-废气、废水排口档案-动态管控信息调整 -参数与企业关联")
@RestController
@RequestMapping("/smainDynamicControlFactory")
public class SMainDynamicControlFactoryController extends BasesController
{
    @Autowired
    private ISMainDynamicControlFactoryService sMainDynamicControlFactoryService;

    /**
     * 查询基本信息-废气、废水排口档案-动态管控信息调整 -参数与企业关联列表
     */
    @ApiOperation(value = "查询基本信息-废气、废水排口档案-动态管控信息调整 -参数与企业关联")
    @GetMapping("/list")
    public AjaxResults<IPage<SMainDynamicControlFactory>> list(SMainDynamicControlFactoryQuery sMainDynamicControlFactory)
    {
        Page<SMainDynamicControlFactory> page = new Page<>(sMainDynamicControlFactory.getPageNum(), sMainDynamicControlFactory.getPageSize());
        IPage<SMainDynamicControlFactory> list = sMainDynamicControlFactoryService.page(page, SMainDynamicControlFactoryQuery.createLambdaQueryWrapper(sMainDynamicControlFactory));
        return AjaxResults.success(list);
    }
    

    /**
     * 导出基本信息-废气、废水排口档案-动态管控信息调整 -参数与企业关联列表
     */
    @ApiOperation(value = "导出基本信息-废气、废水排口档案-动态管控信息调整 -参数与企业关联")
    @Log(title = "基本信息-废气、废水排口档案-动态管控信息调整 -参数与企业关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SMainDynamicControlFactory sMainDynamicControlFactory)
    {
        List<SMainDynamicControlFactory> list = sMainDynamicControlFactoryService.selectSMainDynamicControlFactoryList(sMainDynamicControlFactory);
        ExcelUtil<SMainDynamicControlFactory> util = new ExcelUtil<SMainDynamicControlFactory>(SMainDynamicControlFactory.class);
        util.exportExcel(response, list, "基本信息-废气、废水排口档案-动态管控信息调整 -参数与企业关联数据");
    }

    /**
     * 获取基本信息-废气、废水排口档案-动态管控信息调整 -参数与企业关联详细信息
     */
    @ApiOperation(value = "获取基本信息-废气、废水排口档案-动态管控信息调整 -参数与企业关联详细信息")
    @PostMapping(value = "/{id}")
    public AjaxResults<SMainDynamicControlFactory> getInfo(@PathVariable("id") Integer id) {
        return AjaxResults.success(sMainDynamicControlFactoryService.getById(id));
    }
    /**
     * 新增基本信息-废气、废水排口档案-动态管控信息调整 -参数与企业关联
     */
    @ApiOperation(value = "新增基本信息-废气、废水排口档案-动态管控信息调整 -参数与企业关联")
    @Log(title = "基本信息-废气、废水排口档案-动态管控信息调整 -参数与企业关联", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    public AjaxResults<Boolean> add(@RequestBody SMainDynamicControlFactory sMainDynamicControlFactory) {
        return toAjax(sMainDynamicControlFactoryService.save(sMainDynamicControlFactory));
    }
}
