ressource put init
This commit is contained in:
parent
0b241bd8b5
commit
7b5772b49f
@ -14,6 +14,7 @@ import javax.transaction.Transactional;
|
||||
import javax.ws.rs.CookieParam;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.InternalServerErrorException;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
@ -26,12 +27,16 @@ import io.smallrye.jwt.auth.principal.JWTParser;
|
||||
import io.smallrye.jwt.auth.principal.ParseException;
|
||||
import io.smallrye.jwt.build.Jwt;
|
||||
|
||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||
import org.eclipse.microprofile.jwt.JsonWebToken;
|
||||
|
||||
|
||||
@Path("/token")
|
||||
public class TokenRessource {
|
||||
|
||||
@Inject
|
||||
@ConfigProperty(name = "covas.schema.create", defaultValue = "true")
|
||||
boolean schemaCreate;
|
||||
|
||||
@Inject
|
||||
JsonWebToken jwt;
|
||||
@ -39,6 +44,25 @@ public class TokenRessource {
|
||||
|
||||
@Inject JWTParser parser;
|
||||
|
||||
@PUT
|
||||
@Path("init")
|
||||
@Transactional
|
||||
public Response init(){
|
||||
if (schemaCreate){
|
||||
Users users = new Users();
|
||||
if(users.findByName("Peter") == null){
|
||||
users.name = "Peter";
|
||||
users.birth = LocalDate.of(1993, Month.FEBRUARY, 23);
|
||||
users.status = true;
|
||||
users.persist();
|
||||
return Response.status(Response.Status.CREATED).build();
|
||||
}
|
||||
}
|
||||
return Response.status(Response.Status.NOT_MODIFIED).build();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("authentificate")
|
||||
|
@ -11,3 +11,5 @@ quarkus.datasource.jdbc.url = jdbc:postgresql://localhost:5432/toto
|
||||
|
||||
# drop and create the database at startup (use `update` to only update the schema)
|
||||
quarkus.hibernate-orm.database.generation = drop-and-create
|
||||
|
||||
covas.schema.create = true
|
Loading…
x
Reference in New Issue
Block a user