Skip to content

Commit e0ea998

Browse files
authoredJan 29, 2025··
Merge pull request #25 from team-MoPlus/feature/#24
[fix/#24] problem repository bean 이름 겹침 충돌 해결
2 parents 04b6eec + 92e865e commit e0ea998

File tree

6 files changed

+24
-23
lines changed

6 files changed

+24
-23
lines changed
 

‎src/main/java/com/moplus/moplus_server/domain/v0/DetailResultApplication/service/DetailResultApplicationService.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import com.moplus.moplus_server.domain.v0.practiceTest.domain.PracticeTest;
1515
import com.moplus.moplus_server.domain.v0.practiceTest.domain.ProblemForTest;
1616
import com.moplus.moplus_server.domain.v0.practiceTest.repository.PracticeTestRepository;
17-
import com.moplus.moplus_server.domain.v0.practiceTest.repository.ProblemRepository;
17+
import com.moplus.moplus_server.domain.v0.practiceTest.repository.ProblemForTestRepository;
1818
import com.moplus.moplus_server.global.error.exception.ErrorCode;
1919
import com.moplus.moplus_server.global.error.exception.NotFoundException;
2020
import java.time.Duration;
@@ -33,7 +33,7 @@ public class DetailResultApplicationService {
3333
private final EstimatedRatingRepository estimatedRatingRepository;
3434
private final IncorrectProblemService incorrectProblemService;
3535
private final IncorrectProblemRepository incorrectProblemRepository;
36-
private final ProblemRepository problemRepository;
36+
private final ProblemForTestRepository problemForTestRepository;
3737

3838
@Transactional
3939
public void saveApplication(DetailResultApplicationPostRequest request) {
@@ -57,7 +57,7 @@ public ReviewNoteGetResponse getReviewNoteInfo(Long testResultId) {
5757
List<ProblemForTest> incorrectProblemForTests = incorrectProblemRepository.findAllByTestResultId(testResultId)
5858
.stream()
5959
.map(IncorrectProblem::getProblemId)
60-
.map(problemId -> problemRepository.findById(problemId).orElseThrow())
60+
.map(problemId -> problemForTestRepository.findById(problemId).orElseThrow())
6161
.toList();
6262

6363
List<ProblemGetResponse> forCurrentRating = incorrectProblemForTests.stream()

‎src/main/java/com/moplus/moplus_server/domain/v0/practiceTest/repository/ProblemRepository.java ‎src/main/java/com/moplus/moplus_server/domain/v0/practiceTest/repository/ProblemForTestRepository.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.springframework.data.jpa.repository.Query;
1010
import org.springframework.data.repository.query.Param;
1111

12-
public interface ProblemRepository extends JpaRepository<ProblemForTest, Long> {
12+
public interface ProblemForTestRepository extends JpaRepository<ProblemForTest, Long> {
1313

1414
List<ProblemForTest> findAllByPracticeTestId(Long id);
1515

‎src/main/java/com/moplus/moplus_server/domain/v0/practiceTest/service/admin/PracticeTestAdminService.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.moplus.moplus_server.domain.v0.practiceTest.dto.admin.request.PracticeTestRequest;
77
import com.moplus.moplus_server.domain.v0.practiceTest.dto.admin.request.RatingTableRequest;
88
import com.moplus.moplus_server.domain.v0.practiceTest.repository.PracticeTestRepository;
9-
import com.moplus.moplus_server.domain.v0.practiceTest.repository.ProblemRepository;
9+
import com.moplus.moplus_server.domain.v0.practiceTest.repository.ProblemForTestRepository;
1010
import com.moplus.moplus_server.domain.v0.practiceTest.repository.RatingTableRepository;
1111
import com.moplus.moplus_server.global.error.exception.ErrorCode;
1212
import com.moplus.moplus_server.global.error.exception.NotFoundException;
@@ -22,7 +22,7 @@ public class PracticeTestAdminService {
2222

2323
private final PracticeTestRepository practiceTestRepository;
2424
private final RatingTableRepository ratingTableRepository;
25-
private final ProblemRepository problemRepository;
25+
private final ProblemForTestRepository problemForTestRepository;
2626
private final RatingTableAdminService ratingTableAdminService;
2727

2828
private static void addToPracticeTestUpdateModel(Model model, List<RatingTable> ratingTables,
@@ -63,7 +63,7 @@ public void getPracticeTestUpdateModel(Model model, Long id) {
6363
@Transactional
6464
public void deletePracticeTest(Long id) {
6565
ratingTableRepository.deleteAllByPracticeTestId(id);
66-
problemRepository.deleteAllByPracticeTestId(id);
66+
problemForTestRepository.deleteAllByPracticeTestId(id);
6767
practiceTestRepository.deleteById(id);
6868
}
6969

‎src/main/java/com/moplus/moplus_server/domain/v0/practiceTest/service/admin/ProblemImageUploadService.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import com.moplus.moplus_server.domain.v0.practiceTest.domain.ProblemImageForTest;
77
import com.moplus.moplus_server.domain.v0.practiceTest.dto.admin.request.ProblemImageRequest;
88
import com.moplus.moplus_server.domain.v0.practiceTest.repository.PracticeTestRepository;
9+
import com.moplus.moplus_server.domain.v0.practiceTest.repository.ProblemForTestRepository;
910
import com.moplus.moplus_server.domain.v0.practiceTest.repository.ProblemImageRepository;
10-
import com.moplus.moplus_server.domain.v0.practiceTest.repository.ProblemRepository;
1111
import com.moplus.moplus_server.global.error.exception.ErrorCode;
1212
import com.moplus.moplus_server.global.error.exception.NotFoundException;
1313
import com.moplus.moplus_server.global.utils.s3.S3Util;
@@ -26,12 +26,13 @@ public class ProblemImageUploadService {
2626

2727
private final S3Util s3Util;
2828
private final PracticeTestRepository practiceTestRepository;
29-
private final ProblemRepository problemRepository;
29+
private final ProblemForTestRepository problemForTestRepository;
3030
private final ProblemImageRepository problemImageRepository;
3131

3232
@Transactional(readOnly = true)
3333
public void setProblemImagesByPracticeTestId(Long practiceTestId, Model model) {
34-
List<ProblemImageRequest> imageRequests = problemRepository.findAllByPracticeTestId(practiceTestId).stream()
34+
List<ProblemImageRequest> imageRequests = problemForTestRepository.findAllByPracticeTestId(practiceTestId)
35+
.stream()
3536
.map(ProblemImageRequest::of)
3637
.toList();
3738
model.addAttribute("problemImageRequests", imageRequests);
@@ -41,7 +42,7 @@ public void setProblemImagesByPracticeTestId(Long practiceTestId, Model model) {
4142
public void uploadImage(Long practiceId, Long problemId, MultipartFile image) {
4243
PracticeTest practiceTest = practiceTestRepository.findById(practiceId)
4344
.orElseThrow(() -> new NotFoundException(ErrorCode.PRACTICE_TEST_NOT_FOUND));
44-
ProblemForTest problemForTest = problemRepository.findById(problemId)
45+
ProblemForTest problemForTest = problemForTestRepository.findById(problemId)
4546
.orElseThrow(() -> new NotFoundException(ErrorCode.PROBLEM_NOT_FOUND));
4647
String fileName = uploadFile(image, problemId, practiceTest.getName());
4748
String s3ObjectUrl = s3Util.getS3ObjectUrl(fileName);
@@ -52,7 +53,7 @@ public void uploadImage(Long practiceId, Long problemId, MultipartFile image) {
5253
.build();
5354
ProblemImageForTest saved = problemImageRepository.save(problemImageForTest);
5455
problemForTest.addImage(saved);
55-
problemRepository.save(problemForTest);
56+
problemForTestRepository.save(problemForTest);
5657
}
5758

5859
public String uploadFile(MultipartFile file, Long problemId, String practiceTestName) {

‎src/main/java/com/moplus/moplus_server/domain/v0/practiceTest/service/client/ProblemService.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.moplus.moplus_server.domain.v0.practiceTest.domain.ProblemForTest;
55
import com.moplus.moplus_server.domain.v0.practiceTest.dto.admin.request.ProblemCreateRequest;
66
import com.moplus.moplus_server.domain.v0.practiceTest.dto.client.response.ProblemGetResponse;
7-
import com.moplus.moplus_server.domain.v0.practiceTest.repository.ProblemRepository;
7+
import com.moplus.moplus_server.domain.v0.practiceTest.repository.ProblemForTestRepository;
88
import com.moplus.moplus_server.global.error.exception.ErrorCode;
99
import com.moplus.moplus_server.global.error.exception.NotFoundException;
1010
import jakarta.servlet.http.HttpServletRequest;
@@ -18,7 +18,7 @@
1818
@RequiredArgsConstructor
1919
public class ProblemService {
2020

21-
private final ProblemRepository problemRepository;
21+
private final ProblemForTestRepository problemForTestRepository;
2222

2323
@Transactional
2424
public void saveProblems(PracticeTest practiceTest, HttpServletRequest request) {
@@ -41,12 +41,12 @@ public void saveProblems(PracticeTest practiceTest, HttpServletRequest request)
4141
.toList();
4242
problemsEntities
4343
.forEach(ProblemForTest::calculateProblemRating);
44-
problemRepository.saveAll(problemsEntities);
44+
problemForTestRepository.saveAll(problemsEntities);
4545
}
4646

4747
@Transactional
4848
public void updateProblems(PracticeTest practiceTest, HttpServletRequest request) {
49-
List<ProblemForTest> problemForTests = problemRepository.findAllByPracticeTestId(practiceTest.getId());
49+
List<ProblemForTest> problemForTests = problemForTestRepository.findAllByPracticeTestId(practiceTest.getId());
5050

5151
for (int i = 1; i <= practiceTest.getSubject().getProblemCount(); i++) {
5252
ProblemForTest problemForTest = problemForTests.get(i - 1);
@@ -55,29 +55,29 @@ public void updateProblems(PracticeTest practiceTest, HttpServletRequest request
5555
problemForTest.updateCorrectRate(Double.parseDouble(request.getParameter("correctRate_" + i)));
5656

5757
problemForTest.calculateProblemRating();
58-
problemRepository.save(problemForTest);
58+
problemForTestRepository.save(problemForTest);
5959
}
6060
}
6161

6262

6363
public ProblemForTest getProblemByPracticeTestIdAndNumber(Long practiceId, String problemNumber) {
64-
return problemRepository.findByProblemNumberAndPracticeTestId(problemNumber, practiceId)
64+
return problemForTestRepository.findByProblemNumberAndPracticeTestId(problemNumber, practiceId)
6565
.orElseThrow(() -> new NotFoundException(ErrorCode.PROBLEM_NOT_FOUND));
6666
}
6767

6868
@Transactional
6969
public ProblemForTest updateCorrectRate(Long practiceTestId, String problemNumber, double correctRate) {
70-
ProblemForTest problemForTest = problemRepository.findByProblemNumberAndPracticeTestIdWithPessimisticLock(
70+
ProblemForTest problemForTest = problemForTestRepository.findByProblemNumberAndPracticeTestIdWithPessimisticLock(
7171
problemNumber,
7272
practiceTestId)
7373
.orElseThrow(() -> new NotFoundException(ErrorCode.PROBLEM_NOT_FOUND));
7474
problemForTest.getPracticeTest();
7575
problemForTest.updateCorrectRate(correctRate);
76-
return problemRepository.save(problemForTest);
76+
return problemForTestRepository.save(problemForTest);
7777
}
7878

7979
public List<ProblemGetResponse> getProblemsByTestId(Long testId) {
80-
return problemRepository.findAllByPracticeTestId(testId).stream()
80+
return problemForTestRepository.findAllByPracticeTestId(testId).stream()
8181
.map(ProblemGetResponse::from)
8282
.toList();
8383
}

‎src/test/java/com/moplus/moplus_server/domain/practiceTest/service/client/PracticeTestServiceTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import com.moplus.moplus_server.domain.v0.practiceTest.domain.PracticeTest;
66
import com.moplus.moplus_server.domain.v0.practiceTest.repository.PracticeTestRepository;
7-
import com.moplus.moplus_server.domain.v0.practiceTest.repository.ProblemRepository;
7+
import com.moplus.moplus_server.domain.v0.practiceTest.repository.ProblemForTestRepository;
88
import com.moplus.moplus_server.domain.v0.practiceTest.service.client.PracticeTestService;
99
import java.util.concurrent.CountDownLatch;
1010
import java.util.concurrent.ExecutorService;
@@ -25,7 +25,7 @@ class PracticeTestServiceTest {
2525
@Autowired
2626
private PracticeTestRepository practiceTestRepository;
2727
@Autowired
28-
private ProblemRepository problemRepository;
28+
private ProblemForTestRepository problemForTestRepository;
2929

3030
@BeforeEach
3131
void setup() {

0 commit comments

Comments
 (0)
Please sign in to comment.