Skip to content

Commit

Permalink
chore: update merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Kang1221 committed Sep 13, 2024
2 parents 175b95d + 1a3d0e9 commit 6904dcb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Java CI with Gradle

on:
push:
branches: [ "deploy", "develop" ]
branches: [ "main", "develop" ]

permissions:
contents: read
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ build/
### YML ###
application-*


### KEY ###
*.json

Expand Down
21 changes: 15 additions & 6 deletions src/main/java/co/orange/ddanzi/service/ProductService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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())
Expand Down Expand Up @@ -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<String, String> result = restTemplate.postForObject(path, requestDto, Map.class);
if(result == null)
try {
Map<String, String> 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");
}
}


Expand Down

0 comments on commit 6904dcb

Please sign in to comment.