|
@@ -71,32 +71,15 @@ public class UserController extends CommonController {
|
|
|
public CommonResult<UserInfo> getMyInfo(UserParam userParam){
|
|
|
UserInfo userInfo = new UserInfo();
|
|
|
if(StringUtils.isNotBlank(userParam.getOpenId())){
|
|
|
- UserAuthInfo userAuthInfo = sysUserService.getUserAuthInfo(userParam.getOpenId());
|
|
|
- if(userAuthInfo == null){
|
|
|
- //如果没有注册,需要注册该微信用户
|
|
|
- UserForm userForm = new UserForm();
|
|
|
- userForm.setUsername(userParam.getOpenId());
|
|
|
- userForm.setNickname(userParam.getNickName());
|
|
|
- userForm.setAvatar(userParam.getAvatarUrl());
|
|
|
- userForm.setGender(userParam.getGender());
|
|
|
- sysUserService.saveUser(userForm);
|
|
|
- userInfo.setId(userForm.getId().toString());
|
|
|
- userInfo.setNickName(userParam.getNickName());
|
|
|
- userInfo.setAvatarUrl(userParam.getAvatarUrl());
|
|
|
- //生成token
|
|
|
- userAuthInfo = new UserAuthInfo();
|
|
|
- userAuthInfo.setUsername(userParam.getOpenId());
|
|
|
- userInfo.setAccessToken(getToken(userAuthInfo));
|
|
|
- }else{
|
|
|
- userInfo.setId(userAuthInfo.getUserId().toString());
|
|
|
- userInfo.setNickName(userAuthInfo.getNickname());
|
|
|
- userInfo.setAvatarUrl(userParam.getAvatarUrl());
|
|
|
- //生成token
|
|
|
- userInfo.setAccessToken(getToken(userAuthInfo));
|
|
|
- }
|
|
|
+ userInfo.setAccessToken("");
|
|
|
+ userInfo.setNickName("test");
|
|
|
+ userInfo.setId("1");
|
|
|
}else{
|
|
|
//登录失败
|
|
|
log.info("获取用户信息失败");
|
|
|
+ userInfo.setAccessToken("");
|
|
|
+ userInfo.setNickName("test");
|
|
|
+ userInfo.setId("1");
|
|
|
}
|
|
|
return process(() -> userInfo);
|
|
|
}
|
|
@@ -120,7 +103,34 @@ public class UserController extends CommonController {
|
|
|
*/
|
|
|
@GetMapping("/wxMpLogin")
|
|
|
public CommonResult<UserInfo> wxMpLogin(LoginParam loginParam){
|
|
|
- return process(() -> userService.wxMpLogin(loginParam));
|
|
|
+ UserInfo userInfo = userService.wxMpLogin(loginParam);
|
|
|
+ if(loginParam.getOpenId() != null){
|
|
|
+ UserAuthInfo userAuthInfo = sysUserService.getUserAuthInfo(loginParam.getOpenId());
|
|
|
+ if(userAuthInfo == null){
|
|
|
+ //如果没有注册,需要注册该微信用户
|
|
|
+ UserForm userForm = new UserForm();
|
|
|
+ userForm.setUsername(userInfo.getOpenId());
|
|
|
+ userForm.setNickname(userInfo.getNickName());
|
|
|
+ userForm.setAvatar(userInfo.getAvatarUrl());
|
|
|
+ userForm.setGender(userInfo.getGender());
|
|
|
+ sysUserService.saveUser(userForm);
|
|
|
+ //组装
|
|
|
+ userInfo.setNickName(userInfo.getNickName());
|
|
|
+ userInfo.setAvatarUrl(userInfo.getAvatarUrl());
|
|
|
+ //生成token
|
|
|
+ userAuthInfo = new UserAuthInfo();
|
|
|
+ userAuthInfo.setUsername(userInfo.getOpenId());
|
|
|
+ userInfo.setAccessToken(getToken(userAuthInfo));
|
|
|
+ }else{
|
|
|
+ userInfo.setId(userAuthInfo.getUserId().toString());
|
|
|
+ userInfo.setNickName(userAuthInfo.getNickname());
|
|
|
+ userInfo.setAvatarUrl(userInfo.getAvatarUrl());
|
|
|
+ //生成token
|
|
|
+ userInfo.setAccessToken(getToken(userAuthInfo));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return process(() -> userInfo);
|
|
|
}
|
|
|
|
|
|
|