package com.pm.sms;


import ch.qos.logback.classic.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.springframework.stereotype.Component;

@Component
public class SmsMonitor implements SmsSender{
    @Around("execution(* SmsGateway.sendAlert(..))")
    public Object logSmsSend(ProceedingJoinPoint pjp) throws Throwable {
        long start = System.currentTimeMillis();
        Logger log = null;
        try {
            Object result = pjp.proceed();
            log.info("短信发送成功 | 耗时:{}ms", System.currentTimeMillis()-start);
            return result;
        } catch (Throwable e) {
            log.error("短信发送失败", e);
            throw e;
        }
    }

    @Override
    public boolean sendAlert(String phone, String message) {
        return false;
    }
}