|
@@ -116,65 +116,56 @@ public class WechatController {
|
|
|
redirectCodeCoookie.setMaxAge(3600);
|
|
|
response.addCookie(redirectCodeCoookie);
|
|
|
|
|
|
- if (netLoginVideoAccess.contains(redirectCode)) {
|
|
|
- JSONObject userInfoJson = WechatHandle.getUserInfo(openid, appid, secret, code);
|
|
|
- UserAccount userAccount = userAccountService.checkAccountByUnionid(userInfoJson);
|
|
|
- Document document = MongoDBUtil.queryVLoginToken(userAccount.getId());
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.add(Calendar.DAY_OF_YEAR,30);
|
|
|
- String loginToken = UUID.randomUUID().toString();
|
|
|
- if( Objects.isNull(document)){
|
|
|
- MongoDBUtil.insertVLoginToken(calendar.getTime(),userAccount.getId(),loginToken,1);
|
|
|
- }else{
|
|
|
- MongoDBUtil.updateVLoginTOken(calendar.getTime(),userAccount.getId(),loginToken);
|
|
|
- }
|
|
|
- Cookie cookie0 = new Cookie("loginTokenAccount", userAccount.getId());
|
|
|
- cookie0.setPath("/");
|
|
|
- cookie0.setMaxAge(24 * 60 * 60);
|
|
|
- cookie0.setDomain("360lj.com");
|
|
|
- response.addCookie(cookie0);
|
|
|
- Cookie cookie1 = new Cookie("LoginToken", loginToken);
|
|
|
- cookie1.setPath("/");
|
|
|
- cookie1.setMaxAge(24 * 60 * 60);
|
|
|
- cookie1.setDomain("360lj.com");
|
|
|
- response.addCookie(cookie1);
|
|
|
- if (identity.equals(0)) { //用户授权
|
|
|
- if (StringUtils.isBlank(userAccount.getNickname())) {
|
|
|
- String url = redirectPathSource.getRedirectPath(redirectCode, userAccount, id);
|
|
|
- logger.debug("将跳转至:"+url);
|
|
|
- response.sendRedirect(url);
|
|
|
- return;
|
|
|
- }
|
|
|
- String url = redirectPathSource.getRedirectPath(redirectCode, null, "");
|
|
|
- logger.debug("将跳转至:"+url);
|
|
|
- response.sendRedirect(url);
|
|
|
- return;
|
|
|
- }
|
|
|
- return;
|
|
|
+ JSONObject userInfoJson = WechatHandle.getUserInfo(openid, appid, secret, code);
|
|
|
+ UserAccount userAccount = userAccountService.checkAccountByUnionid(userInfoJson);
|
|
|
+ Document document = MongoDBUtil.queryVLoginToken(userAccount.getId());
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.add(Calendar.DAY_OF_YEAR,30);
|
|
|
+ String loginToken = UUID.randomUUID().toString();
|
|
|
+ if( Objects.isNull(document)){
|
|
|
+ MongoDBUtil.insertVLoginToken(calendar.getTime(),userAccount.getId(),loginToken,1);
|
|
|
+ }else{
|
|
|
+ MongoDBUtil.updateVLoginTOken(calendar.getTime(),userAccount.getId(),loginToken);
|
|
|
}
|
|
|
-
|
|
|
- //原.net授权
|
|
|
- JSONObject userInfoJson1 = WechatHandle.getUserInfo(openid, appid, secret, code);
|
|
|
- UserAccount user = userAccountService.checkAccountByUnionid(userInfoJson1);
|
|
|
- Cookie cookie1 = new Cookie("loginTokenAccount", user.getId());
|
|
|
+ Cookie cookie0 = new Cookie("loginTokenAccount", userAccount.getId());
|
|
|
+ cookie0.setPath("/");
|
|
|
+ cookie0.setMaxAge(24 * 60 * 60);
|
|
|
+ cookie0.setDomain("360lj.com");
|
|
|
+ response.addCookie(cookie0);
|
|
|
+ Cookie cookie1 = new Cookie("LoginToken", loginToken);
|
|
|
cookie1.setPath("/");
|
|
|
cookie1.setMaxAge(24 * 60 * 60);
|
|
|
cookie1.setDomain("360lj.com");
|
|
|
response.addCookie(cookie1);
|
|
|
+// if (netLoginVideoAccess.contains(redirectCode)) {
|
|
|
+// if (identity.equals(0)) { //用户授权
|
|
|
+// if (StringUtils.isBlank(userAccount.getNickname())) {
|
|
|
+// String url = redirectPathSource.getRedirectPath(redirectCode, userAccount, id);
|
|
|
+// logger.debug("将跳转至:" + url);
|
|
|
+// response.sendRedirect(url);
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// String url = redirectPathSource.getRedirectPath(redirectCode, null, "");
|
|
|
+// logger.debug("将跳转至:"+url);
|
|
|
+// response.sendRedirect(url);
|
|
|
+// return;
|
|
|
+// }
|
|
|
+
|
|
|
if (identity.equals(0)) { //用户授权
|
|
|
- if (StringUtils.isBlank(user.getNickname())) {
|
|
|
- response.sendRedirect(redirectPathSource.getRedirectPath(redirectCode, user, id));
|
|
|
+ if (StringUtils.isBlank(userAccount.getNickname())) {
|
|
|
+ response.sendRedirect(redirectPathSource.getRedirectPath(redirectCode, userAccount, id));
|
|
|
return;
|
|
|
}
|
|
|
response.sendRedirect(redirectPathSource.getRedirectPath(redirectCode, null, ""));
|
|
|
return;
|
|
|
} else if(identity.equals(1) || identity.equals(2)){ //医生合伙人授权
|
|
|
- userRoleService.checkRole(identity, user, id, redirectCode, response);
|
|
|
+ userRoleService.checkRole(identity, userAccount, id, redirectCode, response);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 判断是否有该用户,如果有跳转个人中心,没有则跳转注册页面
|
|
|
- if (user == null) {
|
|
|
+ if (userAccount == null) {
|
|
|
JSONObject userInfo = WechatHandle.getUserInfo(openid, appid, secret, code);
|
|
|
userAccountService.create(userInfo);
|
|
|
logger.info("将跳转至: " + fillInfoPath);
|
|
@@ -182,13 +173,13 @@ public class WechatController {
|
|
|
response.getWriter().print(html);
|
|
|
return;
|
|
|
}
|
|
|
- if (StringUtils.isBlank(user.getMobile())) {
|
|
|
+ if (StringUtils.isBlank(userAccount.getMobile())) {
|
|
|
logger.info("将跳转至: " + fillInfoPath);
|
|
|
String html = "<script type='text/javascript'>location.href='" + fillInfoPath + "';</script>";
|
|
|
response.getWriter().print(html);
|
|
|
return;
|
|
|
}
|
|
|
- String otherRedirectPath = redirectPathSource.getRedirectPath(redirectCode, user, id);
|
|
|
+ String otherRedirectPath = redirectPathSource.getRedirectPath(redirectCode, userAccount, id);
|
|
|
logger.info("将跳转至: " + otherRedirectPath);
|
|
|
String html = "<script type='text/javascript'>" +
|
|
|
"location.href='" + otherRedirectPath + "';" +
|