@@ -42,11 +42,14 @@ public class ClientGetService {
42
42
private final ChildProblemSubmitRepository childProblemSubmitRepository ;
43
43
private final ChildProblemRepository childProblemRepository ;
44
44
45
-
46
45
@ Transactional (readOnly = true )
47
46
public CommentaryGetResponse getCommentary (Long publishId , Long problemId ) {
48
47
Long memberId = 1L ;
49
48
49
+ // 발행 조회
50
+ Publish publish = publishRepository .findByIdElseThrow (publishId );
51
+ denyAccessToFuturePublish (publish );
52
+
50
53
// 문항 제출 조회
51
54
ProblemSubmit problemSubmit = problemSubmitRepository .findByMemberIdAndPublishIdAndProblemIdElseThrow (memberId ,
52
55
publishId , problemId );
@@ -93,7 +96,10 @@ public List<AllProblemGetResponse> getAllProblem(int year, int month) {
93
96
LocalDate endDate = startDate .withDayOfMonth (startDate .lengthOfMonth ());
94
97
95
98
// 해당 월 모든 Publish 조회
96
- List <Publish > publishes = publishRepository .findByPublishedDateBetween (startDate , endDate );
99
+ // 오늘 이후 발행이 있다면 필터링
100
+ List <Publish > publishes = publishRepository .findByPublishedDateBetween (startDate , endDate ).stream ()
101
+ .filter (publish -> !publish .getPublishedDate ().isAfter (LocalDate .now ()))
102
+ .toList ();
97
103
98
104
List <AllProblemGetResponse > result = new ArrayList <>();
99
105
@@ -104,7 +110,7 @@ public List<AllProblemGetResponse> getAllProblem(int year, int month) {
104
110
// 날짜별 사용자 제출 정보 조회
105
111
List <ProblemSubmit > submissions = problemSubmitRepository .findByMemberIdAndPublishId (memberId , publishId );
106
112
List <ProblemSubmitStatus > problemStatuses = submissions .stream ()
107
- .map (ProblemSubmit ::getStatus )
113
+ .map (ProblemSubmit ::getStatus )
108
114
.toList ();
109
115
110
116
// 사용자 제출 정보 바탕으로 진행도 결정
@@ -128,6 +134,10 @@ private String getMainProblemImageUrl(Long problemSetId) {
128
134
public ProblemClientGetResponse getProblem (Long publishId , Long problemId ) {
129
135
Long memberId = 1L ;
130
136
137
+ // 발행 조회
138
+ Publish publish = publishRepository .findByIdElseThrow (publishId );
139
+ denyAccessToFuturePublish (publish );
140
+
131
141
// 문항조회
132
142
Problem problem = problemRepository .findByIdElseThrow (problemId );
133
143
@@ -152,6 +162,10 @@ public ProblemClientGetResponse getProblem(Long publishId, Long problemId) {
152
162
public ChildProblemClientGetResponse getChildProblem (Long publishId , Long problemId , Long childProblemId ) {
153
163
Long memberId = 1L ;
154
164
165
+ // 발행 조회
166
+ Publish publish = publishRepository .findByIdElseThrow (publishId );
167
+ denyAccessToFuturePublish (publish );
168
+
155
169
// 문항/새끼문항 조회
156
170
Problem problem = problemRepository .findByIdElseThrow (problemId );
157
171
ChildProblem childProblem = childProblemRepository .findByIdElseThrow (childProblemId );
@@ -170,4 +184,10 @@ public ChildProblemClientGetResponse getChildProblem(Long publishId, Long proble
170
184
171
185
return ChildProblemClientGetResponse .of (problem .getNumber (), sequence , childProblem .getImageUrl (), childProblemSubmit .getStatus ());
172
186
}
187
+
188
+ private void denyAccessToFuturePublish (Publish publish ){
189
+ if (publish .getPublishedDate ().isAfter (LocalDate .now ())) {
190
+ throw new InvalidValueException (ErrorCode .FUTURE_PUBLISH_NOT_ACCESSIBLE );
191
+ }
192
+ }
173
193
}
0 commit comments