fix: better manager response (#39)
Release package / release (push) Successful in 16m46s

Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com>
Reviewed-on: #39
This commit was merged in pull request #39.
This commit is contained in:
2026-04-28 07:23:30 +00:00
parent dd2e53e24d
commit 5434445a4c
2 changed files with 8 additions and 2 deletions
@@ -1,7 +1,9 @@
package com.drinkool.services; package com.drinkool.services;
import com.drinkool.Role;
import com.drinkool.Url; import com.drinkool.Url;
import com.drinkool.dtos.SmsOtp; import com.drinkool.dtos.SmsOtp;
import com.drinkool.entities.ManagerEntity;
import com.drinkool.models.UserModel; import com.drinkool.models.UserModel;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.ws.rs.*; import jakarta.ws.rs.*;
@@ -22,11 +24,14 @@ public class AccountService {
.entity("InvalidPhoneNumber") .entity("InvalidPhoneNumber")
.build(); .build();
if (
ManagerEntity.find("phone", input.phone).firstResult() != null
) return Response.accepted().entity(Role.Manager).build();
String otp = otpService.generateAndSaveOtp(input.phone); 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); System.out.println("OTP cho " + input.phone + " là: " + otp);
return Response.accepted().build(); return Response.accepted().entity(Role.Customer).build();
} }
} }
@@ -62,6 +62,7 @@ public class ManagerService extends BaseService<ManagerEntity> {
return Response.accepted() return Response.accepted()
.header(InternalValue.userId, customer.id.toString()) .header(InternalValue.userId, customer.id.toString())
.header(InternalValue.role, Role.Manager) .header(InternalValue.role, Role.Manager)
.entity(customer)
.build(); .build();
} }
} }