Skip to content

Commit 5b193db

Browse files
committed
hotfix: videourl
1 parent a55c504 commit 5b193db

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/main/java/com/unithon/ddoeunyeong/domain/advice/controller/AdviceController.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.unithon.ddoeunyeong.domain.advice.dto.AdvicePreviewListResponse;
44
import com.unithon.ddoeunyeong.domain.advice.dto.AdviceReportResponse;
5+
import com.unithon.ddoeunyeong.domain.advice.dto.AdviceResponse;
6+
import com.unithon.ddoeunyeong.domain.advice.dto.AdviceVideoResponse;
57
import com.unithon.ddoeunyeong.domain.advice.service.AdviceService;
68
import com.unithon.ddoeunyeong.global.exception.BaseResponse;
79
import com.unithon.ddoeunyeong.infra.gptapi.dto.GPTAdviceReportResponse;
@@ -32,6 +34,18 @@ public BaseResponse<AdvicePreviewListResponse> getAdviceList(@PathVariable Long
3234
.build();
3335
}
3436

37+
@GetMapping("/advice/{adviceId}/video")
38+
@Operation(summary = "상담 영상 url를 조회하는 API입니다.", description = "해당 API를 호출해서 상담 영상 url를 조회해주세요.")
39+
public BaseResponse<AdviceVideoResponse> getVideoUrl(@PathVariable Long adviceId){
40+
41+
return BaseResponse.<AdviceVideoResponse>builder()
42+
.code(200)
43+
.message("상담 결과가 조회되었습니다.")
44+
.data(adviceService.getVideoUrl(adviceId))
45+
.isSuccess(true)
46+
.build();
47+
}
48+
3549
@GetMapping("/advice/{adviceId}/report")
3650
@Operation(summary = "마지막 상담 결과를 조회하는 API입니다.", description = "해당 API를 호출해서 상담 결과를 출력해주세요.")
3751
public BaseResponse<AdviceReportResponse> getFinalReport(@PathVariable Long adviceId) throws IOException {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.unithon.ddoeunyeong.domain.advice.dto;
2+
3+
public record AdviceVideoResponse(String videoUrl) {
4+
}

src/main/java/com/unithon/ddoeunyeong/domain/advice/service/AdviceService.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.unithon.ddoeunyeong.domain.advice.dto.AdvicePreviewListResponse;
44
import com.unithon.ddoeunyeong.domain.advice.dto.AdviceReportResponse;
5+
import com.unithon.ddoeunyeong.domain.advice.dto.AdviceVideoResponse;
56
import com.unithon.ddoeunyeong.domain.advice.entity.Advice;
67
import com.unithon.ddoeunyeong.domain.advice.entity.AdviceStatus;
78
import com.unithon.ddoeunyeong.domain.advice.entity.Emotion;
@@ -40,19 +41,28 @@ public Advice createAdviceBeforeSurvey(Long childId) {
4041

4142
@Transactional
4243
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));
4446
advice.updateSessionId(sessionId);
4547
advice.updateStatus(AdviceStatus.IN_PROGRESS);
4648
return adviceRepository.save(advice);
4749
}
4850

4951
@Transactional
5052
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));
5255
if (s3Url != null) advice.saveVideoUrl(s3Url);
5356
advice.updateStatus(status);
5457
}
5558

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+
5666
public AdvicePreviewListResponse getAdviceList(Long childId) {
5767
// childId로 Advice 목록 조회 (예: 최신순)
5868
List<Advice> adviceList = adviceRepository.findTop6ByChildIdOrderByCreatedAtDesc(childId);

0 commit comments

Comments
 (0)