/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.google.gson.Gson
 *  javax.servlet.ServletException
 *  javax.servlet.http.HttpServlet
 *  javax.servlet.http.HttpServletRequest
 *  javax.servlet.http.HttpServletResponse
 *  org.apache.commons.logging.Log
 *  org.apache.commons.logging.LogFactory
 */
package com.hst.servlet;

import com.google.gson.Gson;
import com.hst.common.util.HstWxServiceUtil;
import com.hst.framework.constants.WebConstants;
import com.hst.servlet.domain.IDCardPhoptoResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class QueryPhotoServlet
extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public static Log _logger = LogFactory.getLog(QueryPhotoServlet.class);

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        block6: {
            String idcard = request.getParameter("idcard");
            String name = request.getParameter("name");
            IDCardPhoptoResponse resData = new IDCardPhoptoResponse();
            response.setContentType("text/json; charset=utf-8");
            String zjkurl = String.valueOf(WebConstants.ZJK_SERVICE_URL) + "/queryPhoto";
            HashMap<String, String> params = new HashMap<String, String>();
            params.put("idcard", idcard);
            params.put("name", name);
            try {
                try {
                    Map<String, String> res = HstWxServiceUtil.sendMess(zjkurl, params, "utf-8");
                    if ("00".equals(res.get("code"))) {
                        resData = (IDCardPhoptoResponse)new Gson().fromJson(res.get("mess"), IDCardPhoptoResponse.class);
                        break block6;
                    }
                    resData.setErrorCode("-1");
                    resData.setErrorMsg(res.get("mess"));
                }
                catch (Exception e) {
                    _logger.error((Object)e.getMessage());
                    resData.setErrorCode("-1");
                    resData.setErrorMsg("\u7cfb\u7edf\u5f02\u5e38");
                    e.printStackTrace();
                    PrintWriter out = response.getWriter();
                    out.write(new Gson().toJson((Object)resData));
                }
            }
            finally {
                PrintWriter out = response.getWriter();
                out.write(new Gson().toJson((Object)resData));
            }
        }
    }
}
