package com.ruoyi.ss.channel.service.impl;

import com.ruoyi.common.core.domain.BaseValidator;
import com.ruoyi.ss.channel.domain.Channel;
import com.ruoyi.ss.channel.service.ChannelService;
import com.ruoyi.ss.channel.service.ChannelValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author wjh
 * 2024/5/5
 */
@Service
public class ChannelValidatorImpl extends BaseValidator implements ChannelValidator {

    @Autowired
    private ChannelService channelService;

    /**
     * 判断渠道是否可用
     *
     * @param channelId
     * @return
     */
    @Override
    public boolean isEnabled(Long channelId) {
        if (channelId == null) {
            return false;
        }
        Channel channel = channelService.selectSmChannelByChannelId(channelId);
        return channel != null && channel.getEnabled() != null && channel.getEnabled();
    }
}
