From 5f33e438bf7b3f947389cc1676992323db486f86 Mon Sep 17 00:00:00 2001 From: midday2612 Date: Mon, 16 Jun 2025 10:58:48 +0900 Subject: [PATCH] KW-676/feat: getConnectionIdByPassId grpc server --- build.gradle | 12 +++---- .../exception/errorcode/PassErrorCode.java | 3 +- .../grpc/server/PassGrpcServiceImpl.java | 36 +++++++++++++++++++ 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 21ae490..f4f801f 100644 --- a/build.gradle +++ b/build.gradle @@ -72,12 +72,12 @@ dependencies { implementation("org.modelmapper:modelmapper:3.1.1") // (1) hospital-interface 모듈 - implementation "com.doubleo.grpc:hospital-interface:0.3.2" - implementation "com.doubleo.grpc:patient-interface:0.3.2" - implementation "com.doubleo.grpc:member-interface:0.3.2" - implementation "com.doubleo.grpc:log-interface:0.3.2" - implementation "com.doubleo.grpc:acapy-interface:0.3.2" - implementation "com.doubleo.grpc:pass-interface:0.3.2" + implementation "com.doubleo.grpc:hospital-interface:0.3.3" + implementation "com.doubleo.grpc:patient-interface:0.3.3" + implementation "com.doubleo.grpc:member-interface:0.3.3" + implementation "com.doubleo.grpc:log-interface:0.3.3" + implementation "com.doubleo.grpc:acapy-interface:0.3.3" + implementation "com.doubleo.grpc:pass-interface:0.3.3" // (2) gRPC 런타임 implementation "io.grpc:grpc-netty:1.63.0" diff --git a/src/main/java/com/doubleo/passservice/global/exception/errorcode/PassErrorCode.java b/src/main/java/com/doubleo/passservice/global/exception/errorcode/PassErrorCode.java index 3994e24..66e43ae 100644 --- a/src/main/java/com/doubleo/passservice/global/exception/errorcode/PassErrorCode.java +++ b/src/main/java/com/doubleo/passservice/global/exception/errorcode/PassErrorCode.java @@ -10,7 +10,8 @@ public enum PassErrorCode implements BaseErrorCode { PATIENT_ID_REQUIRED_FOR_GUARDIAN(HttpStatus.BAD_REQUEST, "patient id가 필요합니다."), PASS_NOT_FOUND(HttpStatus.NOT_FOUND, "pass를 찾을 수 없습니다."), VISIT_CATEGORY_REQUIRED_FOR_PASS(HttpStatus.BAD_REQUEST, "visit category가 올바르지 않습니다."), - VC_ISSUE_FAILED(HttpStatus.INTERNAL_SERVER_ERROR, "VC 발급에 실패했습니다."); + VC_ISSUE_FAILED(HttpStatus.INTERNAL_SERVER_ERROR, "VC 발급에 실패했습니다."), + CONNECTION_ID_NOT_ASSIGNED(HttpStatus.CONFLICT, "connectionId가 아직 할당되지 않았습니다."); private final HttpStatus httpStatus; private final String message; diff --git a/src/main/java/com/doubleo/passservice/grpc/server/PassGrpcServiceImpl.java b/src/main/java/com/doubleo/passservice/grpc/server/PassGrpcServiceImpl.java index 63c9ff7..4313084 100644 --- a/src/main/java/com/doubleo/passservice/grpc/server/PassGrpcServiceImpl.java +++ b/src/main/java/com/doubleo/passservice/grpc/server/PassGrpcServiceImpl.java @@ -141,4 +141,40 @@ public void updateConnectionState( responseObserver.onNext(response); responseObserver.onCompleted(); } + + @Override + public void getConnectionIdByPassId( + GetConnectionIdByPassIdRequest request, + StreamObserver responseObserver) { + String tenantId = request.getTenantId(); + long passId = request.getPassId(); + + try { + Pass pass = + passRepository + .findById(passId) + .orElseThrow(() -> new CommonException(PassErrorCode.PASS_NOT_FOUND)); + + String connectionId = pass.getDidConnectionId(); + if (connectionId == null) { + throw new CommonException(PassErrorCode.CONNECTION_ID_NOT_ASSIGNED); + } + + GetConnectionIdByPassIdResponse response = + GetConnectionIdByPassIdResponse.newBuilder() + .setConnectionId(connectionId) + .build(); + + responseObserver.onNext(response); + responseObserver.onCompleted(); + + } catch (Exception e) { + log.error( + "[{}] connectionId 조회 실패 - passId: {}, error: {}", + tenantId, + passId, + e.getMessage()); + responseObserver.onError(e); + } + } }