get id users with uuid

This commit is contained in:
Valentin CZERYBA 2022-05-11 23:01:27 +02:00
parent dabcd87485
commit 4ea644e1d4
2 changed files with 18 additions and 5 deletions

View File

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

View File

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