diff --git a/src/main/java/ArchitectureTest/CompanyRest.java b/src/main/java/ArchitectureTest/CompanyRest.java index 995d2c5..bf0cac0 100644 --- a/src/main/java/ArchitectureTest/CompanyRest.java +++ b/src/main/java/ArchitectureTest/CompanyRest.java @@ -22,10 +22,16 @@ Companies.getInstance().getCompanies().put(name, new Company(address)); System.out.println(Companies.getInstance().getCompanies()); } - - @Path("/{company}") + + @Path("/{companyId}/address") + @GET + public void getAddress(@PathParam("companyId") String company) { + Companies.getInstance().getCompanies().get(company).getAddress(); + } + + @Path("/{companyId}/address") @PUT - public void updateAddress(@PathParam("company") String company, @FormParam("address")String address) { + public void updateAddress(@PathParam("companyId") String company, @FormParam("address") String address) { Companies.getInstance().getCompanies().get(company).setAddress(address); } } diff --git a/src/main/java/ArchitectureTest/Customer.java b/src/main/java/ArchitectureTest/Customer.java index 4a7603c..9fc61dc 100644 --- a/src/main/java/ArchitectureTest/Customer.java +++ b/src/main/java/ArchitectureTest/Customer.java @@ -4,12 +4,12 @@ public class Customer { private URI companyURI; + private String office; private String address; - private String cusAddress; Customer(String company, String address) { companyURI = URI.create("/companies/" + company); - this.address = address; + this.office = address; } public URI getCompanyURI() { @@ -20,19 +20,19 @@ this.companyURI = companyURI; } + public String getOffice() { + return office; + } + + public void setOffice(String address) { + this.office = address; + } + public String getAddress() { return address; } - public void setAddress(String address) { - this.address = address; - } - - public String getCusAddress() { - return cusAddress; - } - - public void setCusAddress(String cusAddress) { - this.cusAddress = cusAddress; + public void setAddress(String cusAddress) { + this.address = cusAddress; } } diff --git a/src/main/java/ArchitectureTest/CustomerRest.java b/src/main/java/ArchitectureTest/CustomerRest.java index b6ba68d..7e85430 100644 --- a/src/main/java/ArchitectureTest/CustomerRest.java +++ b/src/main/java/ArchitectureTest/CustomerRest.java @@ -22,10 +22,28 @@ Customers.getInstance().getCustomers().put(name, new Customer(office, address)); System.out.println(Customers.getInstance().getCustomers()); } - - @Path("/{customer}") + + @Path("/{customerId}/office") + @GET + public String getOffice(@PathParam("customerId") String id) { + return Customers.getInstance().getCustomers().get(id).getOffice(); + } + + @Path("/{customerId}/office") @PUT - public void updateAddress(@PathParam("customerID") String id, @FormParam("address") String address) { - Customers.getInstance().getCustomers().get(id).setCusAddress(address); + public void updateOffice(@PathParam("customerId") String id, @FormParam("office") String office) { + Customers.getInstance().getCustomers().get(id).setOffice(office); + } + + @Path("/{customerId}/address") + @GET + public String getAddress(@PathParam("customerId") String id) { + return Customers.getInstance().getCustomers().get(id).getAddress(); + } + + @Path("/{customerId}/address") + @PUT + public void getAddress(@PathParam("customerId") String id, @FormParam("address") String address) { + Customers.getInstance().getCustomers().get(id).setAddress(address); } }