From 32ad7024dda6accb6ee4e416bf5055b32e8d36dd Mon Sep 17 00:00:00 2001 From: kang Date: Sat, 14 Sep 2024 02:42:13 +0900 Subject: [PATCH 1/7] chore: update yml --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4f087c6f..d7e273d6 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ build/ ### YML ### application-* - +application.yml ### KEY ### *.json From e227042ecb7cbafe813c1f0760a1af141331ce37 Mon Sep 17 00:00:00 2001 From: kang Date: Sat, 14 Sep 2024 02:42:48 +0900 Subject: [PATCH 2/7] chore: update yml --- src/main/resources/application.yml | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 src/main/resources/application.yml diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml deleted file mode 100644 index a6e96043..00000000 --- a/src/main/resources/application.yml +++ /dev/null @@ -1,4 +0,0 @@ -spring: - profiles: - active: develop, gcs - From c52384775aa0757cb081faae036ec68eb51bbd32 Mon Sep 17 00:00:00 2001 From: kang Date: Sat, 14 Sep 2024 02:47:30 +0900 Subject: [PATCH 3/7] chore: update gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index d7e273d6..d0300e34 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ build/ ### YML ### application-* -application.yml ### KEY ### *.json From eb8684df5f5f491bd90b3adcb54e960e8ce3dad0 Mon Sep 17 00:00:00 2001 From: kang Date: Sat, 14 Sep 2024 02:47:48 +0900 Subject: [PATCH 4/7] chore: add yml --- src/main/resources/application.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/main/resources/application.yml diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 00000000..a6e96043 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,4 @@ +spring: + profiles: + active: develop, gcs + From 107d9fea390386f19937febc77db7226e6e70967 Mon Sep 17 00:00:00 2001 From: Yeonsoo Kang <90603399+Kang1221@users.noreply.github.com> Date: Sat, 14 Sep 2024 04:22:34 +0900 Subject: [PATCH 5/7] Update gradle.yml --- .github/workflows/gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 42c97446..cbcc87d5 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -2,7 +2,7 @@ name: Java CI with Gradle on: push: - branches: [ "deploy", "develop" ] + branches: [ "main", "develop" ] permissions: contents: read From 3f5c4aa5e82bcb609891f050ecabf99fa5d27d74 Mon Sep 17 00:00:00 2001 From: Yeonsoo Kang <90603399+Kang1221@users.noreply.github.com> Date: Sat, 14 Sep 2024 04:23:27 +0900 Subject: [PATCH 6/7] Update application.yml --- src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a6e96043..924c25fb 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: - active: develop, gcs + active: product, db, gcs From 1a3d0e9c0ffaef3253848bf2c52004b3051cdd91 Mon Sep 17 00:00:00 2001 From: kang Date: Sat, 14 Sep 2024 04:44:44 +0900 Subject: [PATCH 7/7] feat: add conditional handling for similar product retrieval --- .../orange/ddanzi/service/ProductService.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/co/orange/ddanzi/service/ProductService.java b/src/main/java/co/orange/ddanzi/service/ProductService.java index 66f32802..2208de6f 100644 --- a/src/main/java/co/orange/ddanzi/service/ProductService.java +++ b/src/main/java/co/orange/ddanzi/service/ProductService.java @@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.client.HttpServerErrorException; import org.springframework.web.client.RestTemplate; import java.util.Map; @@ -38,12 +39,17 @@ public class ProductService { @Autowired RestTemplate restTemplate; + @Transactional public ApiResponse getMostSimilarProduct(@RequestBody ProductRequestDto requestDto){ String productId = getMostSimilarProductId(requestDto); - if(productId == null) - return ApiResponse.onFailure(Error.PRODUCT_NOT_FOUND,null); + if(productId == null) { + return ApiResponse.onSuccess(Success.GET_MOST_SIMILAR_PRODUCT_SUCCESS, CheckItemResponseDto.builder() + .productId("") + .productName("") + .imgUrl("") + .build()); + } log.info("Find product by id: {}", productId); - Product product = productRepository.findById(productId).orElseThrow(ProductNotFoundException::new); CheckItemResponseDto responseDto = CheckItemResponseDto.builder() .productId(product.getId()) @@ -75,10 +81,13 @@ public ApiResponse getProductForItem(String productId){ public String getMostSimilarProductId(ProductRequestDto requestDto){ log.info("Start to get more similar product from AI Server"); String path = "/api/v1/image"; - Map result = restTemplate.postForObject(path, requestDto, Map.class); - if(result == null) + try { + Map result = restTemplate.postForObject(path, requestDto, Map.class); + return result.get("productId"); + } catch (HttpServerErrorException e) { + log.error("Server error occurred while fetching similar product", e); return null; - return result.get("productId"); + } }