Compare commits
1 Commits
test_thème
...
endpoints
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
228f71c404 |
@@ -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();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,7 +3,55 @@ package hackathon.FrisbYEE.jpa.service;
|
|||||||
import hackathon.FrisbYEE.jpa.metier.Activite;
|
import hackathon.FrisbYEE.jpa.metier.Activite;
|
||||||
import hackathon.FrisbYEE.jpa.metier.Athlete;
|
import hackathon.FrisbYEE.jpa.metier.Athlete;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
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> {
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.ApiResponse;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import hackathon.FrisbYEE.jpa.dto.AthleteDTO;
|
||||||
import hackathon.FrisbYEE.jpa.service.AthleteDAO;
|
import hackathon.FrisbYEE.jpa.service.AthleteDAO;
|
||||||
|
import hackathon.FrisbYEE.jpa.interface.IAthlete;
|
||||||
|
|
||||||
public class AthleteResource {
|
public class AthleteResource {
|
||||||
|
|
||||||
private AthleteDAO athleteDAO;
|
private AthleteDAO athleteDAO;
|
||||||
|
|
||||||
@Operation(summary = "Récupère tous les utilisateurs")
|
@Operation(summary = "Récupère tous les utilisateurs")
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(responseCode = "200", description = "Récupère le Joueur ayant l'identifiant correspondant",
|
@ApiResponse(responseCode = "200", description = "Récupère le Joueur ayant l'identifiant correspondant",
|
||||||
content = @Content(mediaType = "application/json",
|
content = @Content(mediaType = "application/json",
|
||||||
schema = @Schema(implementation = JoueurDTO.class)))
|
schema = @Schema(implementation = AthleteDTO.class)))
|
||||||
})
|
})
|
||||||
@GetMapping("/joueur/{id}")
|
@GetMapping("/joueur/{id}")
|
||||||
public JoueurDTO getJoueurById(@PathVariable Integer joueurId) {
|
public AthleteDTO getJoueurById(@PathVariable Integer joueurId) {
|
||||||
// return pet
|
|
||||||
System.out.println("ID A CHERCHER" + joueurId);
|
System.out.println("ID A CHERCHER" + joueurId);
|
||||||
IJoueur j = dao.findOne(joueurId);
|
IAthlete j = athleteDAO.findOne(joueurId);
|
||||||
JoueurDTO jDTO = new JoueurDTO(null, null);
|
AthleteDTO jDTO = new AthleteDTO();
|
||||||
System.out.println(j);
|
System.out.println(j);
|
||||||
return jDTO;
|
return jDTO;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user