package com.mzl.flower.service.impl.sms; import com.mzl.flower.config.sms.TosSmsProperties; import com.mzl.flower.service.sms.TosSmsService; import com.volcengine.model.request.SmsSendRequest; import com.volcengine.model.response.SmsSendResponse; import com.volcengine.service.sms.SmsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.Map; @Service public class TosSmsServiceImpl implements TosSmsService { @Autowired private TosSmsProperties tosSmsProperties; @Autowired @Qualifier("volcSmsService") private SmsService smsService; @Override public SmsSendResponse sendSms(SmsSendRequest request) { SmsSendResponse response = null; try { response = smsService.sendV2(request); } catch (Exception e) { throw new RuntimeException(e); } return response; } @Override public SmsSendResponse sendSms(String phonenum, Map params) { SmsSendRequest req = new SmsSendRequest(); req.setPhoneNumbers(phonenum); req.setSmsAccount(tosSmsProperties.getSmsAccount()); req.setTemplateId(tosSmsProperties.getTemplateId()); req.setSign(tosSmsProperties.getSign()); req.setTemplateParamByMap(params); try { SmsSendResponse smsSendResponse = smsService.sendV2(req); return smsSendResponse; } catch (Exception e) { throw new RuntimeException(e); } } @Override public SmsSendResponse sendSms(String phonenum, Map params, String smsAccount, String templateId, String sign) { SmsSendRequest req = new SmsSendRequest(); req.setPhoneNumbers(phonenum); req.setSmsAccount(smsAccount); req.setTemplateId(templateId); req.setSign(sign); req.setTemplateParamByMap(params); try { SmsSendResponse smsSendResponse = smsService.sendV2(req); return smsSendResponse; } catch (Exception e) { throw new RuntimeException(e); } } }