package vip.xiaonuo.coldchain.core.alarm.service.messagepush.impl;

import org.springframework.stereotype.Service;
import vip.xiaonuo.coldchain.core.alarm.bean.SensorAlarm;
import vip.xiaonuo.coldchain.core.alarm.service.messagepush.MessagePushService;

/**
 * @author jackzhou
 * @version 1.0
 * @project jfcloud-coldchain
 * @description 短信推送实现类
 * @date 2024/11/26
 */
@Service("SMS")
public class SMSPushService implements MessagePushService {

    @Override
    public boolean sendAlarmMessage(SensorAlarm alarm/*, SensorAlarmUser user*/) {
        // 这里是模拟发送短信的实现，具体可以集成第三方短信服务
        String message = buildMessage(alarm);
        System.out.println("发送短信到:  内容: " + message);
        return false;
    }

    @Override
    public boolean sendAlarmRecoverMessage(SensorAlarm alarm, Long firstAlarmTime) {
        return false;
    }

    @Override
    public boolean sendOfflineMessage(SensorAlarm alarm) {
        return false;
    }

    @Override
    public boolean sendOnlineMessage(SensorAlarm alarm, Long firstAlarmTime) {
        return false;
    }

    private String buildMessage(SensorAlarm alarm) {
        return "告警信息：设备 " + alarm.getDeviceName() + " " + alarm.getMessage();
    }
}
