From 4ea644e1d41eb7a206a006905c2c67d0c5a144b6 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Wed, 11 May 2022 23:01:27 +0200 Subject: [PATCH] get id users with uuid --- src/main/java/com/covas/Entity/UsersEntity.java | 15 +++++++++++++-- .../java/com/covas/Resources/UsersRessources.java | 8 +++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/covas/Entity/UsersEntity.java b/src/main/java/com/covas/Entity/UsersEntity.java index ce0b8d7..0d17bc8 100644 --- a/src/main/java/com/covas/Entity/UsersEntity.java +++ b/src/main/java/com/covas/Entity/UsersEntity.java @@ -1,21 +1,32 @@ package com.covas.Entity; import java.time.LocalDate; +import java.util.UUID; +import javax.annotation.Generated; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; import javax.persistence.Table; import com.covas.Classes.Hash; import org.hibernate.annotations.ColumnDefault; +import org.hibernate.annotations.GenericGenerator; -import io.quarkus.hibernate.orm.panache.PanacheEntity; +import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @Entity @Table(name = "users") -public class UsersEntity extends PanacheEntity { +public class UsersEntity extends PanacheEntityBase { + @Id + @Column(name = "id") + @GeneratedValue(generator = "UUID") + @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator") + public UUID id; @Column(nullable = false, unique = true) public String pseudo; diff --git a/src/main/java/com/covas/Resources/UsersRessources.java b/src/main/java/com/covas/Resources/UsersRessources.java index 9c4f889..39ac060 100644 --- a/src/main/java/com/covas/Resources/UsersRessources.java +++ b/src/main/java/com/covas/Resources/UsersRessources.java @@ -1,5 +1,7 @@ package com.covas.Resources; +import java.util.UUID; + import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -23,9 +25,9 @@ public class UsersRessources { @GET @Path("{id}") - public Response getSingleUser(@PathParam("id") Long id){ - LOGGER.info(id); - UsersEntity users = UsersEntity.findById(id); + public Response getSingleUser(@PathParam("id") String id){ + UUID uid = UUID.fromString(id); + UsersEntity users = UsersEntity.findById(uid); if(users == null){ return Response.status(Response.Status.NOT_FOUND).build(); }