Newer
Older
stockManagement.push / src / main / java / stockManagement / push / Shipping.java
Shinji on 20 Jan 2023 1 KB gitignoreの追加
package stockManagement.push;

import java.util.*;
import javax.ws.rs.*;
import javax.ws.rs.client.*;
import javax.ws.rs.core.*;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper;

import pushPullRefactor.Getter;
import pushPullRefactor.Message;
import pushPullRefactor.Resource;
import pushPullRefactor.State;

import com.fasterxml.jackson.core.JsonProcessingException;

@Path("/shipping")
@Component
@Resource("shipping")
public class Shipping {
	@State
	private Map.Entry<String, Integer> value;
	@PUT
	@Message("handling")
	public void updateHandling(@FormParam("handling") String handling_json) throws JsonProcessingException {
		Map.Entry<String, Map.Entry<Integer, Integer>> handling;
		{
			Map<String, Map<String, Integer>> i = new ObjectMapper().readValue(handling_json, HashMap.class);
			handling = new AbstractMap.SimpleEntry<>(i.entrySet().iterator().next().getKey(),
					new AbstractMap.SimpleEntry<>(Integer.parseInt(i.entrySet().iterator().next().getValue().entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue().entrySet().iterator().next().getValue()));
		}
		this.value = new AbstractMap.SimpleEntry<>(handling.getKey(), handling.getValue().getKey());
	}
	@Produces(MediaType.APPLICATION_JSON)
	@GET
	@Getter
	public Map.Entry<String, Integer> getValue() {
		return value;
	}
}