Skip to content

Commit 422f75b

Browse files
authored
Merge pull request #97 from TeamLearningFlow/develop
Develop
2 parents 1da07c1 + 7e3a658 commit 422f75b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/main/java/learningFlow/learningFlow_BE/service/lambda/LambdaService.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.amazonaws.SdkClientException;
44
import com.fasterxml.jackson.databind.JsonNode;
55
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import learningFlow.learningFlow_BE.domain.Resource;
7+
import learningFlow.learningFlow_BE.repository.ResourceRepository;
68
import lombok.RequiredArgsConstructor;
79
import lombok.extern.slf4j.Slf4j;
810
import org.springframework.stereotype.Service;
@@ -20,8 +22,13 @@ public class LambdaService {
2022

2123
private final LambdaClient lambdaClient;
2224
private final ObjectMapper objectMapper;
25+
private final ResourceRepository resourceRepository;
2326

24-
public String invokeLambda(String url,int width, int height) {
27+
public void ClientUrlUpdate(Resource resource, String clientUrl){
28+
resource.setClientUrl(clientUrl);
29+
resourceRepository.save(resource);
30+
}
31+
public String invokeLambda(String url,int width, int height, Resource resource) {
2532
try {
2633
String payload = String.format("{\"url\":\"%s\", \"width\":%d, \"height\":%d}", url, width, height);
2734
SdkBytes payloadBytes = SdkBytes.fromUtf8String(payload);
@@ -58,7 +65,7 @@ public String invokeLambda(String url,int width, int height) {
5865
throw new RuntimeException("Lambda 호출 실패: s3_url이 없음");
5966
}
6067

61-
log.info("✅ Lambda 호출 성공: {}", s3Url);
68+
ClientUrlUpdate(resource, s3Url);
6269
return s3Url;
6370
} catch (IOException e) {
6471
log.error("❌ JSON 파싱 오류 발생", e);
@@ -71,4 +78,5 @@ public String invokeLambda(String url,int width, int height) {
7178
return null;
7279
}
7380
}
81+
7482
}

src/main/java/learningFlow/learningFlow_BE/web/controller/ResourceRestController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public ApiResponse<String> getBlogEpisodeContent(@PathVariable("episode-id") Lon
117117
if (resource.getClientUrl() != null) {
118118
return ApiResponse.onSuccess(resource.getClientUrl());
119119
}
120-
return ApiResponse.onSuccess(lambdaService.invokeLambda(resource.getUrl(), width, height));
120+
return ApiResponse.onSuccess(lambdaService.invokeLambda(resource.getUrl(), width, height, resource));
121121
}
122122

123123
@PostMapping("/{episode-id}/save-progress")

0 commit comments

Comments
 (0)