-
Notifications
You must be signed in to change notification settings - Fork 4
/
SmsServiceImpl.kt
34 lines (29 loc) · 1.08 KB
/
SmsServiceImpl.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.akagiyui.drive.service.impl
import com.akagiyui.common.delegate.LoggerDelegate
import com.akagiyui.common.notifier.AliyunSmsCodePusher
import com.akagiyui.drive.service.ActionLogService
import com.akagiyui.drive.service.SettingService
import com.akagiyui.drive.service.SmsService
import org.springframework.stereotype.Service
/**
* 短信 Service 实现类
* @author AkagiYui
*/
@Service
class SmsServiceImpl(
private val settingService: SettingService,
private val aLog: ActionLogService,
) : SmsService {
private val log by LoggerDelegate()
override fun sendSmsOneTimePassword(phone: String, otp: String) {
val pusher = AliyunSmsCodePusher(
settingService.aliyunSmsAccessKeyId,
settingService.aliyunSmsAccessKeySecret,
settingService.aliyunSmsSignName,
settingService.aliyunSmsTemplateCode
)
aLog.log("SYSTEM", "SMS", "send sms to $phone, otp: $otp")
pusher.sendSms(phone, mapOf(settingService.aliyunSmsTemplateCodeParam to otp))
log.info("send sms to $phone, otp: $otp")
}
}