fix account unblock login cache
This commit is contained in:
parent
97738f5b5e
commit
d7c3fbf721
@ -39,7 +39,7 @@ public enum ConsoleAccountStatusEnum {
|
||||
/**
|
||||
* 账号解封.
|
||||
*/
|
||||
UNTIE_ACOOUNT("UNTIE_DEVICE", "账号解封"),
|
||||
UNTIE_ACOOUNT("UNTIE_ACOOUNT", "账号解封"),
|
||||
|
||||
/**
|
||||
* 设备+账户解封.
|
||||
|
||||
@ -246,10 +246,10 @@ public class UserAccountCommon {
|
||||
* 解封账号.
|
||||
*/
|
||||
public void unblock(UnblockAccountCmd cmd) {
|
||||
userProfileGateway.removeCacheAll(cmd.getBeOptUserId());
|
||||
if (!baseInfoService.updateAccountStatus(cmd.getBeOptUserId(), AccountStatusEnum.NORMAL)) {
|
||||
return;
|
||||
}
|
||||
userProfileGateway.removeCacheAll(cmd.getBeOptUserId());
|
||||
|
||||
// 记录日志
|
||||
approvalUserAccountStatusLogService.save(new ApprovalUserAccountStatusLog()
|
||||
|
||||
@ -263,17 +263,29 @@ public class UserAccountClientServiceImpl implements UserAccountClientService {
|
||||
|
||||
@Override
|
||||
public boolean updateAccountFreeze(Long userId, Integer days) {
|
||||
return baseInfoService.updateAccountFreeze(userId, days);
|
||||
boolean updated = baseInfoService.updateAccountFreeze(userId, days);
|
||||
if (updated) {
|
||||
userProfileGateway.removeCacheAll(userId);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateAccountStatus(Long userId, AccountStatusEnum accountStatus) {
|
||||
return baseInfoService.updateAccountStatus(userId, accountStatus);
|
||||
boolean updated = baseInfoService.updateAccountStatus(userId, accountStatus);
|
||||
if (updated) {
|
||||
userProfileGateway.removeCacheAll(userId);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateAccountStatusDays(Long userId, AccountStatusEnum accountStatus, Integer days) {
|
||||
return baseInfoService.updateAccountStatusDays(userId, accountStatus, days);
|
||||
boolean updated = baseInfoService.updateAccountStatusDays(userId, accountStatus, days);
|
||||
if (updated) {
|
||||
userProfileGateway.removeCacheAll(userId);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -388,9 +400,12 @@ public class UserAccountClientServiceImpl implements UserAccountClientService {
|
||||
|
||||
|
||||
public UserAccountDTO createUserAccountDTO(Long userId, String imei, VoidConsumer voidConsumer) {
|
||||
UserProfile userProfile = userProfileGateway.getByUserId(userId);
|
||||
userProfile.setFamilyId(Optional.ofNullable(familyMemberInfoService.getFamilyMemberByUserId(userId)).map(FamilyMemberInfo::getFamilyId).orElse(null));
|
||||
UserProfile userProfile = refreshStaleAccountStatus(userId,
|
||||
userProfileGateway.getByUserId(userId));
|
||||
ResponseAssert.notNull(CommonErrorCode.DATA_ERROR, userProfile);
|
||||
userProfile.setFamilyId(Optional.ofNullable(familyMemberInfoService.getFamilyMemberByUserId(userId))
|
||||
.map(FamilyMemberInfo::getFamilyId)
|
||||
.orElse(null));
|
||||
|
||||
// 注册黑名单
|
||||
if (Objects.equals(userProfile.getDel(), Boolean.TRUE)) {
|
||||
@ -431,6 +446,22 @@ public class UserAccountClientServiceImpl implements UserAccountClientService {
|
||||
return errorCode.getMessage() + "[ ID:" + userProfile.getAccount() + "]";
|
||||
}
|
||||
|
||||
private UserProfile refreshStaleAccountStatus(Long userId, UserProfile userProfile) {
|
||||
if (Objects.isNull(userProfile) || userProfile.checkAccountAvailable()) {
|
||||
return userProfile;
|
||||
}
|
||||
|
||||
BaseInfo baseInfo = baseInfoService.getById(userId);
|
||||
if (Objects.isNull(baseInfo)
|
||||
|| (Objects.equals(baseInfo.getAccountStatus(), userProfile.getAccountStatus())
|
||||
&& Objects.equals(baseInfo.getFreezingTime(), userProfile.getFreezingTime()))) {
|
||||
return userProfile;
|
||||
}
|
||||
|
||||
userProfileGateway.removeCacheAll(userId);
|
||||
return userProfileGateway.getByUserId(userId);
|
||||
}
|
||||
|
||||
private void sendLoginMessage(AuthTypeEnum authTypeEnum, AppExtCommand cmd) {
|
||||
userMqMessageService.loginLogger(Objects.toString(cmd.requiredReqUserId()),
|
||||
userProfileInnerConvertor.toLoginLoggerEventLogin(authTypeEnum, cmd));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user