Enter score andfindscore by student and subject - #19
Open
NhoemPonleu wants to merge 3 commits into
Open
Conversation
pisething
reviewed
Nov 6, 2022
| public interface ScoreRepository extends JpaRepository<MonthlyScore, Long>,JpaSpecificationExecutor<MonthlyScore> { | ||
| List<MonthlyScore>findByStudent(Student student); | ||
| List<MonthlyScore>findBySubject(Subject subject); | ||
| //MonthlyScoreDTO save(MonthlyScoreDTO dto, Integer studentId, Integer subjectId); |
| // PostDTO cretePost(PostDTO postDTO, Integer userId, Integer categoryId); | ||
| //} | ||
|
|
||
| //MonthlyScore createScore(MonthlyScore score, Integer Id, Integer Id1); |
| List<MonthlyScoreDTO> getSubjectById(Long id1); | ||
| void deleteScore(Long id); | ||
| List<MonthlyScoreDTO>getScoreList(); | ||
| MonthlyScore getById(Long id); |
Owner
There was a problem hiding this comment.
All methods should indent same space.
| public MonthlyScoreDTO update(Long id, MonthlyScoreDTO monthlyScoreDTO) { | ||
| // TODO Auto-generated method stub | ||
| MonthlyScore score = this.scoreRepository.findById(id).orElseThrow(()-> new ResourceNotFoundException("MonthlyScore", id)); | ||
| score.setMonth(Month.NOVEMBER); |
Owner
There was a problem hiding this comment.
Score properties should get new value from monthlyScoreDTO.
| // TODO Auto-generated method stub | ||
| MonthlyScore score = this.scoreRepository.findById(id).orElseThrow(()-> new ResourceNotFoundException("MonthlyScore", id)); | ||
| score.setMonth(Month.NOVEMBER); | ||
| score.setScore(score.getScore()); |
| @RequiredArgsConstructor | ||
| public class ScoreController { | ||
| private final ScoreService scoreService ; | ||
| @PostMapping("/student/{id}/subject/{id1}") |
Owner
There was a problem hiding this comment.
-if you use @PostMapping("/student/{id}/subject/{id1}") , you should provide a good name for parameter like studentId...
-Anyway, no need to use path variable, you can get the studentId and subject id from MonthlyScoreDTO.
| private Double score; | ||
|
|
||
|
|
||
| private Year year; |
Owner
There was a problem hiding this comment.
You can use integer for month and year also.
| @@ -29,5 +38,7 @@ public class MonthlyScore { | |||
| @Enumerated(EnumType.STRING) | |||
| @Column(name = "month") | |||
| private Month month; | |||
Owner
There was a problem hiding this comment.
Can use integer for month also ok.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.