|
2 | 2 |
|
3 | 3 | import com.unithon.ddoeunyeong.domain.advice.dto.AdvicePreviewListResponse; |
4 | 4 | import com.unithon.ddoeunyeong.domain.advice.dto.AdviceReportResponse; |
| 5 | +import com.unithon.ddoeunyeong.domain.advice.dto.AdviceVideoResponse; |
5 | 6 | import com.unithon.ddoeunyeong.domain.advice.entity.Advice; |
6 | 7 | import com.unithon.ddoeunyeong.domain.advice.entity.AdviceStatus; |
7 | 8 | import com.unithon.ddoeunyeong.domain.advice.entity.Emotion; |
@@ -40,19 +41,28 @@ public Advice createAdviceBeforeSurvey(Long childId) { |
40 | 41 |
|
41 | 42 | @Transactional |
42 | 43 | public Advice startAdviceSession(Long adviceId, String sessionId) { |
43 | | - Advice advice = adviceRepository.findById(adviceId).orElse(null); |
| 44 | + Advice advice = adviceRepository.findById(adviceId) |
| 45 | + .orElseThrow(() -> new CustomException(ErrorCode.NO_ADVICE)); |
44 | 46 | advice.updateSessionId(sessionId); |
45 | 47 | advice.updateStatus(AdviceStatus.IN_PROGRESS); |
46 | 48 | return adviceRepository.save(advice); |
47 | 49 | } |
48 | 50 |
|
49 | 51 | @Transactional |
50 | 52 | public void finishAdviceSession(Long adviceId, String s3Url, AdviceStatus status) { |
51 | | - Advice advice = adviceRepository.findById(adviceId).orElseThrow(); |
| 53 | + Advice advice = adviceRepository.findById(adviceId) |
| 54 | + .orElseThrow(() -> new CustomException(ErrorCode.NO_ADVICE)); |
52 | 55 | if (s3Url != null) advice.saveVideoUrl(s3Url); |
53 | 56 | advice.updateStatus(status); |
54 | 57 | } |
55 | 58 |
|
| 59 | + public AdviceVideoResponse getVideoUrl(Long adviceId){ |
| 60 | + Advice advice = adviceRepository.findById(adviceId) |
| 61 | + .orElseThrow(() -> new CustomException(ErrorCode.NO_ADVICE)); |
| 62 | + |
| 63 | + return new AdviceVideoResponse(advice.getVideoUrl()); |
| 64 | + } |
| 65 | + |
56 | 66 | public AdvicePreviewListResponse getAdviceList(Long childId) { |
57 | 67 | // childId로 Advice 목록 조회 (예: 최신순) |
58 | 68 | List<Advice> adviceList = adviceRepository.findTop6ByChildIdOrderByCreatedAtDesc(childId); |
|
0 commit comments