|
@@ -66,38 +66,94 @@ public class UserDetailsServiceImpl implements UserDetailsService
|
|
|
return createLoginUser(user);
|
|
|
} else if (StudentLoginTypeEnum.AUTHORIZATION_CODE_LOGIN.getCode().equals(loginType)){
|
|
|
{
|
|
|
- UserInfo userInfo = userService.getStudentByOpenId(identification);
|
|
|
+ //由于之前没有保存用户unionid,只有openid,所以这里判定两个都不存在才不存在用户
|
|
|
+ UserInfo userInfoGetByUnionId = userService.getStudentByUnionId(identification);
|
|
|
+ String openid = (String)ServletUtils.getRequest().getAttribute("openid");
|
|
|
+ UserInfo userInfoGetByOpenId = userService.getStudentByUnionId(openid);
|
|
|
String third = (String)ServletUtils.getRequest().getAttribute("third");
|
|
|
- if (userInfo == null) {
|
|
|
- userInfo = new UserInfo();
|
|
|
+ if (userInfoGetByUnionId == null && userInfoGetByOpenId == null) {
|
|
|
+ UserInfo userInfo = new UserInfo();
|
|
|
userInfo.setHeadImage((String) ServletUtils.getRequest().getAttribute("headImage"));
|
|
|
userInfo.setNickName((String) ServletUtils.getRequest().getAttribute("nickName"));
|
|
|
userInfo.setThirdPlatform(third);
|
|
|
- userInfo.setOpenid(identification);
|
|
|
+ userInfo.setAppOpenid(openid);
|
|
|
+ userInfo.setUnionId(identification);
|
|
|
userInfo.setIsVip(0);
|
|
|
userService.saveUserInfo(userInfo);
|
|
|
- userInfo = userService.getStudentByOpenId(identification);
|
|
|
+ return createLoginUser(userService.getStudentByUnionId(identification));
|
|
|
}else {
|
|
|
+ UserInfo userInfo = userInfoGetByUnionId != null ? userInfoGetByUnionId:userInfoGetByOpenId;
|
|
|
userInfo.setHeadImage((String) ServletUtils.getRequest().getAttribute("headImage"));
|
|
|
userInfo.setNickName((String) ServletUtils.getRequest().getAttribute("nickName"));
|
|
|
+ userInfo.setThirdPlatform(third);
|
|
|
+ userInfo.setUnionId(identification);
|
|
|
userService.updateStudent(userInfo);
|
|
|
+ return createLoginUser(userService.getStudentByUnionId(identification));
|
|
|
}
|
|
|
- return createLoginUser(userInfo);
|
|
|
+
|
|
|
}
|
|
|
+ }
|
|
|
+ else if (StudentLoginTypeEnum.AUTHORIZATION_CODE_DY_LOGIN.getCode().equals(loginType)){
|
|
|
+ UserInfo userInfoGetByUnionId = userService.getStudentByUnionId(identification);
|
|
|
+ String openid = (String)ServletUtils.getRequest().getAttribute("openid");;
|
|
|
+ String third = (String)ServletUtils.getRequest().getAttribute("third");
|
|
|
+ if (userInfoGetByUnionId == null ) {
|
|
|
+ UserInfo userInfo = new UserInfo();
|
|
|
+ userInfo.setHeadImage((String) ServletUtils.getRequest().getAttribute("headImage"));
|
|
|
+ userInfo.setNickName((String) ServletUtils.getRequest().getAttribute("nickName"));
|
|
|
+ userInfo.setThirdPlatform(third);
|
|
|
+ userInfo.setAppOpenid(openid);
|
|
|
+ userInfo.setUnionId(identification);
|
|
|
+ userInfo.setIsVip(0);
|
|
|
+ userService.saveUserInfo(userInfo);
|
|
|
+ return createLoginUser(userService.getStudentByUnionId(identification));
|
|
|
+ }else {
|
|
|
+ UserInfo userInfo = userInfoGetByUnionId;
|
|
|
+ userInfo.setHeadImage((String) ServletUtils.getRequest().getAttribute("headImage"));
|
|
|
+ userInfo.setNickName((String) ServletUtils.getRequest().getAttribute("nickName"));
|
|
|
+ userInfo.setAppOpenid(openid);
|
|
|
+ userService.updateStudent(userInfo);
|
|
|
+ return createLoginUser(userService.getStudentByUnionId(identification));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (StudentLoginTypeEnum.AUTHORIZATION_CODE_TT_LOGIN.getCode().equals(loginType)){
|
|
|
+ UserInfo userInfoGetByUnionId = userService.getStudentByUnionId(identification);
|
|
|
+ String openid = (String)ServletUtils.getRequest().getAttribute("openid");;
|
|
|
+ String third = (String)ServletUtils.getRequest().getAttribute("third");
|
|
|
+ if (userInfoGetByUnionId == null ) {
|
|
|
+ UserInfo userInfo = new UserInfo();
|
|
|
+// userInfo.setHeadImage((String) ServletUtils.getRequest().getAttribute("headImage"));
|
|
|
+// userInfo.setNickName((String) ServletUtils.getRequest().getAttribute("nickName"));
|
|
|
+ userInfo.setThirdPlatform(third);
|
|
|
+ userInfo.setXcxOpenid(openid);
|
|
|
+ userInfo.setUnionId(identification);
|
|
|
+ userInfo.setIsVip(0);
|
|
|
+ userService.saveUserInfo(userInfo);
|
|
|
+ return createLoginUser(userService.getStudentByUnionId(identification));
|
|
|
+ }else {
|
|
|
+ UserInfo userInfo = userInfoGetByUnionId;
|
|
|
+ userInfo.setXcxOpenid(openid);
|
|
|
+// userInfo.setHeadImage((String) ServletUtils.getRequest().getAttribute("headImage"));
|
|
|
+// userInfo.setNickName((String) ServletUtils.getRequest().getAttribute("nickName"));
|
|
|
+ userService.updateStudent(userInfo);
|
|
|
+ return createLoginUser(userService.getStudentByUnionId(identification));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
else if (StudentLoginTypeEnum.IOS_CODE_LOGIN.getCode().equals(loginType)){
|
|
|
{
|
|
|
UserInfo userInfo = userService.getStudentByOpenId(identification);
|
|
|
if (userInfo == null) {
|
|
|
userInfo = new UserInfo();
|
|
|
- userInfo.setOpenid(identification);
|
|
|
+ userInfo.setAppOpenid(identification);
|
|
|
userService.saveUserInfo(userInfo);
|
|
|
}
|
|
|
- return createLoginUser(userInfo);
|
|
|
+ return createLoginUser(userService.getStudentByOpenId(identification));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
else{
|
|
|
throw new CustomException("登录类型不存在");
|
|
|
}
|