修复:修复后台删除用户后列表残留

This commit is contained in:
xiaowang
2026-03-26 16:55:30 +08:00
parent be596f15d1
commit c0eae0ef03
5 changed files with 112 additions and 4 deletions
@@ -1364,6 +1364,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
return shopOptions;
}
if (userShopBindingSupport.hasBindingHistory(userDO.getId())) {
return shopOptions;
}
Long legacyShopId = normalizeShopId(userDO.getShopId());
if (legacyShopId != null) {
ShopVO legacyShop = shopService.getShopById(legacyShopId);
@@ -49,7 +49,16 @@ public class AdminScopeHelper {
public Long resolveShopScope(UserDO currentUser, Long requestedShopId) {
Long managedShopId = getManagedShopId(currentUser);
return managedShopId != null ? managedShopId : requestedShopId;
if (managedShopId != null) {
return managedShopId;
}
if (requestedShopId != null && requestedShopId > 0) {
return requestedShopId;
}
if (currentUser != null && currentUser.getShopId() != null && currentUser.getShopId() > 0) {
return currentUser.getShopId();
}
return null;
}
public void ensureShopAccessible(UserDO currentUser, Long targetShopId, String message) {
@@ -1,6 +1,7 @@
package com.xiaowang.yuminailcore.support;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.xiaowang.yuminailcore.entity.ShopDO;
import com.xiaowang.yuminailcore.entity.UserDO;
import com.xiaowang.yuminailcore.entity.UserShopBindingDO;
@@ -382,9 +383,14 @@ public class UserShopBindingSupport {
if (Objects.equals(userDO.getShopId(), primaryShopId)) {
return;
}
userDO.setShopId(primaryShopId);
userDO.setUpdateTime(LocalDateTime.now());
userMapper.updateById(userDO);
LocalDateTime now = LocalDateTime.now();
userMapper.update(
null,
new LambdaUpdateWrapper<UserDO>()
.eq(UserDO::getId, userId)
.set(UserDO::getShopId, primaryShopId)
.set(UserDO::getUpdateTime, now)
);
}
private Map<Long, ShopDO> fetchAllShopMap(boolean onlyActiveShops) {