diff --git a/src/main/java/org/autorepo/server/domain/template/service/TemplateService.java b/src/main/java/org/autorepo/server/domain/template/service/TemplateService.java index 501c61e..7339e13 100644 --- a/src/main/java/org/autorepo/server/domain/template/service/TemplateService.java +++ b/src/main/java/org/autorepo/server/domain/template/service/TemplateService.java @@ -80,23 +80,15 @@ public void saveTemplate(ShareTemplateRequestDto shareTemplateRequestDto, String Repo repo = repoRepository.findByRepoUrl(shareTemplateRequestDto.repoUrl()) .orElseThrow(() -> new EntityNotFoundException(REPO_NOT_FOUND)); - Template existingTemplate = templateRepository.findByRepoAndType(repo, shareTemplateRequestDto.type()) - .orElse(null); - if (existingTemplate != null) { - existingTemplate.updateContent(shareTemplateRequestDto.title(), shareTemplateRequestDto.content(), imageUrl); - templateRepository.save(existingTemplate); - } else { - // 새로운 템플릿 생성 - Template newTemplate = Template.builder() - .repo(repo) - .title(shareTemplateRequestDto.title()) - .content(shareTemplateRequestDto.content()) - .type(shareTemplateRequestDto.type()) - .imageUrl(imageUrl) - .build(); - - templateRepository.save(newTemplate); - } + Template newTemplate = Template.builder() + .repo(repo) + .title(shareTemplateRequestDto.title()) + .content(shareTemplateRequestDto.content()) + .type(shareTemplateRequestDto.type()) + .imageUrl(imageUrl) + .build(); + + templateRepository.save(newTemplate); } diff --git a/src/main/java/org/autorepo/server/global/utils/GitHubService.java b/src/main/java/org/autorepo/server/global/utils/GitHubService.java index 7c6bc7a..07361be 100644 --- a/src/main/java/org/autorepo/server/global/utils/GitHubService.java +++ b/src/main/java/org/autorepo/server/global/utils/GitHubService.java @@ -48,6 +48,7 @@ public ResponseEntity sendRequest(String url, HttpMethod method, HttpHea try { return restTemplate.exchange(url, method, request, String.class); } catch (HttpClientErrorException e) { + System.out.println("GitHub API request failed: " + e.getMessage()); throw new InternalServerException(GITHUB_API_ERROR); } } @@ -60,6 +61,7 @@ public String getFileSha(String url, HttpHeaders headers) { return new org.json.JSONObject(response.getBody()).getString("sha"); } } catch (Exception e) { + System.out.println("Failed to get SHA from GitHub API: " + e.getMessage()); throw new InternalServerException(UNPROCESSABLE_ENTITY); } return null;