修复:修复按店铺删除用户残留显示

This commit is contained in:
xiaowang
2026-03-26 16:16:38 +08:00
parent 8c13f5a96a
commit c06d57873a
3 changed files with 42 additions and 16 deletions
+12 -2
View File
@@ -971,7 +971,12 @@ const handleModalCancel = () => {
const handleStatusChange = async (record: any, checked: boolean) => {
try {
await adminUserApi.updateUserStatus(record.id, checked ? 1 : 0)
const success = await adminUserApi.updateUserStatus(record.id, checked ? 1 : 0)
if (!success) {
message.warning('未找到当前店铺下可更新状态的用户绑定')
await fetchUserList()
return
}
record.status = checked ? 1 : 0
message.success(`已${checked ? '启用' : '停用'}当前店铺下的用户访问`)
} catch (error) {
@@ -1002,7 +1007,12 @@ const handleDelete = async (record: any) => {
message.warning('管理员账号无法被删除')
return
}
await adminUserApi.deleteUser(record.id)
const success = await adminUserApi.deleteUser(record.id)
if (!success) {
message.warning('未找到当前店铺下可删除的用户绑定')
await fetchUserList()
return
}
message.success('已移除当前店铺下的用户绑定')
await fetchUserList()
} catch (error) {
@@ -273,17 +273,20 @@ public class UserShopBindingSupport {
if (userId == null || shopId == null || shopId <= 0) {
return false;
}
UserShopBindingDO binding = userShopBindingMapper.selectOne(new LambdaQueryWrapper<UserShopBindingDO>()
List<UserShopBindingDO> bindings = userShopBindingMapper.selectList(new LambdaQueryWrapper<UserShopBindingDO>()
.eq(UserShopBindingDO::getUserId, userId)
.eq(UserShopBindingDO::getShopId, shopId)
.eq(UserShopBindingDO::getIsDelete, 0)
.last("limit 1"));
if (binding == null) {
.eq(UserShopBindingDO::getIsDelete, 0));
if (bindings.isEmpty()) {
return false;
}
binding.setStatus(Integer.valueOf(1).equals(status) ? 1 : 0);
binding.setUpdateTime(LocalDateTime.now());
userShopBindingMapper.updateById(binding);
Integer normalizedStatus = Integer.valueOf(1).equals(status) ? 1 : 0;
LocalDateTime now = LocalDateTime.now();
for (UserShopBindingDO binding : bindings) {
binding.setStatus(normalizedStatus);
binding.setUpdateTime(now);
userShopBindingMapper.updateById(binding);
}
refreshLegacyPrimaryShop(userId);
return true;
}
@@ -293,17 +296,19 @@ public class UserShopBindingSupport {
if (userId == null || shopId == null || shopId <= 0) {
return false;
}
UserShopBindingDO binding = userShopBindingMapper.selectOne(new LambdaQueryWrapper<UserShopBindingDO>()
List<UserShopBindingDO> bindings = userShopBindingMapper.selectList(new LambdaQueryWrapper<UserShopBindingDO>()
.eq(UserShopBindingDO::getUserId, userId)
.eq(UserShopBindingDO::getShopId, shopId)
.eq(UserShopBindingDO::getIsDelete, 0)
.last("limit 1"));
if (binding == null) {
.eq(UserShopBindingDO::getIsDelete, 0));
if (bindings.isEmpty()) {
return false;
}
binding.setIsDelete(1);
binding.setUpdateTime(LocalDateTime.now());
userShopBindingMapper.updateById(binding);
LocalDateTime now = LocalDateTime.now();
for (UserShopBindingDO binding : bindings) {
binding.setIsDelete(1);
binding.setUpdateTime(now);
userShopBindingMapper.updateById(binding);
}
refreshLegacyPrimaryShop(userId);
return true;
}
@@ -27,6 +27,17 @@
- 在后台获取“当前用户权限”时,先同步一次该账号的受管默认权限,再返回权限列表。
- 这样历史店长账号即使之前权限数据漂移,只要重新进入后台并拉取权限,就会补齐默认的 `user:create` 等能力。
### 3. 用户按店铺删除的残留显示修复
- 文件:`YumiNail-Core/src/main/java/com/xiaowang/yuminailcore/support/UserShopBindingSupport.java`
- 文件:`Frontend/src/views/admin/UsersView.vue`
- 修复“删除当前店铺下用户绑定后,列表里仍能看到用户”的问题:
- 后端原先只删除一条匹配绑定记录,历史重复绑定数据会残留
- 现改为同一用户在同一店铺下的所有有效绑定一并删除/更新状态
- 前端删除和停用动作新增布尔结果判断:
- 后端返回 `false` 时,不再误提示成功
- 会明确提示当前店铺下未找到可操作的用户绑定,并刷新列表
## 结果说明
- 后台新增用户时,手机号重复会在表单阶段直接报出,不再只能等提交后由后端兜底。