package com.njcn.msgpush.module.push.client.factory.impl;

import com.njcn.msgpush.module.push.client.factory.MessageProviderFactory;
import com.njcn.msgpush.module.push.client.sender.AppPushSender;
import com.njcn.msgpush.module.push.client.sender.EmailSender;
import com.njcn.msgpush.module.push.client.sender.SmsSender;
import com.njcn.msgpush.module.push.client.sender.impl.TelecomSmsSender;
import com.njcn.msgpush.module.push.client.setting.impl.TelecomSmsSetting;
import com.njcn.msgpush.module.push.dal.dataobject.channel.ChannelProviderConfigDO;
import com.njcn.msgpush.module.push.util.RestTemplateUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * @author caozehui
 * @data 2026-02-11
 */
@Slf4j
public class TelecomProviderFactory implements MessageProviderFactory {
    private RestTemplateUtil restTemplateUtil;

    public TelecomProviderFactory(RestTemplateUtil restTemplateUtil) {
        this.restTemplateUtil = restTemplateUtil;
    }

    @Override
    public SmsSender createSmsSender(ChannelProviderConfigDO config) {
        TelecomSmsSetting telecomSmsSetting = TelecomSmsSetting.builder()
                .account(config.getAppKey())
                .password(config.getAppSecret())
                .build();
        return new TelecomSmsSender(telecomSmsSetting, restTemplateUtil);
    }

    @Override
    public EmailSender createEmailSender(ChannelProviderConfigDO config) throws Exception {
        return null;
    }

    @Override
    public AppPushSender createAppPushSender(ChannelProviderConfigDO config) {
        log.error("电信暂不支持app推送");
        return null;
    }
}
