Newer
Older
Architecture / src / main / java / ArchitectureTest / CustomerRest.java
yoichiro on 6 Apr 2019 904 bytes PUT追加
package ArchitectureTest;

import javax.ws.rs.FormParam;
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 net.arnx.jsonic.JSON;

@Path("/customers")
public class CustomerRest {
	@GET
	public String getCustomers() {
		return JSON.encode(Customers.getInstance().getCustomers());
	}

	@POST
	public void createCustomer(@FormParam("name") String name, @FormParam("office") String office,
			@FormParam("address") String address) {
		Customers.getInstance().getCustomers().put(name, new Customer(office, address));
		System.out.println(Customers.getInstance().getCustomers());
	}
	
	@Path("/{customer}")
	@PUT
	public void updateAddress(@PathParam("customerID") String id, @FormParam("address") String address) {
		Customers.getInstance().getCustomers().get(id).setCusAddress(address);
	}
}