package com.jeeplus.modules.esignature.service.signer;

import com.alibaba.fastjson.JSONObject;
import com.jeeplus.modules.esignature.kinggridserver.KingGridServer;
import com.jeeplus.modules.esignature.utils.HttpRequest;

import java.io.IOException;

public class SignerService {
	public static void main(String[] args) throws IOException {
		String signer_code = KingGridServer.SIGNER_CODE;
		JSONObject json = createSigner(signer_code , "安琪拉" , "360111198708089867");
		System.out.println(json);
	}
	
	
	/**
	 * 创建个人用户
	 * @throws IOException 
	 */
	public static JSONObject createSigner(String signer_code , String name , String idcode) throws IOException{
		HttpRequest request = KingGridServer.createHttpRequest("/api/signer/create");
		//	签署用户编码
		request.addParam("signer_code", signer_code);
		//签署用户名称
		request.addParam("signer_name", name);
		//签署用户手机号码
		request.addParam("signer_phone", "18771066108");
		//签署用户手机号码
		request.addParam("signer_idcode", idcode);
		
		request.send();
		JSONObject jsonObject = JSONObject.parseObject(request.resultToString());
		return jsonObject;
	}
	
	/**
	 * 创建企业用户
	 * @throws IOException 
	 */
	public static JSONObject createCompanySigner(String signer_code) throws IOException{
		
		HttpRequest request = KingGridServer.createHttpRequest("/api/signer/create");
		//设置用户编码
		request.addParam("signer_code",signer_code);
		//设置用户编码
		request.addParam("signer_name", "金格科技股份有限公司");
		
		request.addParam("signer_phone", "18770066807");
		
		//设置企业类型
		request.addParam("signer_type", "2");
		request.addParam("signer_idtype", "2");
		request.addParam("signer_idcode", "9136010674863060XM");
		
		return JSONObject.parseObject(request.resultToString());
	}
	
}
