Newer
Older
Architecture / src / main / java / architectureTest / CompanyRest.java
m1924003 on 16 May 2019 1 KB package名変更
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("/companies")
public class CompanyRest {

	@GET
	public String getCompanies() {
		return JSON.encode(Companies.getInstance().getCompanies());
	}

	@POST
	public void createCompanies(@FormParam("name") String name, @FormParam("address") String address) {
		Companies.getInstance().getCompanies().put(name, new Company(address));
		System.out.println(Companies.getInstance().getCompanies());
	}

	@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("companyId") String company, @FormParam("address") String address) {
		Companies.getInstance().getCompanies().get(company).setAddress(address);
	}
}