Skip to content

Commit

Permalink
feat: STT 결과에 소유검증 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yugyeom-ghim committed Nov 13, 2024
1 parent c4e726d commit b88d368
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/main/java/notai/stt/application/SttQueryService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package notai.stt.application;

import lombok.RequiredArgsConstructor;
import notai.document.domain.Document;
import notai.document.domain.DocumentRepository;
import notai.member.domain.Member;
import notai.member.domain.MemberRepository;
import notai.stt.domain.Stt;
import notai.stt.domain.SttRepository;
import notai.stt.presentation.response.SttPageResponse;
Expand All @@ -13,10 +17,17 @@
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class SttQueryService {

private final SttRepository sttRepository;
private final MemberRepository memberRepository;
private final DocumentRepository documentRepository;

public SttPageResponse getSttByPage(Long memberId, Long documentId, Integer pageNumber) {
Member member = memberRepository.getById(memberId);
Document foundDocument = documentRepository.getById(documentId);
foundDocument.validateOwner(member);

public SttPageResponse getSttByPage(Long documentId, Integer pageNumber) {
List<Stt> sttResults = sttRepository.findAllByDocumentIdAndPageNumber(documentId, pageNumber);
return SttPageResponse.of(pageNumber, sttResults);
}
}
}
4 changes: 3 additions & 1 deletion src/main/java/notai/stt/presentation/SttController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package notai.stt.presentation;

import lombok.RequiredArgsConstructor;
import notai.auth.Auth;
import notai.stt.application.SttQueryService;
import notai.stt.presentation.response.SttPageResponse;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -16,9 +17,10 @@ public class SttController {

@GetMapping("/documents/{documentId}/pages/{pageNumber}")
public SttPageResponse getSttByPage(
@Auth Long memberId,
@PathVariable Long documentId,
@PathVariable Integer pageNumber
) {
return sttQueryService.getSttByPage(documentId, pageNumber);
return sttQueryService.getSttByPage(memberId, documentId, pageNumber);
}
}

0 comments on commit b88d368

Please sign in to comment.