feat: 拦截器同步用户调整
parent
1501cfdd23
commit
8ebdfdfcae
|
|
@ -7,6 +7,7 @@ import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
||||||
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserInfo;
|
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserInfo;
|
||||||
import org.qinan.safetyeval.infrastructure.dataobject.AccountDO;
|
import org.qinan.safetyeval.infrastructure.dataobject.AccountDO;
|
||||||
import org.qinan.safetyeval.infrastructure.mapper.AccountMapper;
|
import org.qinan.safetyeval.infrastructure.mapper.AccountMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
|
|
@ -36,7 +37,7 @@ public class GbsUserSyncInterceptor implements WebMvcConfigurer {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
AuthUserInfo currentUser = AuthUserContextAdapter.getCurrentUser();
|
AuthUserInfo currentUser = AuthUserContextAdapter.getCurrentUser();
|
||||||
if (currentUser == null) {
|
if (currentUser == null || currentUser.getUserId() == null) {
|
||||||
throw new BizException(ErrorCode.GBS_USER_ERROR);
|
throw new BizException(ErrorCode.GBS_USER_ERROR);
|
||||||
}
|
}
|
||||||
AccountDO accountDO = accountMapper.selectById(currentUser.getUserId());
|
AccountDO accountDO = accountMapper.selectById(currentUser.getUserId());
|
||||||
|
|
@ -45,10 +46,11 @@ public class GbsUserSyncInterceptor implements WebMvcConfigurer {
|
||||||
AccountDO accountSave = new AccountDO();
|
AccountDO accountSave = new AccountDO();
|
||||||
accountSave.setId(currentUser.getUserId());
|
accountSave.setId(currentUser.getUserId());
|
||||||
accountSave.setUserName(currentUser.getUserName());
|
accountSave.setUserName(currentUser.getUserName());
|
||||||
accountSave.setAccount(currentUser.getAccount());
|
accountSave.setAccount(currentUser.getAccount() == null ? "" : currentUser.getAccount());
|
||||||
accountSave.setPhone(currentUser.getMobile());
|
accountSave.setPhone(currentUser.getMobile() == null ? "" : currentUser.getMobile());
|
||||||
accountSave.setTenantId(currentUser.getTenantId());
|
accountSave.setTenantId(currentUser.getTenantId());
|
||||||
accountSave.setType(2);
|
accountSave.setType(2);
|
||||||
|
InsertFieldDefaults.applyIgnoreOrgId(accountSave);
|
||||||
accountMapper.insert(accountSave);
|
accountMapper.insert(accountSave);
|
||||||
log.info("用户{}同步gbs信息成功", currentUser.getUserName());
|
log.info("用户{}同步gbs信息成功", currentUser.getUserName());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue