Modifiy table users
This commit is contained in:
parent
ca2ae584bc
commit
cac880df01
@ -30,10 +30,14 @@ public class ApplicationLifeCycle {
|
||||
LOGGER.info("The application has started");
|
||||
if (schemaCreate){
|
||||
Users users = new Users();
|
||||
if(users.findByName("Peter") == null){
|
||||
users.name = "Peter";
|
||||
if(users.findByPseudo("Peter") == null){
|
||||
users.pseudo = "Peter";
|
||||
users.email = "peter@email.com";
|
||||
users.name = "Toto";
|
||||
users.firstName = "Peter";
|
||||
users.birth = LocalDate.of(1993, Month.FEBRUARY, 23);
|
||||
users.status = true;
|
||||
users.password = "toto";
|
||||
users.persist();
|
||||
LOGGER.info("Users test was created");
|
||||
} else {
|
||||
|
@ -2,19 +2,34 @@ package com.covas;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
|
||||
import io.quarkus.hibernate.orm.panache.PanacheEntity;
|
||||
|
||||
|
||||
@Entity
|
||||
public class Users extends PanacheEntity {
|
||||
public String name;
|
||||
public LocalDate birth;
|
||||
public Boolean status;
|
||||
|
||||
public static Users findByName(String name){
|
||||
return find("name", name).firstResult();
|
||||
@Column(nullable = false, unique = true)
|
||||
public String pseudo;
|
||||
@Column(nullable = false, unique = true)
|
||||
public String email;
|
||||
@Column(nullable = false)
|
||||
public String name;
|
||||
@Column(nullable = false)
|
||||
public String firstName;
|
||||
@Column(nullable = false)
|
||||
public LocalDate birth;
|
||||
@ColumnDefault("false")
|
||||
public Boolean status;
|
||||
@Column(nullable = false)
|
||||
public String password;
|
||||
|
||||
public static Users findByPseudo(String pseudo){
|
||||
return find("pseudo", pseudo).firstResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user