33import com .amazonaws .SdkClientException ;
44import com .fasterxml .jackson .databind .JsonNode ;
55import com .fasterxml .jackson .databind .ObjectMapper ;
6+ import learningFlow .learningFlow_BE .domain .Resource ;
7+ import learningFlow .learningFlow_BE .repository .ResourceRepository ;
68import lombok .RequiredArgsConstructor ;
79import lombok .extern .slf4j .Slf4j ;
810import 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}
0 commit comments