Newer
Older
stockManagement.pull / src / main / java / stockManagement / pull / Stock.java
Shinji on 21 Jan 2023 1 KB プロジェクトの追加
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.*;

import com.fasterxml.jackson.core.JsonProcessingException;

@Path("/stock")
@Resource("stock")
@Component
public class Stock {
	@State
	private Map<String, Integer> value = new HashMap<String, Integer>();
	@POST
	@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.put(deriver.getKey(),deriver.getValue().getValue());
	}
	@Produces(MediaType.APPLICATION_JSON)
	@GET
	@Getter
	public Map<String, Integer> getValue() {
		return value;
	}
}