From c06d57873a105bccadbfb61109270aaea84dffe9 Mon Sep 17 00:00:00 2001 From: xiaowang Date: Thu, 26 Mar 2026 16:16:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=8C=89=E5=BA=97=E9=93=BA=E5=88=A0=E9=99=A4=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=AE=8B=E7=95=99=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/src/views/admin/UsersView.vue | 14 ++++++-- .../support/UserShopBindingSupport.java | 33 +++++++++++-------- ...用户手机号唯一校验与店长新增美甲师修复.md | 11 +++++++ 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/Frontend/src/views/admin/UsersView.vue b/Frontend/src/views/admin/UsersView.vue index 9fa78057..6f6cea75 100644 --- a/Frontend/src/views/admin/UsersView.vue +++ b/Frontend/src/views/admin/UsersView.vue @@ -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) { diff --git a/YumiNail-Core/src/main/java/com/xiaowang/yuminailcore/support/UserShopBindingSupport.java b/YumiNail-Core/src/main/java/com/xiaowang/yuminailcore/support/UserShopBindingSupport.java index 2d5bc1f7..8a6accee 100644 --- a/YumiNail-Core/src/main/java/com/xiaowang/yuminailcore/support/UserShopBindingSupport.java +++ b/YumiNail-Core/src/main/java/com/xiaowang/yuminailcore/support/UserShopBindingSupport.java @@ -273,17 +273,20 @@ public class UserShopBindingSupport { if (userId == null || shopId == null || shopId <= 0) { return false; } - UserShopBindingDO binding = userShopBindingMapper.selectOne(new LambdaQueryWrapper() + List bindings = userShopBindingMapper.selectList(new LambdaQueryWrapper() .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() + List bindings = userShopBindingMapper.selectList(new LambdaQueryWrapper() .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; } diff --git a/docs/changes/2026-03-26-后台用户手机号唯一校验与店长新增美甲师修复.md b/docs/changes/2026-03-26-后台用户手机号唯一校验与店长新增美甲师修复.md index 12f24035..07b71cee 100644 --- a/docs/changes/2026-03-26-后台用户手机号唯一校验与店长新增美甲师修复.md +++ b/docs/changes/2026-03-26-后台用户手机号唯一校验与店长新增美甲师修复.md @@ -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` 时,不再误提示成功 + - 会明确提示当前店铺下未找到可操作的用户绑定,并刷新列表 + ## 结果说明 - 后台新增用户时,手机号重复会在表单阶段直接报出,不再只能等提交后由后端兜底。