package com.citygis.web.controller;


import com.citygis.common.annotation.Log;
import com.citygis.common.enums.BusinessType;
import com.citygis.common.utils.poi.ExcelUtil;
import com.citygis.web.domain.TabKafkalog;
import com.citygis.web.service.ITabKafkalogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author citygis
 * @since 2025-01-14
 */
@Api(tags = "kafka监控")
@RestController
@RequestMapping("/web/tab-kafkalog")
public class TabKafkalogController {

    @Resource
    ITabKafkalogService tabKafkalogService;

    @Log(title = "kafka监控", businessType = BusinessType.EXPORT)
    @ApiOperation("导出kafka监控")
    @PostMapping("/export")
    @ResponseBody
    public void export(HttpServletResponse response, @ModelAttribute TabKafkalog tabKafkalog) throws IOException {
        List<TabKafkalog> list = tabKafkalogService.getKafkaLogList(tabKafkalog);
        ExcelUtil<TabKafkalog> util = new ExcelUtil<TabKafkalog>(TabKafkalog.class);
        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("kafka监控数据.xlsx", "UTF-8"));
        util.exportExcel(response, list, "kafka监控数据","kafka监控数据信息");
    }

}

