mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 02:46:50 +08:00
提交修改
This commit is contained in:
@@ -186,7 +186,72 @@ public class PortalLoginApi extends ApiBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新的登录处理,通过接口,同步用户数据
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/boenewlogin", method = {RequestMethod.GET,RequestMethod.POST})
|
||||
public JsonResponse<Map<String, Object>> boeNewLogin(String token) {
|
||||
try {
|
||||
if (StringUtil.isBlank(token)) {
|
||||
return wrap(JsonResponseStatus.TOKEN_NOPASS, "token error");
|
||||
}
|
||||
Map<String, String> tokenInfo = authorizationToken.readToken(token);
|
||||
if (tokenInfo == null) {
|
||||
return wrap(JsonResponseStatus.TOKEN_NOPASS, "token error");
|
||||
}
|
||||
Account account = null;
|
||||
if(StringUtil.isNotBlank(tokenInfo.get("aid"))){
|
||||
//检查系统用户是否存在
|
||||
account = accountService.get(tokenInfo.get("aid"));
|
||||
}else{
|
||||
//log.error("查询用户kid【"+tokenInfo.get("userId")+"】");
|
||||
// 没有aid则判断是否已同步的用户,不是则同步
|
||||
if(StringUtil.isNotBlank(tokenInfo.get("userId"))){
|
||||
account = accountService.findLoginBySysId(tokenInfo.get("userId"));
|
||||
if(account == null){ //系统中无此用户,需要同步用户
|
||||
log.error("未找到【"+tokenInfo.get("userId")+"】的用户");
|
||||
UserVo fwUser = fwUserService.getById(tokenInfo.get("userId"));
|
||||
if(fwUser != null) {
|
||||
try {
|
||||
account = userService.syncUser(fwUser);
|
||||
} catch (Exception e) {
|
||||
log.error("boelogin同步用户错误:" + e.getMessage());
|
||||
return error("登录失败,未同步用户");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(account.getDeleted()!=null && account.getDeleted()) {
|
||||
return error("登录失败,用户已删除,请与管理员联系");
|
||||
}else if(account.getStatus()!=null && account.getStatus()==Account.STATUS_DEAD) {
|
||||
return error("登录失败,用户已停用,请与管理员联系");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
return error("token不合法");
|
||||
}
|
||||
}
|
||||
if (account == null) {
|
||||
log.error("未找到用户的id:"+tokenInfo.get("userId"));
|
||||
return error("未找到的用户信息");
|
||||
}
|
||||
|
||||
//在这种情况下情况下,应该重置 一下缓存,以便对用户进行缓存更新
|
||||
//String cacheKey=CacheName.NAME_USER+ CacheName.KEY_USER_SYSID +account.getId();
|
||||
|
||||
// if (account.getStatus() == Constants.ACCOUNT_STATUS_DEACTIVATE) {
|
||||
// return error("账号已停用");
|
||||
// }
|
||||
|
||||
Map<String, Object> map = this.createToken(account);
|
||||
//此处以后用于服务端记录,因为当前不再转化token,直接使用老系统生成的token
|
||||
return success(map);
|
||||
} catch (Exception e) {
|
||||
log.error("boe登录 错误", e);
|
||||
return error("boe登录失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* boe登录
|
||||
|
||||
Reference in New Issue
Block a user