package com.tongran.rocketmq.service.impl;

import com.tongran.common.core.utils.DateUtils;
import com.tongran.rocketmq.domain.RmFrpcPortMapping;
import com.tongran.rocketmq.mapper.RmFrpcPortMappingMapper;
import com.tongran.rocketmq.service.IRmFrpcPortMappingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * FRPC端口映射配置Service业务层处理
 * 
 * @author tongran
 * @date 2025-12-19
 */
@Service
public class RmFrpcPortMappingServiceImpl implements IRmFrpcPortMappingService 
{
    @Autowired
    private RmFrpcPortMappingMapper rmFrpcPortMappingMapper;

    /**
     * 查询FRPC端口映射配置
     * 
     * @param id FRPC端口映射配置主键
     * @return FRPC端口映射配置
     */
    @Override
    public RmFrpcPortMapping selectRmFrpcPortMappingById(Long id)
    {
        return rmFrpcPortMappingMapper.selectRmFrpcPortMappingById(id);
    }

    /**
     * 查询FRPC端口映射配置列表
     * 
     * @param rmFrpcPortMapping FRPC端口映射配置
     * @return FRPC端口映射配置
     */
    @Override
    public List<RmFrpcPortMapping> selectRmFrpcPortMappingList(RmFrpcPortMapping rmFrpcPortMapping)
    {
        return rmFrpcPortMappingMapper.selectRmFrpcPortMappingList(rmFrpcPortMapping);
    }

    /**
     * 新增FRPC端口映射配置
     * 
     * @param rmFrpcPortMapping FRPC端口映射配置
     * @return 结果
     */
    @Override
    public int insertRmFrpcPortMapping(RmFrpcPortMapping rmFrpcPortMapping)
    {
        // 清理配置表
        rmFrpcPortMappingMapper.truncateFrpcPortMapping();
        // 插入表
        int rows = rmFrpcPortMappingMapper.insertRmFrpcPortMapping(rmFrpcPortMapping);
        return 1;
    }

    /**
     * 修改FRPC端口映射配置
     * 
     * @param rmFrpcPortMapping FRPC端口映射配置
     * @return 结果
     */
    @Override
    public int updateRmFrpcPortMapping(RmFrpcPortMapping rmFrpcPortMapping)
    {
        rmFrpcPortMapping.setUpdateTime(DateUtils.getNowDate());
        return rmFrpcPortMappingMapper.updateRmFrpcPortMapping(rmFrpcPortMapping);
    }

    /**
     * 批量删除FRPC端口映射配置
     * 
     * @param ids 需要删除的FRPC端口映射配置主键
     * @return 结果
     */
    @Override
    public int deleteRmFrpcPortMappingByIds(Long[] ids)
    {
        return rmFrpcPortMappingMapper.deleteRmFrpcPortMappingByIds(ids);
    }

    /**
     * 删除FRPC端口映射配置信息
     * 
     * @param id FRPC端口映射配置主键
     * @return 结果
     */
    @Override
    public int deleteRmFrpcPortMappingById(Long id)
    {
        return rmFrpcPortMappingMapper.deleteRmFrpcPortMappingById(id);
    }
}
