Refactoring start
This commit is contained in:
@@ -5,23 +5,72 @@ import com.pmu.betengine.repository.ResultatRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ResultatService {
|
||||
|
||||
private final ResultatRepository resultatCourseRepository;
|
||||
private final ResultatRepository resultatRepository;
|
||||
|
||||
public Optional<Resultat> findByCourseId(Long courseId) {
|
||||
return resultatCourseRepository.findByCourseId(courseId);
|
||||
// CREATE / UPDATE
|
||||
public Resultat save(Resultat resultat) {
|
||||
return resultatRepository.save(resultat);
|
||||
}
|
||||
|
||||
public Resultat save(Resultat resultatCourse) {
|
||||
return resultatCourseRepository.save(resultatCourse);
|
||||
// GET ALL
|
||||
public List<Resultat> getAll() {
|
||||
return resultatRepository.findAll();
|
||||
}
|
||||
|
||||
// GET BY ID
|
||||
public Resultat getById(Long id) {
|
||||
return resultatRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
// GET BY COURSE
|
||||
public Resultat getByCourseId(Long courseId) {
|
||||
return resultatRepository.findByCourseId(courseId).orElse(null);
|
||||
}
|
||||
|
||||
// DELETE BY ID
|
||||
public void delete(Long id) {
|
||||
resultatRepository.deleteById(id);
|
||||
}
|
||||
|
||||
// DELETE BY COURSE
|
||||
public void deleteByCourseId(Long courseId) {
|
||||
resultatCourseRepository.deleteByCourseId(courseId);
|
||||
resultatRepository.deleteByCourseId(courseId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// package com.pmu.betengine.service;
|
||||
|
||||
// import com.pmu.betengine.model.Resultat;
|
||||
// import com.pmu.betengine.repository.ResultatRepository;
|
||||
// import lombok.RequiredArgsConstructor;
|
||||
// import org.springframework.stereotype.Service;
|
||||
|
||||
// import java.util.Optional;
|
||||
|
||||
// @Service
|
||||
// @RequiredArgsConstructor
|
||||
// public class ResultatService {
|
||||
|
||||
// private final ResultatRepository resultatCourseRepository;
|
||||
|
||||
// public Optional<Resultat> findByCourseId(Long courseId) {
|
||||
// return resultatCourseRepository.findByCourseId(courseId);
|
||||
// }
|
||||
|
||||
// public Resultat save(Resultat resultatCourse) {
|
||||
// return resultatCourseRepository.save(resultatCourse);
|
||||
// }
|
||||
|
||||
// public void deleteByCourseId(Long courseId) {
|
||||
// resultatCourseRepository.deleteByCourseId(courseId);
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user