33import com .moplus .moplus_server .admin .problemset .dto .response .ProblemSetGetResponse ;
44import com .moplus .moplus_server .admin .problemset .dto .response .ProblemSummaryResponse ;
55import com .moplus .moplus_server .client .submit .domain .ProgressStatus ;
6+ import com .moplus .moplus_server .global .error .exception .ErrorCode ;
7+ import com .moplus .moplus_server .global .error .exception .NotFoundException ;
68import java .time .LocalDate ;
79import java .util .List ;
10+ import org .slf4j .Logger ;
11+ import org .slf4j .LoggerFactory ;
812
913public record HomeFeedResponse (
1014 List <DailyProgressResponse > dailyProgresses ,
1115 List <ProblemSetHomeFeedResponse > problemSets
1216) {
17+ private static final Logger log = LoggerFactory .getLogger (HomeFeedResponse .class );
18+
1319 public static HomeFeedResponse of (
1420 List <DailyProgressResponse > dailyProgresses ,
1521 List <ProblemSetHomeFeedResponse > problemSets
@@ -36,12 +42,20 @@ public record ProblemSetHomeFeedResponse(
3642 public static ProblemSetHomeFeedResponse of (LocalDate date , Long publishId ,
3743 ProblemSetGetResponse problemSetGetResponse ,
3844 Long submitCount ) {
45+ ProblemSummaryResponse problemSummaryResponse = null ;
46+ try {
47+ problemSummaryResponse = problemSetGetResponse .problemSummaries ().get (0 );
48+ } catch (IndexOutOfBoundsException e ) {
49+ log .atError ().log ("id " + publishId + "번 발행에 속한 세트에 문항이 존재하지 않습니다. " );
50+ throw new NotFoundException (ErrorCode .PROBLEM_NOT_FOUND ,
51+ "id " + publishId + "번 발행에 속한 세트에 문항이 존재하지 않습니다. " );
52+ }
3953 return new ProblemSetHomeFeedResponse (
4054 date ,
4155 publishId ,
4256 problemSetGetResponse .title (),
4357 submitCount ,
44- ProblemHomeFeedResponse .of (problemSetGetResponse . problemSummaries (). get ( 0 ) )
58+ ProblemHomeFeedResponse .of (problemSummaryResponse )
4559 );
4660 }
4761
0 commit comments