tokenGain.jsp 2.56 KB
<%--
  Created by IntelliJ IDEA.
  User: zhaiyaqi
  Date: 2020/3/15
  Time: 7:34 PM
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="org.apache.commons.logging.Log" %>
<%@ page import="org.apache.commons.logging.LogFactory" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="com.cntytz.HttpUtils" %>
<%@ page import="org.springframework.web.servlet.ModelAndView" %>
<%@ page import="org.springframework.web.servlet.view.RedirectView" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    response.setContentType("application/json;charset=utf-8");
    out.clear();
    writeLog("【start token gain interfince ==========】:");
    JSONObject result = new JSONObject(true);
    User user = HrmUserVarify.getUser(request,response);
    String url = request.getParameter("url");
    JSONObject json = new JSONObject();
    String loginid ="";
    writeLog("user=========================" + JSONObject.toJSONString(user));
    try {
        loginid = user.getLoginid();
        String tokenGainurl = "https://ty.cntytz.com/uasSign/sign/authentication";
        writeLog("json =============url " + url);
        json.put("url",url);
        json.put("userLoginName",loginid);
        writeLog("json =============url " + JSONObject.toJSONString(json));
        JSONObject jsonObject = HttpUtils.doPost(tokenGainurl, json);
        writeLog("===================="+jsonObject);
        String tokenUrl = jsonObject.get("url").toString();
        writeLog("====================tokenUrl="+tokenUrl);
        String token = tokenUrl.substring(tokenUrl.indexOf("=")+1,tokenUrl.length());
        writeLog("====================token="+token);
        writeLog("====================url="+url);
        writeLog("====================url+token="+url+token);
        response.sendRedirect(url+token);
    } catch (Exception e) {
        result.put("code", -1);
        result.put("message", "接口处理异常"+e.getMessage());
        out.print("用户信息不完善,请联系管理员进一步完善,谢谢");
        return;
    }
    out.print(result.toJSONString());
%>
<%!
    private void writeLog(Object o) {
        Log var3 = LogFactory.getLog(this.getClass().getName());
        if(o instanceof Exception) {
            var3.info(this.getClass().getName(), (Exception)o);
        } else {
            var3.info(o);
        }
    }

%>