-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCountryController.java
More file actions
60 lines (49 loc) · 1.49 KB
/
CountryController.java
File metadata and controls
60 lines (49 loc) · 1.49 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package org.vishal.controller;
import java.util.List;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.vishal.bean.Country;
import org.vishal.service.CountryService;
@Path("/countries")
public class CountryController {
CountryService countryservice= new CountryService();
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Country> getCountries(){
List<Country> listOfCountries= countryservice.getAllCountries();
return listOfCountries;
}
@GET
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
public Country getCountryById(@PathParam("id") int id){
return countryservice.getCountry(id);
}
@POST
@Produces(MediaType.APPLICATION_JSON)
public Country addCountry(Country country){
return countryservice.addCountry(country);
}
@PUT
@Produces(MediaType.APPLICATION_JSON)
public Country updateCountry(Country country){
return countryservice.updateCountry(country);
}
@DELETE
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
public void deleteCountry(@PathParam("id") int id){
countryservice.deleteCountry(id);
}
/* @DELETE
@Produces(MediaType.APPLICATION_JSON)
public Country deleteCountry(Country country){
return countryservice.deleteCountry(country);
} */
}