package com.tongran.rocketmq.controller;

import com.tongran.common.core.web.controller.BaseController;
import com.tongran.common.core.web.domain.AjaxResult;
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.RmTcpdumpConfig;
import com.tongran.rocketmq.service.IRmTcpdumpConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * tcpdump探测策略Controller
 * 
 * @author tongran
 * @date 2026-01-21
 */
@RestController
@RequestMapping("/rmTcpdumpConfig")
@RequiresPermissions("rocketmq:traffic")
public class RmTcpdumpConfigController extends BaseController
{
    @Autowired
    private IRmTcpdumpConfigService rmTcpdumpConfigService;

    /**
     * 查询tcpdump探测策略列表
     */
    @PostMapping("/list")
    public AjaxResult list(RmTcpdumpConfig rmTcpdumpConfig)
    {
        List<RmTcpdumpConfig> list = rmTcpdumpConfigService.selectRmTcpdumpConfigList(rmTcpdumpConfig);
        return success(list);
    }


    /**
     * 获取tcpdump探测策略详细信息
     */
    @GetMapping(value = "/{clientId}")
    public AjaxResult getInfo(@PathVariable("clientId") String clientId)
    {
        return success(rmTcpdumpConfigService.selectRmTcpdumpConfigByClientId(clientId));
    }

    /**
     * 新增tcpdump探测策略
     */
    @Log(title = "tcpdump探测策略", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RmTcpdumpConfig rmTcpdumpConfig)
    {
        return toAjax(rmTcpdumpConfigService.insertRmTcpdumpConfig(rmTcpdumpConfig));
    }

}
