|
@@ -17,6 +17,8 @@ import com.boman.common.core.utils.StringUtils;
|
|
import com.boman.common.security.service.TokenService;
|
|
import com.boman.common.security.service.TokenService;
|
|
import com.boman.system.api.model.LoginUser;
|
|
import com.boman.system.api.model.LoginUser;
|
|
|
|
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* token 控制
|
|
* token 控制
|
|
*
|
|
*
|
|
@@ -37,7 +39,6 @@ public class TokenController {
|
|
|
|
|
|
@PostMapping("login")
|
|
@PostMapping("login")
|
|
public R<?> login(@RequestBody LoginBody form) {
|
|
public R<?> login(@RequestBody LoginBody form) {
|
|
- String unionId = "";
|
|
|
|
String openId = "";
|
|
String openId = "";
|
|
// 验证是pc还是小程序
|
|
// 验证是pc还是小程序
|
|
if (form.getLogintype() != null && form.getLogintype().equals(WechatEnum.W.getValue())) {
|
|
if (form.getLogintype() != null && form.getLogintype().equals(WechatEnum.W.getValue())) {
|
|
@@ -45,11 +46,10 @@ public class TokenController {
|
|
if ((Integer) result.get(AjaxResult.CODE_TAG) != 0) {
|
|
if ((Integer) result.get(AjaxResult.CODE_TAG) != 0) {
|
|
throw new BaseException((String) result.get(AjaxResult.MSG_TAG));
|
|
throw new BaseException((String) result.get(AjaxResult.MSG_TAG));
|
|
}
|
|
}
|
|
- JSONObject jsonObject = (JSONObject) result.get(AjaxResult.DATA_TAG);
|
|
|
|
|
|
+ Map<String, Object> jsonObject = (Map<String, Object>) result.get(AjaxResult.DATA_TAG);
|
|
if (jsonObject == null) {
|
|
if (jsonObject == null) {
|
|
throw new BaseException("未获取到微信鉴权相关信息!");
|
|
throw new BaseException("未获取到微信鉴权相关信息!");
|
|
}
|
|
}
|
|
- unionId = (String) jsonObject.get("unionid");
|
|
|
|
openId = (String) jsonObject.get("openId");
|
|
openId = (String) jsonObject.get("openId");
|
|
}
|
|
}
|
|
// 用户登录
|
|
// 用户登录
|
|
@@ -57,10 +57,9 @@ public class TokenController {
|
|
// 如果是微信登录并且获取到的用户的unionId不为空
|
|
// 如果是微信登录并且获取到的用户的unionId不为空
|
|
if (form.getLogintype() != null
|
|
if (form.getLogintype() != null
|
|
&& form.getLogintype().equals(WechatEnum.W.getValue())
|
|
&& form.getLogintype().equals(WechatEnum.W.getValue())
|
|
- && StringUtils.isNotEmpty(unionId)) {
|
|
|
|
|
|
+ && StringUtils.isNotEmpty(openId)) {
|
|
SysUser sysUser = new SysUser();
|
|
SysUser sysUser = new SysUser();
|
|
- sysUser.setId(userInfo.getUserid());
|
|
|
|
- sysUser.setUnionId(unionId);
|
|
|
|
|
|
+ sysUser.setId(userInfo.getSysUser().getId());
|
|
sysUser.setOpenId(openId);
|
|
sysUser.setOpenId(openId);
|
|
AjaxResult updateResult = sysLoginService.updateUnionId(sysUser);
|
|
AjaxResult updateResult = sysLoginService.updateUnionId(sysUser);
|
|
if((Integer) updateResult.get(AjaxResult.CODE_TAG) != 0) {
|
|
if((Integer) updateResult.get(AjaxResult.CODE_TAG) != 0) {
|