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("deriver")
	public void updateDeriver(@FormParam("deriver") String deriver_json) throws JsonProcessingException {
		Map.Entry<String, Map.Entry<Integer, Integer>> deriver;
		{
			Map<String, Map<String, Integer>> i = new ObjectMapper().readValue(deriver_json, HashMap.class);
			deriver = 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<>(deriver.getKey(), deriver.getValue().getKey());
	}
	@Produces(MediaType.APPLICATION_JSON)
	@GET
	@Getter
	public Map.Entry<String, Integer> getValue() {
		return value;
	}
}