Browse Source

添加获取token接口

wangmh 7 years ago
parent
commit
f24397997f

+ 30 - 0
sso-common/src/main/java/com/uas/sso/util/AccountUtils.java

@@ -1211,4 +1211,34 @@ public class AccountUtils {
 		}
 		return null;
 	}
+
+	/**
+	 * 根据营业执照号分页查找该企业的用户
+	 * @param spaceUU
+	 * @param userUU
+	 * @return
+	 * @throws Exception
+	 */
+	public static String getToken(Long spaceUU, Long userUU) throws Exception {
+		String url = AccountConfig.getUserSaveUrl();
+		if (!StringUtils.isEmpty(url)) {
+			url = url + "/getToken";
+			String appId = SSOHelper.getSSOService().getConfig().getAppName();
+			ModelMap data = new ModelMap();
+			data.put("spaceUU", spaceUU);
+			data.put("userUU", userUU);
+			HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
+			if (!res.isSuccess()) {
+				throw new Exception(res.getContent());
+			} else {
+                ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
+                if (!result.isSuccess()) {
+                    throw new Exception(result.getErrMsg());
+                } else if (result.getContent() != null) {
+                    return result.getContent().toString();
+                }
+			}
+		}
+		return null;
+	}
 }

+ 10 - 0
sso-server/src/main/java/com/uas/sso/controller/UserManagerController.java

@@ -512,4 +512,14 @@ public class UserManagerController extends BaseController {
             e.printStackTrace();
         }
     }
+    @RequestMapping(value = "/getToken", method = RequestMethod.GET)
+    @ResponseBody
+    public ModelMap getToken(Long userUU, Long spaceUU) {
+        ModelMap data = new ModelMap();
+        data.put("userUU", userUU);
+        data.put("spaceUU", spaceUU);
+        Token token = new Token(data);
+        tokenService.save(token);
+        return success(token.getId());
+    }
 }