-
Notifications
You must be signed in to change notification settings - Fork 0
/
PersonResource.java
47 lines (37 loc) · 1000 Bytes
/
PersonResource.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.mongodb;
import jakarta.inject.Inject;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import java.util.List;
@Path("/api")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class PersonResource {
@Inject
PersonRepository personRepository;
@GET
@Path("/hello")
public String hello() {
return "Hello from Quarkus REST";
}
@POST
@Path("/person")
public String createPerson(PersonEntity person) {
return personRepository.add(person);
}
@GET
@Path("/persons")
public List<PersonEntity> getPersons() {
return personRepository.getPersons();
}
@PUT
@Path("/person/{id}")
public long anniversaryPerson(@PathParam("id") String id) {
return personRepository.anniversaryPerson(id);
}
@DELETE
@Path("/person/{id}")
public long deletePerson(@PathParam("id") String id) {
return personRepository.deletePerson(id);
}
}