Merge branch 'feature/REQ-3714' into 'master'

Feature/req 3714

See merge request universal/infrastructure/backend/tyr!448
This commit is contained in:
李龙 2025-03-26 03:29:39 +00:00
commit fc0e524184
2 changed files with 22 additions and 19 deletions

View File

@ -88,7 +88,7 @@ public class RocketMQEventConfiguration {
@Slf4j
@Component
@RocketMQMessageListener(topic = "%RETRY%GID_topic_thrones_${spring.profiles.active}",
consumerGroup = "GID_topic_thrones_${spring.application.name}_${spring.profiles.active}",
consumerGroup = "GID_topic_thrones_retry_${spring.application.name}_${spring.profiles.active}",
messageModel = MessageModel.BROADCASTING,
nameServer = "${rocketmq.name-server}"
)
@ -130,7 +130,7 @@ public class RocketMQEventConfiguration {
@Slf4j
@Component
@RocketMQMessageListener(topic = "%RETRY%GID_topic_tyr_${spring.profiles.active}",
consumerGroup = "GID_topic_tyr_${spring.application.name}_${spring.profiles.active}",
consumerGroup = "GID_topic_tyr_retry_${spring.application.name}_${spring.profiles.active}",
messageModel = MessageModel.BROADCASTING,
nameServer = "${rocketmq.name-server}"
)
@ -176,7 +176,7 @@ public class RocketMQEventConfiguration {
@Slf4j
@Component
@RocketMQMessageListener(topic = "%RETRY%GID_topic_apisix_plat_${spring.profiles.active}",
consumerGroup = "GID_topic_apisix_plat_${spring.application.name}_${spring.profiles.active}",
consumerGroup = "GID_topic_apisix_plat_retry_${spring.application.name}_${spring.profiles.active}",
messageModel = MessageModel.BROADCASTING,
nameServer = "${rocketmq.name-server}"
)

View File

@ -223,46 +223,49 @@ public class SaasRoleUserRelationServiceImpl extends ServiceImpl<SaasRoleUserRel
.collect(Collectors.groupingBy(e -> e.getIdentityId() + "_" + e.getIdentityType() +
"_" + e.getSaasRoleUser().getPersonId() + "_" + e.getWorkspaceId() + "_" + e.getOuId()));
// 根据入参解析insertdelete的记录
List<SaasRoleUserRelation> upsert = Lists.newArrayList();
assembleInsertData(roleUserMap, param, roles, upsert);
List<SaasRoleUserRelation> insert = Lists.newArrayList();
List<SaasRoleUserRelation> remove = Lists.newArrayList();
assembleInsertData(roleUserMap, param, roles, insert);
assembleDeleteData(roleUserMap, param, roles, upsert);
assembleDeleteData(roleUserMap, param, roles, remove);
// 批量insertdelete
if (CollectionUtils.isEmpty(upsert)) {
if (CollectionUtils.isEmpty(insert) && CollectionUtils.isEmpty(remove)) {
return;
}
this.saveOrUpdateBatch(upsert);
if (!CollectionUtils.isEmpty(insert)) {
this.saveBatch(insert);
}
if (!CollectionUtils.isEmpty(remove)) {
this.removeByIds(Lists.transform(remove, SaasRoleUserRelation::getId));
}
// 发送mq
List<SaasRoleUserRelation> inserts = upsert.stream()
.filter(saasRoleUserRelation -> Objects.isNull(saasRoleUserRelation.getIsDelete()) || Objects.equals(TableIsDeleteEnum.NORMAL.value, saasRoleUserRelation.getIsDelete()))
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(inserts)) {
if (!CollectionUtils.isEmpty(insert)) {
Event event = Event.builder()
.targetType(TARGET_TYPE)
.eventCode(SAAS_ROLE_USER_RELATION_UPSERT.getEventCode())
.data(SaasRoleUserRelationUpsertPayload.builder()
.newValues(inserts)
.newValues(insert)
.build())
.build();
mqProducer.send(event);
}
List<SaasRoleUserRelation> deletes = upsert.stream()
.filter(saasRoleUserRelation -> Objects.nonNull(saasRoleUserRelation.getIsDelete()) && !Objects.equals(TableIsDeleteEnum.NORMAL.value, saasRoleUserRelation.getIsDelete()))
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(deletes)) {
if (!CollectionUtils.isEmpty(remove)) {
Event event = Event.builder()
.targetType(TARGET_TYPE)
.eventCode(SAAS_ROLE_USER_RELATION_REMOVED.getEventCode())
.data(SaasRoleUserRelationRemovePayload.builder()
.values(deletes)
.values(remove)
.build())
.build();
mqProducer.send(event);
}
insert.addAll(remove);
operateLogService.save(LogAddReq.builder()
.scene("UPSERT_USER_ROLE")
@ -274,7 +277,7 @@ public class SaasRoleUserRelationServiceImpl extends ServiceImpl<SaasRoleUserRel
.message(new JSONObject()
.fluentPut("param", param)
.fluentPut("oldValues", oldRoleUsers)
.fluentPut("newValues", upsert)
.fluentPut("newValues", insert)
.toJSONString())
.build());
}