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.RmFrpcPortMapping;
import com.tongran.rocketmq.service.IRmFrpcPortMappingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * FRPC端口映射配置Controller
 * 
 * @author tongran
 * @date 2025-12-19
 */
@RestController
@RequestMapping("/frpcPortMapping")
@RequiresPermissions("rocketmq:frpcConfigManage")
public class RmFrpcPortMappingController extends BaseController
{
    @Autowired
    private IRmFrpcPortMappingService rmFrpcPortMappingService;

    /**
     * 查询FRPC端口映射配置列表
     */
    @PostMapping("/list")
    public AjaxResult list(@RequestBody RmFrpcPortMapping rmFrpcPortMapping)
    {
        List<RmFrpcPortMapping> list = rmFrpcPortMappingService.selectRmFrpcPortMappingList(rmFrpcPortMapping);
        return success(list);
    }


    /**
     * 获取FRPC端口映射配置详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rmFrpcPortMappingService.selectRmFrpcPortMappingById(id));
    }

    /**
     * 新增FRPC端口映射配置
     */
    @Log(title = "FRPC端口映射配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RmFrpcPortMapping rmFrpcPortMapping)
    {
        return toAjax(rmFrpcPortMappingService.insertRmFrpcPortMapping(rmFrpcPortMapping));
    }
}
