package cn.reghao.tnb.oss.store.service;

import cn.reghao.tnb.oss.api.dto.NodeProperties;
import cn.reghao.tnb.oss.api.dto.ObjectChannel;
import cn.reghao.tnb.oss.api.dto.StoreNodeDto;
import cn.reghao.tnb.oss.api.iface.ConsoleService;
import org.springframework.stereotype.Service;

import jakarta.annotation.PostConstruct;

/**
 * 对 rpc 服务 ConsoleService 的一个包装, 目前只是简单调用 ConsoleService 的接口, 后期可添加缓存减少对 rpc 接口的调用
 *
 * @author reghao
 * @date 2024-12-09 10:39:08
 */
@Service
public class ConsoleServiceWrapper {
    private final ConsoleService consoleService;

    public ConsoleServiceWrapper(ConsoleService consoleService) {
        this.consoleService = consoleService;
    }

    @PostConstruct
    public void initCache() {
    }

    public void registerNode(StoreNodeDto storeNodeDto) {
        consoleService.registerNode(storeNodeDto);
    }

    public ObjectChannel getChannelByCode(int owner, int channelCode) {
        return consoleService.getChannelByCode(owner, channelCode);
    }

    public NodeProperties getNodeProperties(String domain) {
        NodeProperties nodeProperties = consoleService.getNodeProperties(domain);
        return nodeProperties;
    }

    public Integer getChannelCodeByUrl(int owner, String url) {
        return consoleService.getChannelCodeByUrl(owner, url);
    }
}
