Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Reviewed-on: #13
This commit was merged in pull request #13.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.drinkool.services;
|
||||
|
||||
import com.drinkool.Url;
|
||||
import com.drinkool.dtos.*;
|
||||
import com.drinkool.entities.CustomerEntity;
|
||||
import jakarta.inject.Inject;
|
||||
@@ -7,14 +8,14 @@ import jakarta.transaction.Transactional;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.*;
|
||||
|
||||
@Path("/api")
|
||||
@Path("")
|
||||
public class AuthenticationService {
|
||||
|
||||
@Inject
|
||||
OtpService otpService;
|
||||
|
||||
@POST
|
||||
@Path("/signup")
|
||||
@Path(Url.Signup)
|
||||
@Transactional
|
||||
public Response signup(Signup input) {
|
||||
CustomerEntity newCustomer = new CustomerEntity();
|
||||
@@ -25,7 +26,7 @@ public class AuthenticationService {
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/quickSignup")
|
||||
@Path(Url.QuickSignup)
|
||||
@Transactional
|
||||
public Response quickSignup(QuickSignup input) {
|
||||
CustomerEntity newCustomer = new CustomerEntity();
|
||||
@@ -36,7 +37,7 @@ public class AuthenticationService {
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/login")
|
||||
@Path(Url.Login)
|
||||
public Response login(Login input) {
|
||||
CustomerEntity customer = CustomerEntity.find(
|
||||
"phone",
|
||||
@@ -53,18 +54,7 @@ public class AuthenticationService {
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/sms_otp")
|
||||
public Response smsOtp(SmsOtp input) {
|
||||
String otp = otpService.generateAndSaveOtp(input.phone);
|
||||
|
||||
// Ở đây bạn sẽ gọi Kafka để gửi SMS thực tế
|
||||
System.out.println("OTP cho " + input.phone + " là: " + otp);
|
||||
|
||||
return Response.accepted().build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/quicklogin")
|
||||
@Path(Url.QuickLogin)
|
||||
public Response quickLogin(QuickLogin input) {
|
||||
if (otpService.verifyOtp(input.phone, input.otp)) {
|
||||
return Response.accepted().build();
|
||||
@@ -73,4 +63,15 @@ public class AuthenticationService {
|
||||
.entity("InvalidOTP")
|
||||
.build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path(Url.SmsOtp)
|
||||
public Response smsOtp(SmsOtp input) {
|
||||
String otp = otpService.generateAndSaveOtp(input.phone);
|
||||
|
||||
// Ở đây bạn sẽ gọi Kafka để gửi SMS thực tế
|
||||
System.out.println("OTP cho " + input.phone + " là: " + otp);
|
||||
|
||||
return Response.accepted().build();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user