-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 하이라이트 관련 버그 수정 - 하이라이트 리팩토링
- Loading branch information
Showing
107 changed files
with
616 additions
and
581 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* @chysis @BadaHertz52 @soosoo22 @ImxYJL @donghoony @Kimprodp @nayonsoso @skylar1220 | ||
/frontend/ @chysis @BadaHertz52 @soosoo22 @ImxYJL | ||
/backend/ @donghoony @Kimprodp @nayonsoso @skylar1220 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
...main/java/reviewme/config/CorsConfig.java → ...java/reviewme/config/cors/CorsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../java/reviewme/config/CorsProperties.java → .../reviewme/config/cors/CorsProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../java/reviewme/config/DataSourceType.java → ...wme/config/datasource/DataSourceType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package reviewme.config; | ||
package reviewme.config.datasource; | ||
|
||
public enum DataSourceType { | ||
READ, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../config/ReplicationRoutingDataSource.java → ...asource/ReplicationRoutingDataSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 2 additions & 7 deletions
9
...viewme/config/RequestLimitProperties.java → .../requestlimit/RequestLimitProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
package reviewme.config; | ||
package reviewme.config.requestlimit; | ||
|
||
import java.time.Duration; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties(prefix = "request-limit") | ||
public record RequestLimitProperties( | ||
long threshold, | ||
Duration duration, | ||
String host, | ||
int port | ||
) { | ||
public record RequestLimitProperties(long threshold, Duration duration, String host, int port) { | ||
} |
2 changes: 1 addition & 1 deletion
2
...iewme/config/RequestLimitRedisConfig.java → ...requestlimit/RequestLimitRedisConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
backend/src/main/java/reviewme/config/requestlimit/RequestLimitWebConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package reviewme.config.requestlimit; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class RequestLimitWebConfig implements WebMvcConfigurer { | ||
|
||
private final RedisTemplate<String, Long> redisTemplate; | ||
private final RequestLimitProperties requestLimitProperties; | ||
|
||
@Override | ||
public void addInterceptors(InterceptorRegistry registry) { | ||
registry.addInterceptor(new RequestLimitInterceptor(redisTemplate, requestLimitProperties)); | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
...al/exception/TooManyRequestException.java → ...requestlimit/TooManyRequestException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 1 addition & 5 deletions
6
backend/src/main/java/reviewme/global/exception/FieldErrorResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
package reviewme.global.exception; | ||
|
||
public record FieldErrorResponse( | ||
String field, | ||
Object value, | ||
String message | ||
) { | ||
public record FieldErrorResponse(String field, Object value, String message) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
.../java/reviewme/highlight/domain/exception/HighlightStartIndexExceedEndIndexException.java
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
backend/src/main/java/reviewme/highlight/repository/HighlightJdbcRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package reviewme.highlight.repository; | ||
|
||
import java.util.Collection; | ||
import reviewme.highlight.domain.Highlight; | ||
|
||
public interface HighlightJdbcRepository { | ||
|
||
void saveAll(Collection<Highlight> highlights); | ||
} |
24 changes: 24 additions & 0 deletions
24
backend/src/main/java/reviewme/highlight/repository/HighlightJdbcRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package reviewme.highlight.repository; | ||
|
||
import java.util.Collection; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; | ||
import org.springframework.jdbc.core.namedparam.SqlParameterSource; | ||
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils; | ||
import reviewme.highlight.domain.Highlight; | ||
|
||
@RequiredArgsConstructor | ||
public class HighlightJdbcRepositoryImpl implements HighlightJdbcRepository { | ||
|
||
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate; | ||
|
||
@Override | ||
public void saveAll(Collection<Highlight> highlights) { | ||
SqlParameterSource[] parameterSources = SqlParameterSourceUtils.createBatch(highlights.toArray()); | ||
String insertSql = """ | ||
INSERT INTO highlight (answer_id, line_index, start_index, end_index) | ||
VALUES (:answerId, :lineIndex, :highlightRange.startIndex, :highlightRange.endIndex) | ||
"""; | ||
namedParameterJdbcTemplate.batchUpdate(insertSql, parameterSources); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 7 additions & 10 deletions
17
backend/src/main/java/reviewme/highlight/service/HighlightService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,33 @@ | ||
package reviewme.highlight.service; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import reviewme.highlight.domain.Highlight; | ||
import reviewme.highlight.repository.HighlightRepository; | ||
import reviewme.highlight.service.dto.HighlightsRequest; | ||
import reviewme.highlight.service.mapper.HighlightMapper; | ||
import reviewme.highlight.service.validator.HighlightValidator; | ||
import reviewme.review.repository.AnswerRepository; | ||
import reviewme.review.service.validator.AnswerValidator; | ||
import reviewme.reviewgroup.domain.ReviewGroup; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class HighlightService { | ||
|
||
private final HighlightRepository highlightRepository; | ||
private final AnswerRepository answerRepository; | ||
|
||
private final HighlightValidator highlightValidator; | ||
private final HighlightMapper highlightMapper; | ||
private final AnswerValidator answerValidator; | ||
|
||
@Transactional | ||
public void editHighlight(HighlightsRequest highlightsRequest, ReviewGroup reviewGroup) { | ||
highlightValidator.validate(highlightsRequest, reviewGroup); | ||
List<Highlight> highlights = highlightMapper.mapToHighlights(highlightsRequest); | ||
|
||
Set<Long> answerIds = answerRepository.findIdsByQuestionId(highlightsRequest.questionId()); | ||
highlightRepository.deleteAllByAnswerIds(answerIds); | ||
List<Long> requestedAnswerIds = highlightsRequest.getUniqueAnswerIds(); | ||
answerValidator.validateQuestionContainsAnswers(highlightsRequest.questionId(), requestedAnswerIds); | ||
answerValidator.validateReviewGroupContainsAnswers(reviewGroup, requestedAnswerIds); | ||
|
||
List<Highlight> highlights = highlightMapper.mapToHighlights(highlightsRequest); | ||
highlightRepository.deleteByReviewGroupIdAndQuestionId(reviewGroup.getId(), highlightsRequest.questionId()); | ||
highlightRepository.saveAll(highlights); | ||
} | ||
} |
Oops, something went wrong.