feat:(REQ-2720) 菜单节点跟元素绑定关系更新后,根据修改发送mq的payload,减少日子大小

This commit is contained in:
lilong 2024-08-02 14:48:26 +08:00
parent a023d39607
commit bdf274a33d
7 changed files with 30 additions and 17 deletions

View File

@ -47,4 +47,7 @@ public class PageProductFeatureRelationReq implements IPageReq {
*/ */
@CriteriaField(field = "featureType", operator = Operator.IN) @CriteriaField(field = "featureType", operator = Operator.IN)
private List<Integer> featureResourceTypes; private List<Integer> featureResourceTypes;
@CriteriaField(field = "terminal", operator = Operator.EQ)
private String terminal;
} }

View File

@ -16,6 +16,7 @@ import cn.axzo.tyr.server.service.SaasFeatureResourceService;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -82,6 +83,10 @@ public class CacheProductPermissionHandler implements InitializingBean {
.build(); .build();
List<SaasProductModuleFeatureRelation> productFeatures = productFeatureRelationService.list(pageProductFeatureRelationReq); List<SaasProductModuleFeatureRelation> productFeatures = productFeatureRelationService.list(pageProductFeatureRelationReq);
if (CollectionUtils.isEmpty(productFeatures)) {
return;
}
storeProductPermission(productFeatures); storeProductPermission(productFeatures);
log.info("end cached product permission handler rocketmq event: {}", event); log.info("end cached product permission handler rocketmq event: {}", event);
} }
@ -90,7 +95,7 @@ public class CacheProductPermissionHandler implements InitializingBean {
log.info("begin cached product permission handler rocketmq event: {}", event); log.info("begin cached product permission handler rocketmq event: {}", event);
PageElementFeatureResourceUpsertPayload payload = event.normalizedData(PageElementFeatureResourceUpsertPayload.class); PageElementFeatureResourceUpsertPayload payload = event.normalizedData(PageElementFeatureResourceUpsertPayload.class);
if (CollectionUtils.isEmpty(payload.getRelations())) { if (StringUtils.isBlank(payload.getTerminal())) {
return; return;
} }
@ -98,6 +103,9 @@ public class CacheProductPermissionHandler implements InitializingBean {
.build(); .build();
List<SaasProductModuleFeatureRelation> productFeatures = productFeatureRelationService.list(pageProductFeatureRelationReq); List<SaasProductModuleFeatureRelation> productFeatures = productFeatureRelationService.list(pageProductFeatureRelationReq);
if (CollectionUtils.isEmpty(productFeatures)) {
return;
}
storeProductPermission(productFeatures); storeProductPermission(productFeatures);
log.info("end cached product permission handler rocketmq event: {}", event); log.info("end cached product permission handler rocketmq event: {}", event);
} }

View File

@ -94,7 +94,7 @@ public class CacheProductSaasFeatureResourceHandler implements InitializingBean
log.info("begin cached product featureResource handler rocketmq event: {}", event); log.info("begin cached product featureResource handler rocketmq event: {}", event);
PageElementFeatureResourceUpsertPayload payload = event.normalizedData(PageElementFeatureResourceUpsertPayload.class); PageElementFeatureResourceUpsertPayload payload = event.normalizedData(PageElementFeatureResourceUpsertPayload.class);
if (CollectionUtils.isEmpty(payload.getRelations())) { if (StringUtils.isBlank(payload.getTerminal())) {
return; return;
} }
@ -103,6 +103,9 @@ public class CacheProductSaasFeatureResourceHandler implements InitializingBean
.build(); .build();
List<SaasProductModuleFeatureRelation> productFeatures = productFeatureRelationService.list(pageProductFeatureRelationReq); List<SaasProductModuleFeatureRelation> productFeatures = productFeatureRelationService.list(pageProductFeatureRelationReq);
if (CollectionUtils.isEmpty(productFeatures)) {
return;
}
storeProductFeatureResource(productFeatures); storeProductFeatureResource(productFeatures);
log.info("end cached product featureResource handler rocketmq event: {}", event); log.info("end cached product featureResource handler rocketmq event: {}", event);
} }

View File

@ -19,6 +19,7 @@ import cn.axzo.tyr.server.service.SaasFeatureResourceService;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -94,7 +95,7 @@ public class CacheRolePermissionHandler implements InitializingBean {
public void onPageElementFeatureResourceUpsert(Event event, EventConsumer.Context context) { public void onPageElementFeatureResourceUpsert(Event event, EventConsumer.Context context) {
PageElementFeatureResourceUpsertPayload payload = event.normalizedData(PageElementFeatureResourceUpsertPayload.class); PageElementFeatureResourceUpsertPayload payload = event.normalizedData(PageElementFeatureResourceUpsertPayload.class);
if (CollectionUtils.isEmpty(payload.getRelations())) { if (StringUtils.isBlank(payload.getTerminal())) {
return; return;
} }

View File

@ -87,7 +87,7 @@ public class CacheRoleSaasFeatureResourceHandler implements InitializingBean {
public void onPageElementFeatureResourceUpsert(Event event, EventConsumer.Context context) { public void onPageElementFeatureResourceUpsert(Event event, EventConsumer.Context context) {
PageElementFeatureResourceUpsertPayload payload = event.normalizedData(PageElementFeatureResourceUpsertPayload.class); PageElementFeatureResourceUpsertPayload payload = event.normalizedData(PageElementFeatureResourceUpsertPayload.class);
if (CollectionUtils.isEmpty(payload.getRelations())) { if (StringUtils.isBlank(payload.getTerminal())) {
return; return;
} }

View File

@ -15,5 +15,5 @@ import java.util.List;
@AllArgsConstructor @AllArgsConstructor
public class PageElementFeatureResourceUpsertPayload implements Serializable { public class PageElementFeatureResourceUpsertPayload implements Serializable {
private List<SaasPageElementFeatureResourceRelation> relations; private String terminal;
} }

View File

@ -169,11 +169,7 @@ public class SaasPageElementServiceImpl implements SaasPageElementService {
Lists.newArrayList(modifyPageElementRelation.getFeatureResourceUniCode()), Lists.newArrayList(modifyPageElementRelation.getRelationType()), modifyPageElementRelation.getOperatorId()); Lists.newArrayList(modifyPageElementRelation.getFeatureResourceUniCode()), Lists.newArrayList(modifyPageElementRelation.getRelationType()), modifyPageElementRelation.getOperatorId());
// 保存新的绑定关系 // 保存新的绑定关系
if (CollectionUtils.isEmpty(modifyPageElementRelation.getPageElementCodes())) { if (CollectionUtils.isNotEmpty(modifyPageElementRelation.getPageElementCodes())) {
return;
}
// 保存新的绑定关系
List<SaasPageElementFeatureResourceRelation> relations = modifyPageElementRelation.getPageElementCodes().stream().map(e -> SaasPageElementFeatureResourceRelation.builder() List<SaasPageElementFeatureResourceRelation> relations = modifyPageElementRelation.getPageElementCodes().stream().map(e -> SaasPageElementFeatureResourceRelation.builder()
.pageElementCode(e) .pageElementCode(e)
.featureResourceUniCode(modifyPageElementRelation.getFeatureResourceUniCode()) .featureResourceUniCode(modifyPageElementRelation.getFeatureResourceUniCode())
@ -182,12 +178,14 @@ public class SaasPageElementServiceImpl implements SaasPageElementService {
.createBy(modifyPageElementRelation.getOperatorId()) .createBy(modifyPageElementRelation.getOperatorId())
.build()).collect(Collectors.toList()); .build()).collect(Collectors.toList());
saasPageElementFeatureResourceRelationDao.saveBatch(relations); saasPageElementFeatureResourceRelationDao.saveBatch(relations);
}
Event event = Event.builder() Event event = Event.builder()
.targetType(TARGET_TYPE) .targetType(TARGET_TYPE)
.eventCode(PAGE_ELEMENT_FEATURE_RESOURCE_UPSERT.getEventCode()) .eventCode(PAGE_ELEMENT_FEATURE_RESOURCE_UPSERT.getEventCode())
.data(PageElementFeatureResourceUpsertPayload.builder() .data(PageElementFeatureResourceUpsertPayload.builder()
.relations(relations) .terminal(modifyPageElementRelation.getTerminal())
.build()) .build())
.build(); .build();
mqProducer.send(event); mqProducer.send(event);