This commit is contained in:
Alexis Leboeuf
2026-01-05 16:16:16 +01:00
parent cbb4ce3481
commit 228f71c404
3 changed files with 70 additions and 6 deletions

View File

@@ -0,0 +1,15 @@
package hackathon.FrisbYEE.jpa;
public interface IAthlete {
public void run();
int getId();
void setId(int id);
String getNom();
void setNom(String nom);
void setCategorie(String categorie);
String getCategorie();
void setNiveau(String niveau);
String getNiveau();
}

View File

@@ -3,7 +3,55 @@ package hackathon.FrisbYEE.jpa.service;
import hackathon.FrisbYEE.jpa.metier.Activite;
import hackathon.FrisbYEE.jpa.metier.Athlete;
import org.springframework.data.jpa.repository.JpaRepository;
import jakarta.persistence.EntityManager;
import sample.simple.dao.generic.AbstractJpaDao;
import hackathon.FrisbYEE.jpa.interface.IAthlete;
import java.util.List;
public interface AthleteDAO extends JpaRepository<Athlete, Integer> {
private EntityManager em = EntityManagerHelper.getEntityManager();
public AthleteDAO() {
}
@Override
public void save(IAthlete entity) {
em.getTransaction().begin();
em.persist(entity);
em.getTransaction().commit();
}
@Override
public IAthlete update(IAthlete entity) {
em.getTransaction().begin();
IJoueur merged = em.merge(entity);
em.getTransaction().commit();
return merged;
}
@Override
public IAthlete findOne(Integer id) {
return em.find(IAthlete.class, id);
}
@Override
public List<IAthlete> findAll() {
return em.createQuery("from IAthlete", IAthlete.class).getResultList();
}
@Override
public void delete(IAthlete entity) {
em.getTransaction().begin();
em.remove(entity);
em.getTransaction().commit();
}
@Override
public void deleteById(Integer entityId) {
IAthlete entity = findOne(entityId);
delete(entity);
}
}

View File

@@ -8,24 +8,25 @@ import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import hackathon.FrisbYEE.jpa.dto.AthleteDTO;
import hackathon.FrisbYEE.jpa.service.AthleteDAO;
import hackathon.FrisbYEE.jpa.interface.IAthlete;
public class AthleteResource {
private AthleteDAO athleteDAO;
@Operation(summary = "Récupère tous les utilisateurs")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Récupère le Joueur ayant l'identifiant correspondant",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = JoueurDTO.class)))
schema = @Schema(implementation = AthleteDTO.class)))
})
@GetMapping("/joueur/{id}")
public JoueurDTO getJoueurById(@PathVariable Integer joueurId) {
// return pet
public AthleteDTO getJoueurById(@PathVariable Integer joueurId) {
System.out.println("ID A CHERCHER" + joueurId);
IJoueur j = dao.findOne(joueurId);
JoueurDTO jDTO = new JoueurDTO(null, null);
IAthlete j = athleteDAO.findOne(joueurId);
AthleteDTO jDTO = new AthleteDTO();
System.out.println(j);
return jDTO;
}