|
|
|
@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
@@ -68,21 +69,15 @@ public class WeChatController { |
|
|
|
|
|
|
|
log.info("微信login返回信息:{}", weChatUserInfo); |
|
|
|
R<SysEnterpriseStaff> staff = tenantService.existStaff(weChatUserInfo.getOpenid(), SecurityConstants.INNER); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
try { |
|
|
|
if (staff.getData() == null) { |
|
|
|
return AjaxResult.error("对应用户不存在", CryptoUtils.encrypt(weChatUserInfo.toString()) ); |
|
|
|
} else { |
|
|
|
map.put("wechat_auth", CryptoUtils.encrypt(weChatUserInfo.toString())); |
|
|
|
if (staff.getData() != null) { |
|
|
|
R<LoginUser> loginInfoResult = remoteLoginService.getLoginInfoInnerByPhone(staff.getData().getPhone(), SecurityConstants.INNER); |
|
|
|
|
|
|
|
log.info("根据openid获取用户信息返回信息:{}", loginInfoResult.getData().getEnterpriseName()); |
|
|
|
if (ObjectUtil.isNull(loginInfoResult.getData())) { |
|
|
|
return AjaxResult.error("手机号可能错误,请查证后重试!", CryptoUtils.encrypt(weChatUserInfo.toString())); |
|
|
|
} else { |
|
|
|
Map<String, Object> map = tokenService.createToken(loginInfoResult.getData()); |
|
|
|
map.put("openid", weChatUserInfo.getOpenid()); |
|
|
|
return AjaxResult.success(map); |
|
|
|
} |
|
|
|
map.putAll(tokenService.createToken(loginInfoResult.getData())); |
|
|
|
return AjaxResult.success(map); |
|
|
|
} |
|
|
|
return AjaxResult.success(map); |
|
|
|
} catch (Exception e){ |
|
|
|
e.printStackTrace(); |
|
|
|
response.setStatus(500); |
|
|
|
|