4
4
import com .moplus .moplus_server .domain .v0 .practiceTest .domain .ProblemForTest ;
5
5
import com .moplus .moplus_server .domain .v0 .practiceTest .dto .admin .request .ProblemCreateRequest ;
6
6
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 ;
8
8
import com .moplus .moplus_server .global .error .exception .ErrorCode ;
9
9
import com .moplus .moplus_server .global .error .exception .NotFoundException ;
10
10
import jakarta .servlet .http .HttpServletRequest ;
18
18
@ RequiredArgsConstructor
19
19
public class ProblemService {
20
20
21
- private final ProblemRepository problemRepository ;
21
+ private final ProblemForTestRepository problemForTestRepository ;
22
22
23
23
@ Transactional
24
24
public void saveProblems (PracticeTest practiceTest , HttpServletRequest request ) {
@@ -41,12 +41,12 @@ public void saveProblems(PracticeTest practiceTest, HttpServletRequest request)
41
41
.toList ();
42
42
problemsEntities
43
43
.forEach (ProblemForTest ::calculateProblemRating );
44
- problemRepository .saveAll (problemsEntities );
44
+ problemForTestRepository .saveAll (problemsEntities );
45
45
}
46
46
47
47
@ Transactional
48
48
public void updateProblems (PracticeTest practiceTest , HttpServletRequest request ) {
49
- List <ProblemForTest > problemForTests = problemRepository .findAllByPracticeTestId (practiceTest .getId ());
49
+ List <ProblemForTest > problemForTests = problemForTestRepository .findAllByPracticeTestId (practiceTest .getId ());
50
50
51
51
for (int i = 1 ; i <= practiceTest .getSubject ().getProblemCount (); i ++) {
52
52
ProblemForTest problemForTest = problemForTests .get (i - 1 );
@@ -55,29 +55,29 @@ public void updateProblems(PracticeTest practiceTest, HttpServletRequest request
55
55
problemForTest .updateCorrectRate (Double .parseDouble (request .getParameter ("correctRate_" + i )));
56
56
57
57
problemForTest .calculateProblemRating ();
58
- problemRepository .save (problemForTest );
58
+ problemForTestRepository .save (problemForTest );
59
59
}
60
60
}
61
61
62
62
63
63
public ProblemForTest getProblemByPracticeTestIdAndNumber (Long practiceId , String problemNumber ) {
64
- return problemRepository .findByProblemNumberAndPracticeTestId (problemNumber , practiceId )
64
+ return problemForTestRepository .findByProblemNumberAndPracticeTestId (problemNumber , practiceId )
65
65
.orElseThrow (() -> new NotFoundException (ErrorCode .PROBLEM_NOT_FOUND ));
66
66
}
67
67
68
68
@ Transactional
69
69
public ProblemForTest updateCorrectRate (Long practiceTestId , String problemNumber , double correctRate ) {
70
- ProblemForTest problemForTest = problemRepository .findByProblemNumberAndPracticeTestIdWithPessimisticLock (
70
+ ProblemForTest problemForTest = problemForTestRepository .findByProblemNumberAndPracticeTestIdWithPessimisticLock (
71
71
problemNumber ,
72
72
practiceTestId )
73
73
.orElseThrow (() -> new NotFoundException (ErrorCode .PROBLEM_NOT_FOUND ));
74
74
problemForTest .getPracticeTest ();
75
75
problemForTest .updateCorrectRate (correctRate );
76
- return problemRepository .save (problemForTest );
76
+ return problemForTestRepository .save (problemForTest );
77
77
}
78
78
79
79
public List <ProblemGetResponse > getProblemsByTestId (Long testId ) {
80
- return problemRepository .findAllByPracticeTestId (testId ).stream ()
80
+ return problemForTestRepository .findAllByPracticeTestId (testId ).stream ()
81
81
.map (ProblemGetResponse ::from )
82
82
.toList ();
83
83
}
0 commit comments