This commit is contained in:
@@ -229,7 +229,6 @@ public class SysUserService implements ISysUserService {
|
|||||||
throw new DException("存在无效用户");
|
throw new DException("存在无效用户");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Integer> deletedUserIds = new ArrayList<>();
|
|
||||||
for (Integer userId : userIds) {
|
for (Integer userId : userIds) {
|
||||||
// 删除当前组关联
|
// 删除当前组关联
|
||||||
sysUserGroupRelRepository.deleteByUserIdAndGroupId(userId, groupId);
|
sysUserGroupRelRepository.deleteByUserIdAndGroupId(userId, groupId);
|
||||||
@@ -237,12 +236,10 @@ public class SysUserService implements ISysUserService {
|
|||||||
if (sysUserGroupRelRepository.countByUserId(userId) == 0) {
|
if (sysUserGroupRelRepository.countByUserId(userId) == 0) {
|
||||||
sysUserAppRoleRelRepository.deleteByUserIdBulk(userId);
|
sysUserAppRoleRelRepository.deleteByUserIdBulk(userId);
|
||||||
sysUserRepository.deleteById(userId);
|
sysUserRepository.deleteById(userId);
|
||||||
deletedUserIds.add(userId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!deletedUserIds.isEmpty()) {
|
// 业务语义:从组移除 = 对子应用即删除(不论是否真删账户),统一推送 DELETE_USER
|
||||||
publishUserEvent(PushInterfaceType.DELETE_USER, deletedUserIds);
|
publishUserEvent(PushInterfaceType.DELETE_USER, userIds);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -65,6 +65,16 @@ public class PushDispatcher {
|
|||||||
if (type == null) {
|
if (type == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 删除类事件:实体已从库中删除,AFTER_COMMIT 阶段重载必然为空,
|
||||||
|
// 直接用事件携带的 id 构建删除体;删除幂等,绕过范围过滤全量投递给已开启删除事件的订阅方
|
||||||
|
if (type == PushInterfaceType.DELETE_GROUP || type == PushInterfaceType.DELETE_USER) {
|
||||||
|
List<Integer> ids = (type == PushInterfaceType.DELETE_GROUP)
|
||||||
|
? event.getGroupIds() : event.getUserIds();
|
||||||
|
for (ApplicationInfo app : applicationInfoRepository.findByPushEnabled(1)) {
|
||||||
|
dispatchDeleteToOne(app, type, ids, "auto");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
List<SysGroup> groups = (event.getGroupIds() != null && !event.getGroupIds().isEmpty())
|
List<SysGroup> groups = (event.getGroupIds() != null && !event.getGroupIds().isEmpty())
|
||||||
? sysGroupRepository.findAllById(event.getGroupIds()) : Collections.emptyList();
|
? sysGroupRepository.findAllById(event.getGroupIds()) : Collections.emptyList();
|
||||||
List<SysUser> users = (event.getUserIds() != null && !event.getUserIds().isEmpty())
|
List<SysUser> users = (event.getUserIds() != null && !event.getUserIds().isEmpty())
|
||||||
@@ -177,6 +187,36 @@ public class PushDispatcher {
|
|||||||
|
|
||||||
// ===================== 核心 =====================
|
// ===================== 核心 =====================
|
||||||
|
|
||||||
|
/** 删除类事件专用投递:跳过 DB 重载与范围过滤,直接用事件携带的 id 构建删除体。 */
|
||||||
|
private void dispatchDeleteToOne(ApplicationInfo app, PushInterfaceType type, List<Integer> ids, String triggerType) {
|
||||||
|
if (app.getPushEnabled() == null || app.getPushEnabled() != 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 仍校验订阅方是否勾选了删除接口
|
||||||
|
if (!containsEventType(app.getPushEventTypes(), type.getPath())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ids == null || ids.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (Object bodyObj : buildDeleteBodies(type, ids)) {
|
||||||
|
sendMessage(app, type, bodyObj, triggerType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除类接口 body 形态:DELETE_GROUP 每个 id 一条 {id};DELETE_USER 整体一条数组 [id,...]。 */
|
||||||
|
private List<Object> buildDeleteBodies(PushInterfaceType type, List<Integer> ids) {
|
||||||
|
if (type == PushInterfaceType.DELETE_GROUP) {
|
||||||
|
return ids.stream()
|
||||||
|
.map(id -> Collections.singletonMap("id", id))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
if (type == PushInterfaceType.DELETE_USER) {
|
||||||
|
return Collections.singletonList(new ArrayList<>(ids));
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
private void dispatchToOne(ApplicationInfo app, PushInterfaceType type,
|
private void dispatchToOne(ApplicationInfo app, PushInterfaceType type,
|
||||||
List<SysGroup> groups, List<SysUser> users, String triggerType, boolean force) {
|
List<SysGroup> groups, List<SysUser> users, String triggerType, boolean force) {
|
||||||
if (app.getPushEnabled() == null || app.getPushEnabled() != 1) {
|
if (app.getPushEnabled() == null || app.getPushEnabled() != 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user