package com.tongran.rocketmq.controller;

import com.tongran.common.core.utils.poi.ExcelUtil;
import com.tongran.common.core.web.controller.BaseController;
import com.tongran.common.core.web.domain.AjaxResult;
import com.tongran.common.core.web.page.TableDataInfo;
import com.tongran.common.log.annotation.Log;
import com.tongran.common.log.enums.BusinessType;
import com.tongran.common.security.annotation.RequiresPermissions;
import com.tongran.rocketmq.domain.RmOutboundTrafficStatistics;
import com.tongran.rocketmq.service.IRmOutboundTrafficStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 出省流量统计Controller
 * 
 * @author tongran
 * @date 2026-01-21
 */
@RestController
@RequestMapping("/rmOutboundTrafficStatistics")
public class RmOutboundTrafficStatisticsController extends BaseController
{
    @Autowired
    private IRmOutboundTrafficStatisticsService rmOutboundTrafficStatisticsService;

    /**
     * 查询出省流量统计列表
     */
    @RequiresPermissions("rocketmq:rmOutboundTrafficStatistics:list")
    @GetMapping("/list")
    public TableDataInfo list(RmOutboundTrafficStatistics rmOutboundTrafficStatistics)
    {
        startPage();
        List<RmOutboundTrafficStatistics> list = rmOutboundTrafficStatisticsService.selectRmOutboundTrafficStatisticsList(rmOutboundTrafficStatistics);
        return getDataTable(list);
    }

    /**
     * 导出出省流量统计列表
     */
    @RequiresPermissions("rocketmq:rmOutboundTrafficStatistics:export")
    @Log(title = "出省流量统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RmOutboundTrafficStatistics rmOutboundTrafficStatistics)
    {
        List<RmOutboundTrafficStatistics> list = rmOutboundTrafficStatisticsService.selectRmOutboundTrafficStatisticsList(rmOutboundTrafficStatistics);
        ExcelUtil<RmOutboundTrafficStatistics> util = new ExcelUtil<RmOutboundTrafficStatistics>(RmOutboundTrafficStatistics.class);
        util.exportExcel(response, list, "出省流量统计数据");
    }

    /**
     * 获取出省流量统计详细信息
     */
    @RequiresPermissions("rocketmq:rmOutboundTrafficStatistics:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rmOutboundTrafficStatisticsService.selectRmOutboundTrafficStatisticsById(id));
    }

    /**
     * 新增出省流量统计
     */
    @RequiresPermissions("rocketmq:rmOutboundTrafficStatistics:add")
    @Log(title = "出省流量统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RmOutboundTrafficStatistics rmOutboundTrafficStatistics)
    {
        return toAjax(rmOutboundTrafficStatisticsService.insertRmOutboundTrafficStatistics(rmOutboundTrafficStatistics));
    }

    /**
     * 修改出省流量统计
     */
    @RequiresPermissions("rocketmq:rmOutboundTrafficStatistics:edit")
    @Log(title = "出省流量统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RmOutboundTrafficStatistics rmOutboundTrafficStatistics)
    {
        return toAjax(rmOutboundTrafficStatisticsService.updateRmOutboundTrafficStatistics(rmOutboundTrafficStatistics));
    }

    /**
     * 删除出省流量统计
     */
    @RequiresPermissions("rocketmq:rmOutboundTrafficStatistics:remove")
    @Log(title = "出省流量统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rmOutboundTrafficStatisticsService.deleteRmOutboundTrafficStatisticsByIds(ids));
    }
}
