Add column created_at and updated_at + PUT add
This commit is contained in:
parent
caf7f514cf
commit
85eb18f518
@ -3,11 +3,9 @@ package com.covas.Entity;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.annotation.Generated;
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
@ -42,8 +40,13 @@ public class UsersEntity extends PanacheEntityBase {
|
|||||||
public Boolean status;
|
public Boolean status;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public String password;
|
public String password;
|
||||||
|
@Column(nullable = false)
|
||||||
public String roles;
|
public String roles;
|
||||||
|
@Column(nullable = false)
|
||||||
|
public LocalDate created_at;
|
||||||
|
@Column(nullable = false)
|
||||||
|
public LocalDate updated_at;
|
||||||
|
|
||||||
public static UsersEntity findByPseudo(String pseudo){
|
public static UsersEntity findByPseudo(String pseudo){
|
||||||
return find("pseudo", pseudo).firstResult();
|
return find("pseudo", pseudo).firstResult();
|
||||||
}
|
}
|
||||||
@ -59,6 +62,8 @@ public class UsersEntity extends PanacheEntityBase {
|
|||||||
users.status = false;
|
users.status = false;
|
||||||
users.password = Hash.encryptSHA512(password);
|
users.password = Hash.encryptSHA512(password);
|
||||||
users.roles = roles;
|
users.roles = roles;
|
||||||
|
users.created_at = LocalDate.now();
|
||||||
|
users.updated_at = LocalDate.now();
|
||||||
users.persist();
|
users.persist();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,9 +5,11 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import javax.annotation.security.RolesAllowed;
|
import javax.annotation.security.RolesAllowed;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
import javax.ws.rs.core.SecurityContext;
|
import javax.ws.rs.core.SecurityContext;
|
||||||
import javax.ws.rs.CookieParam;
|
import javax.ws.rs.CookieParam;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.PUT;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
@ -86,5 +88,14 @@ public class UsersRessources {
|
|||||||
return Response.ok(new UserSingle(user.name, user.pseudo, user.firstName)).build();
|
return Response.ok(new UserSingle(user.name, user.pseudo, user.firstName)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//PUT
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@RolesAllowed("Admin")
|
||||||
|
@Transactional
|
||||||
|
public Response createUser(@Context SecurityContext ctx, @CookieParam("user") String userCookie){
|
||||||
|
return Response.status(Response.Status.CREATED).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user