chore: update
This commit is contained in:
@@ -27,10 +27,14 @@ public class OtpService {
|
||||
|
||||
countCommands.setex(key, 300, otp);
|
||||
|
||||
String smsStatus = null;
|
||||
|
||||
try {
|
||||
smsApi.sendSMS(phone, "Mã OTP drinkool của bạn là " + otp, 2, "");
|
||||
smsStatus = smsApi.sendSMS(phone, "Mã OTP drinkool của bạn là " + otp);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
System.out.println("SMS API response: " + smsStatus);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,14 @@ public class SmsApi {
|
||||
|
||||
public static final String API_URL = "https://api.speedsms.vn/index.php";
|
||||
protected String mAccessToken;
|
||||
protected String mBrandName;
|
||||
|
||||
public SmsApi(
|
||||
@ConfigProperty(name = "sms.api.token") String accessToken
|
||||
// @ConfigProperty(name = "sms.api.brand") String brandName
|
||||
) {
|
||||
this.mAccessToken = accessToken;
|
||||
this.mBrandName = "";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +54,7 @@ public class SmsApi {
|
||||
* @param
|
||||
* @return: json string
|
||||
* */
|
||||
public String sendSMS(String to, String content, int type, String sender)
|
||||
public String sendSMS(String to, String content)
|
||||
throws IOException {
|
||||
String json =
|
||||
"{\"to\": [\"" +
|
||||
@@ -59,9 +62,9 @@ public class SmsApi {
|
||||
"\"], \"content\": \"" +
|
||||
EncodeNonAsciiCharacters(content) +
|
||||
"\", \"type\":" +
|
||||
type +
|
||||
4 +
|
||||
", \"brandname\":\"" +
|
||||
sender +
|
||||
this.mBrandName +
|
||||
"\"}";
|
||||
URI uri = URI.create(API_URL + "/sms/send");
|
||||
HttpURLConnection conn = (HttpURLConnection) uri.toURL().openConnection();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
quarkus.datasource.db-kind=postgresql
|
||||
quarkus.datasource.username=postgres
|
||||
quarkus.datasource.password=password
|
||||
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/postgres
|
||||
quarkus.datasource.jdbc.url=jdbc:postgresql://host.docker.internal:5432/postgres
|
||||
|
||||
quarkus.hibernate-orm.database.generation=update
|
||||
|
||||
@@ -27,4 +27,7 @@ quarkus.index-dependency.lib.artifact-id=lib
|
||||
quarkus.native.container-build=true
|
||||
quarkus.native.remote-container-build=true
|
||||
quarkus.native.additional-build-args=--initialize-at-run-time=com.password4j.AlgorithmFinder,--future-defaults=all
|
||||
quarkus.native.resources.includes=com/google/i18n/phonenumbers/data/**/*
|
||||
quarkus.native.resources.includes=com/google/i18n/phonenumbers/data/**/*
|
||||
|
||||
# Sms API
|
||||
sms.api.token=vc6kYQey8nFG7uRe7U4eYB3Iwq2JAiQa
|
||||
@@ -147,12 +147,7 @@ public class CustomerServiceTest {
|
||||
String.class
|
||||
);
|
||||
|
||||
verify(smsApiMock).sendSMS(
|
||||
eq(phone),
|
||||
contentCaptor.capture(),
|
||||
anyInt(),
|
||||
anyString()
|
||||
);
|
||||
verify(smsApiMock).sendSMS(eq(phone), contentCaptor.capture());
|
||||
|
||||
// 4. Trích xuất mã OTP từ nội dung tin nhắn đã bắt được
|
||||
// Giả sử tin nhắn có định dạng: "... là 123456"
|
||||
|
||||
@@ -60,12 +60,7 @@ public class OtpServiceTest {
|
||||
String.class
|
||||
);
|
||||
|
||||
verify(smsApiMock).sendSMS(
|
||||
eq(phone),
|
||||
contentCaptor.capture(),
|
||||
anyInt(),
|
||||
anyString()
|
||||
);
|
||||
verify(smsApiMock).sendSMS(eq(phone), contentCaptor.capture());
|
||||
|
||||
// 4. Trích xuất mã OTP từ nội dung tin nhắn đã bắt được
|
||||
// Giả sử tin nhắn có định dạng: "... là 123456"
|
||||
@@ -117,12 +112,7 @@ public class OtpServiceTest {
|
||||
String.class
|
||||
);
|
||||
|
||||
verify(smsApiMock).sendSMS(
|
||||
eq(phone),
|
||||
contentCaptor.capture(),
|
||||
anyInt(),
|
||||
anyString()
|
||||
);
|
||||
verify(smsApiMock).sendSMS(eq(phone), contentCaptor.capture());
|
||||
|
||||
// 4. Trích xuất mã OTP từ nội dung tin nhắn đã bắt được
|
||||
// Giả sử tin nhắn có định dạng: "... là 123456"
|
||||
|
||||
Reference in New Issue
Block a user