chore: update

This commit is contained in:
TakahashiNg
2026-04-20 07:21:10 +00:00
parent f6218a933c
commit 7a7beb16d0
5 changed files with 19 additions and 24 deletions
@@ -27,10 +27,14 @@ public class OtpService {
countCommands.setex(key, 300, otp); countCommands.setex(key, 300, otp);
String smsStatus = null;
try { 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) { } catch (IOException e) {
e.printStackTrace(); 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"; public static final String API_URL = "https://api.speedsms.vn/index.php";
protected String mAccessToken; protected String mAccessToken;
protected String mBrandName;
public SmsApi( public SmsApi(
@ConfigProperty(name = "sms.api.token") String accessToken @ConfigProperty(name = "sms.api.token") String accessToken
// @ConfigProperty(name = "sms.api.brand") String brandName
) { ) {
this.mAccessToken = accessToken; this.mAccessToken = accessToken;
this.mBrandName = "";
} }
/** /**
@@ -51,7 +54,7 @@ public class SmsApi {
* @param * @param
* @return: json string * @return: json string
* */ * */
public String sendSMS(String to, String content, int type, String sender) public String sendSMS(String to, String content)
throws IOException { throws IOException {
String json = String json =
"{\"to\": [\"" + "{\"to\": [\"" +
@@ -59,9 +62,9 @@ public class SmsApi {
"\"], \"content\": \"" + "\"], \"content\": \"" +
EncodeNonAsciiCharacters(content) + EncodeNonAsciiCharacters(content) +
"\", \"type\":" + "\", \"type\":" +
type + 4 +
", \"brandname\":\"" + ", \"brandname\":\"" +
sender + this.mBrandName +
"\"}"; "\"}";
URI uri = URI.create(API_URL + "/sms/send"); URI uri = URI.create(API_URL + "/sms/send");
HttpURLConnection conn = (HttpURLConnection) uri.toURL().openConnection(); HttpURLConnection conn = (HttpURLConnection) uri.toURL().openConnection();
@@ -2,7 +2,7 @@
quarkus.datasource.db-kind=postgresql quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=postgres quarkus.datasource.username=postgres
quarkus.datasource.password=password 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 quarkus.hibernate-orm.database.generation=update
@@ -27,4 +27,7 @@ quarkus.index-dependency.lib.artifact-id=lib
quarkus.native.container-build=true quarkus.native.container-build=true
quarkus.native.remote-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.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 String.class
); );
verify(smsApiMock).sendSMS( verify(smsApiMock).sendSMS(eq(phone), contentCaptor.capture());
eq(phone),
contentCaptor.capture(),
anyInt(),
anyString()
);
// 4. Trích xuất mã OTP từ nội dung tin nhắn đã bắt được // 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" // Giả sử tin nhắn có định dạng: "... là 123456"
@@ -60,12 +60,7 @@ public class OtpServiceTest {
String.class String.class
); );
verify(smsApiMock).sendSMS( verify(smsApiMock).sendSMS(eq(phone), contentCaptor.capture());
eq(phone),
contentCaptor.capture(),
anyInt(),
anyString()
);
// 4. Trích xuất mã OTP từ nội dung tin nhắn đã bắt được // 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" // Giả sử tin nhắn có định dạng: "... là 123456"
@@ -117,12 +112,7 @@ public class OtpServiceTest {
String.class String.class
); );
verify(smsApiMock).sendSMS( verify(smsApiMock).sendSMS(eq(phone), contentCaptor.capture());
eq(phone),
contentCaptor.capture(),
anyInt(),
anyString()
);
// 4. Trích xuất mã OTP từ nội dung tin nhắn đã bắt được // 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" // Giả sử tin nhắn có định dạng: "... là 123456"