|
|
@@ -1,12 +1,17 @@
|
|
|
package com.uas.sso.bihe.controller;
|
|
|
|
|
|
+import com.uas.sso.bihe.entity.OAuthInfo;
|
|
|
import com.uas.sso.bihe.entity.OAuthRoot;
|
|
|
+import com.uas.sso.bihe.entity.UserRoot;
|
|
|
+import com.uas.sso.bihe.service.BiHeService;
|
|
|
import com.uas.sso.controller.BaseController;
|
|
|
import com.uas.sso.entity.Token;
|
|
|
import com.uas.sso.entity.User;
|
|
|
import com.uas.sso.service.UserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
+import org.springframework.util.Assert;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
@@ -21,6 +26,8 @@ public class BiHeController extends BaseController {
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BiHeService biHeService;
|
|
|
/**
|
|
|
* 绑定微信账号
|
|
|
* @param t 微信登录失败返回的token
|
|
|
@@ -46,4 +53,19 @@ public class BiHeController extends BaseController {
|
|
|
|
|
|
return success();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取用户
|
|
|
+ * @param t
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/userinfo/{token}",method = RequestMethod.GET)
|
|
|
+ public ModelMap findUserByToken(@PathVariable("token")String t){
|
|
|
+ Token token =tokenService.findOne(t);
|
|
|
+ Assert.notNull(token, "验证信息过期");
|
|
|
+ Assert.isTrue(token.getBind() instanceof OAuthInfo, "参数错误");
|
|
|
+ OAuthInfo oAuthInfo = (OAuthInfo) token.getBind();
|
|
|
+ UserRoot userRoot = biHeService.getUserInfoByAccessToken(oAuthInfo.getOpenId(), oAuthInfo.getAccessToken());
|
|
|
+ return success(userRoot);
|
|
|
+ }
|
|
|
}
|