Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public class RepoController {
// 리포지토리 URL을 통한 등록 확인
@GetMapping("/check")
public ResponseEntity<RepoResponseDto> checkRepoExists(@RequestParam String url) {
RepoResponseDto response = repoService.findRepoByUrl(url);
return ResponseEntity.ok(response);
return repoService.findRepoByUrl(url) // Optional<RepoResponseDto>를 받음
.map(ResponseEntity::ok) // 값이 있으면 200 OK와 함께 body에 담아 반환
.orElseGet(() -> ResponseEntity.noContent().build()); // 값이 없으면 204 No Content 반환
}

// 리포지토리 정보 조회
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

Expand All @@ -16,8 +15,5 @@ public class RepoResponseDto {
private final String language;
private final String description;
private final LocalDateTime githubLastUpdatedAt;
private final LocalDateTime lastSyncedAt;

@Setter // Mapper의 @AfterMapping에서 이 값을 설정
private boolean updateNeeded; // 재동기화 필요 여부 플래그
}
16 changes: 6 additions & 10 deletions src/main/java/com/teamEWSN/gitdeun/repo/service/RepoService.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.Optional;

@Service
@RequiredArgsConstructor
Expand All @@ -23,22 +24,17 @@ public class RepoService {
private final RepoMapper repoMapper;
private final FastApiClient fastApiClient;

/**
* Mapper를 통해 'updateNeeded' 플래그가 포함된 DTO를 반환합니다.
*/
// 레포지토리 ID로 정보 조회
public RepoResponseDto findRepoById(Long repoId) {
Repo repo = repoRepository.findById(repoId)
.orElseThrow(() -> new GlobalException(ErrorCode.REPO_NOT_FOUND_BY_ID));
return repoMapper.toResponseDto(repo);
}

/**
* 리포지토리 URL로 정보를 조회
*/
public RepoResponseDto findRepoByUrl(String url) {
Repo repo = repoRepository.findByGithubRepoUrl(url)
.orElseThrow(() -> new GlobalException(ErrorCode.REPO_NOT_FOUND_BY_URL));
return repoMapper.toResponseDto(repo);
// 리포지토리 URL을 통한 조회하여 등록 확인
public Optional<RepoResponseDto> findRepoByUrl(String url) {
return repoRepository.findByGithubRepoUrl(url)
.map(repoMapper::toResponseDto);
}

/**
Expand Down