Skip to content

Enter score andfindscore by student and subject - #19

Open
NhoemPonleu wants to merge 3 commits into
main_ponlieufrom
EnterScoreAndfindscoreByStudentAndSubject
Open

Enter score andfindscore by student and subject#19
NhoemPonleu wants to merge 3 commits into
main_ponlieufrom
EnterScoreAndfindscoreByStudentAndSubject

Conversation

@NhoemPonleu

Copy link
Copy Markdown
Collaborator

No description provided.

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);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should remove unused code

// PostDTO cretePost(PostDTO postDTO, Integer userId, Integer categoryId);
//}

//MonthlyScore createScore(MonthlyScore score, Integer Id, Integer Id1);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused code

List<MonthlyScoreDTO> getSubjectById(Long id1);
void deleteScore(Long id);
List<MonthlyScoreDTO>getScoreList();
MonthlyScore getById(Long id);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You set same value.

@RequiredArgsConstructor
public class ScoreController {
private final ScoreService scoreService ;
@PostMapping("/student/{id}/subject/{id1}")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-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;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use integer for month also ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants