package cn.reghao.oss.store.rpc;

import cn.reghao.oss.api.constant.UploadChannel;
import cn.reghao.oss.api.dto.ChannelDto;
import cn.reghao.oss.api.iface.ChannelService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author reghao
 * @date 2023-06-02 10:28:28
 */
@DubboService
@Service
public class ChannelServiceImpl implements ChannelService {
    @Override
    public List<ChannelDto> getChannels() {
        List<ChannelDto> list = new ArrayList<>();
        for (UploadChannel channel : UploadChannel.values()) {
            int channelId = channel.getCode();
            String channelPrefix = channel.getPrefix();
            String channelName = channel.name();
            list.add(new ChannelDto(channelPrefix, channelId, channelName));
        }

        return list;
    }
}
