package com.bcxin.api.test;



import com.alibaba.fastjson.JSONObject;
import com.bcxin.api.utils.Apache64Utils;
import com.bcxin.common.util.Encodes;
import com.bcxin.common.util.jiami.ConstUtil;
import com.bcxin.common.util.jiami.HelpPassword;

/**
 *  鍚堜綔鏈烘瀯  json 缁勮
 * @author admin
 *
 */
public class TestJsonUtil {
	
	/**
	 * @return
	 * @throws Exception 
	 */
	public static String   getJsonSuccess() throws Exception{
	
		JSONObject  json= new JSONObject();
		json.put("soleTabId", "");
		json.put("code", 200);
		json.put("message", "鎿嶄綔鎴愬姛");
		JSONObject  returnjson = new JSONObject();
		Long currentTime=System.currentTimeMillis();
		returnjson.put("option", Encodes.encodeBase64(json.toString()));
		returnjson.put("date", currentTime);
		returnjson.put("token", HelpPassword.encryptionPassword(currentTime+"", ConstUtil.COINS_TOKEN));
		return returnjson.toString();
	}
	
	public static String   getJsonError() throws Exception{
		JSONObject  json= new JSONObject();
		json.put("code", 300);
		json.put("message", "淇濆瓨涓嶆垚鍔�");
		JSONObject  returnjson = new JSONObject();
		Long currentTime=System.currentTimeMillis();
		returnjson.put("option", Encodes.encodeBase64(json.toString()));
		returnjson.put("date", currentTime);
		returnjson.put("token", HelpPassword.encryptionPassword(currentTime+"", ConstUtil.COINS_TOKEN));
		return returnjson.toString();
	}

	/**
	 * <b> 缁勮json  鍔犲瘑鏀惧埌data閲岄潰 </b> 
	 * 
	 * @param jsonResult
	 * @return
	 * @author liyongqiang
	 * @date 2017骞�1鏈�5鏃� 涓婂崍10:18:33
	 * @娉ㄦ剰浜嬮」 </b>
	 * <b>
	 */
	public static String getJsonToString(JSONObject jsonResult) {
		
		return Apache64Utils.base64Encode(jsonResult.toString());
	}

	/**
	 * <b>杩斿洖瀹屾暣鐨刯son </b> 
	 * 
	 * @param option
	 * @return
	 * @author liyongqiang
	 * @date 2017骞�1鏈�5鏃� 涓婂崍10:18:54
	 * @娉ㄦ剰浜嬮」 </b>
	 * <b>
	 */
	public static String getJsonToEntity(String option) {
		JSONObject  json= new JSONObject();
		
		return json.toString();
	}
	
	
}