package com.qmth.qrzk.web.controller;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.qmth.qrzk.repository.common.enumeration.BatchType;
import com.qmth.qrzk.repository.common.enumeration.PaperType;

/**
 * 字典，各种参数、类型、常量值
 * @author zhengmin
 *
 */
@RestController
@RequestMapping("/dict")
public class DictController {

	/**
	 * 批次类型
	 * @return
	 */
	@RequestMapping(value="batchType",method=RequestMethod.GET)
	public JSONArray batchType(){
		BatchType[] types = BatchType.values();
		JSONArray result = new JSONArray();
		for(BatchType item : types){
			JSONObject obj = new JSONObject();
			obj.accumulate("name", item.toString());
			obj.accumulate("value", item.getValue());
			result.add(obj);
		}
		return result;
	}
	
	
	/**
	 * 试卷类型，白纸、硫酸纸
	 * @return
	 */
	@RequestMapping(value="paperType",method=RequestMethod.GET)
	public JSONArray paperType(){
		PaperType[] types = PaperType.values();
		JSONArray result = new JSONArray();
		for(PaperType item : types){
			JSONObject obj = new JSONObject();
			obj.accumulate("name", item.toString());
			obj.accumulate("value", item.getValue());
			result.add(obj);
		}
		return result;
	}
}
