|
|
@@ -0,0 +1,39 @@
|
|
|
+package com.uas.sso.bihe.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.uas.sso.bihe.entity.OAuthRoot;
|
|
|
+import com.uas.sso.bihe.service.BiHeService;
|
|
|
+import com.uas.sso.common.util.HttpUtil;
|
|
|
+import com.uas.sso.core.BHParam;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author: huyy
|
|
|
+ * @date: 2018/7/18 11:26
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class BiHeServiceImpl implements BiHeService {
|
|
|
+ @Override
|
|
|
+ public OAuthRoot getOAuthInfoByCode(String code){
|
|
|
+ String url = "https://opengwtest.bgycc.com/open/oauth/token";
|
|
|
+ String appid = BHParam.DEFAULT_APPID;
|
|
|
+ String appSecret = BHParam.DEFAULT_APPSECRET;
|
|
|
+ ModelMap data = new ModelMap();
|
|
|
+ data.put("code", "XIH1G4");
|
|
|
+ data.put("appId", appid);
|
|
|
+ data.put("appSecret", appSecret);
|
|
|
+
|
|
|
+ try {
|
|
|
+ HttpUtil.ResponseWrap res = HttpUtil.doHttpsPost(url, data.toString(), 10000);
|
|
|
+ if (res.getContent() != null) {
|
|
|
+ System.out.println(res.getContent().toString());
|
|
|
+ OAuthRoot oAuthRoot = JSON.parseObject(res.getContent().toString(), OAuthRoot.class);
|
|
|
+ return oAuthRoot;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|