diff --git a/src/main/java/com/umc/naoman/domain/photo/service/FaceDetectionServiceImpl.java b/src/main/java/com/umc/naoman/domain/photo/service/FaceDetectionServiceImpl.java index 66fae00..70508e5 100644 --- a/src/main/java/com/umc/naoman/domain/photo/service/FaceDetectionServiceImpl.java +++ b/src/main/java/com/umc/naoman/domain/photo/service/FaceDetectionServiceImpl.java @@ -2,7 +2,6 @@ import com.amazonaws.services.lambda.AWSLambda; import com.amazonaws.services.lambda.model.InvocationType; import com.amazonaws.services.lambda.model.InvokeRequest; -import com.amazonaws.services.lambda.model.InvokeResult; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.umc.naoman.domain.shareGroup.service.ShareGroupService; @@ -10,7 +9,6 @@ import com.umc.naoman.global.error.code.AwsLambdaErrorCode; import lombok.*; import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import java.util.List; @@ -18,11 +16,11 @@ @Service @RequiredArgsConstructor -public class FaceDetectionServiceImpl implements FaceDetectionService{ - @Value("${spring.lambda.function.detect_face_photo}") - private String detectFacePhotoLambda; - @Value("${spring.lambda.function.join_share_group}") - private String detectFaceShareGroupLambda; +public class FaceDetectionServiceImpl implements FaceDetectionService { + @Value("${spring.lambda.function.detect_face_upload_photo}") + private String detectFaceUploadPhotoLambda; + @Value("${spring.lambda.function.detect_face_join_share_group}") + private String detectFaceJoinShareGroupLambda; private final AWSLambda awsLambda; private final ObjectMapper objectMapper = new ObjectMapper(); private final ShareGroupService shareGroupService; @@ -30,7 +28,7 @@ public class FaceDetectionServiceImpl implements FaceDetectionService{ @Getter @AllArgsConstructor private class DetectFacePhotoPayload { - private List nameList; + private List photoNameList; private List memberIdList; private Long shareGroupId; } @@ -47,17 +45,17 @@ public void detectFaceUploadPhoto(List photoNameList, Long shareGroupId) List memberIdList = shareGroupService.findProfileListByShareGroupId(shareGroupId).stream() .map(profile -> profile.getMember().getId()) .collect(Collectors.toList()); - DetectFacePhotoPayload payLoad = new DetectFacePhotoPayload(photoNameList,memberIdList,shareGroupId); + DetectFacePhotoPayload payLoad = new DetectFacePhotoPayload(photoNameList, memberIdList, shareGroupId); String lambdaPayload = null; try { lambdaPayload = objectMapper.writeValueAsString(payLoad); } catch (JsonProcessingException e) { - throw new BusinessException(AwsLambdaErrorCode.AWS_JsonProcessing_Exception,e); + throw new BusinessException(AwsLambdaErrorCode.AWS_JsonProcessing_Exception, e); } InvokeRequest invokeRequest = new InvokeRequest() - .withInvocationType(InvocationType.Event) - .withFunctionName(detectFacePhotoLambda) + .withInvocationType(InvocationType.Event) //비동기 호출 + .withFunctionName(detectFaceUploadPhotoLambda) .withPayload(lambdaPayload); awsLambda.invoke(invokeRequest); @@ -65,21 +63,19 @@ public void detectFaceUploadPhoto(List photoNameList, Long shareGroupId) @Override public void detectFaceJoinShareGroup(Long memberId, Long shareGroupId) { - DetectFaceShareGroupPayload payLoad = new DetectFaceShareGroupPayload(memberId,shareGroupId); + DetectFaceShareGroupPayload payLoad = new DetectFaceShareGroupPayload(memberId, shareGroupId); String lambdaPayload = null; try { lambdaPayload = objectMapper.writeValueAsString(payLoad); } catch (JsonProcessingException e) { - throw new BusinessException(AwsLambdaErrorCode.AWS_JsonProcessing_Exception,e); + throw new BusinessException(AwsLambdaErrorCode.AWS_JsonProcessing_Exception, e); } InvokeRequest invokeRequest = new InvokeRequest() - .withInvocationType(InvocationType.Event) - .withFunctionName(detectFaceShareGroupLambda) + .withInvocationType(InvocationType.Event) //비동기 호출 + .withFunctionName(detectFaceJoinShareGroupLambda) .withPayload(lambdaPayload); awsLambda.invoke(invokeRequest); } - - } diff --git a/src/main/java/com/umc/naoman/global/config/S3Config.java b/src/main/java/com/umc/naoman/global/config/AwsConfig.java similarity index 98% rename from src/main/java/com/umc/naoman/global/config/S3Config.java rename to src/main/java/com/umc/naoman/global/config/AwsConfig.java index 9788ba6..4c9969f 100644 --- a/src/main/java/com/umc/naoman/global/config/S3Config.java +++ b/src/main/java/com/umc/naoman/global/config/AwsConfig.java @@ -12,7 +12,7 @@ import org.springframework.context.annotation.Primary; @Configuration -public class S3Config { +public class AwsConfig { @Value("${spring.cloud.aws.credentials.access-key}") private String accessKey;