Merge branch 'hotfix/20240723-menuSync' into 'master'

fix(REQ-2545): 2545同步菜单优化,已pre环境关联的角色为准。全量覆盖同步至环境的数据。

See merge request universal/infrastructure/backend/tyr!80
This commit is contained in:
李龙 2024-07-23 09:09:18 +00:00
commit f799013c6e
2 changed files with 22 additions and 6 deletions

View File

@ -40,6 +40,7 @@ public class FeatureResourceController implements FeatureResourceApi {
@Override
public ApiResult<Void> syncFromBase(ResourceSyncReq req) {
log.warn("sync menu, operatorId:{}", req.getOperatorId());
if (CollectionUtil.isEmpty(req.getIds())) {
log.warn("no ids to sync from base env");

View File

@ -233,20 +233,35 @@ public class FeatureResourceSyncServiceImpl implements FeatureResourceSyncServic
}
private void doFeatureResourceRole(SaasFeatureResource featureResource, List<String> roleCodes, Long operatorId) {
if (Objects.isNull(featureResource) || CollectionUtils.isEmpty(roleCodes)) {
if (Objects.isNull(featureResource)) {
return;
}
List<String> existRoleCodes = getFeatureResourceRoleCodeMap(Lists.newArrayList(featureResource.getId()))
.get(featureResource.getId());
if (CollectionUtils.isNotEmpty(existRoleCodes)) {
roleCodes.removeAll(existRoleCodes);
// 先清除资源绑定的角色 @20240723 产品武艳华要求资源绑定的角色以PRE角色为准
List<SaasPgroupPermissionRelation> existPermissionRelations = saasPgroupPermissionRelationDao.lambdaQuery()
.eq(BaseEntity::getIsDelete, DeleteEnum.NORMAL.value)
.eq(SaasPgroupPermissionRelation::getFeatureId, featureResource.getId())
.eq(SaasPgroupPermissionRelation::getType, NEW_FEATURE)
.list();
if (CollectionUtils.isNotEmpty(existPermissionRelations)) {
log.warn("sync menu delete SaasPgroupPermissionRelation operateId:{} featureResourceId:{}, saasPgroupPermissionRelationIds:{}", operatorId, featureResource.getId(), existPermissionRelations.stream().map(BaseEntity::getId).collect(Collectors.toList()));
saasPgroupPermissionRelationDao.removeByFeatureIdAndGroupIds(featureResource.getId(), existPermissionRelations.stream().map(SaasPgroupPermissionRelation::getGroupId).collect(Collectors.toList()), operatorId);
}
if (CollectionUtils.isEmpty(roleCodes)) {
return;
}
// List<String> existRoleCodes = getFeatureResourceRoleCodeMap(Lists.newArrayList(featureResource.getId()))
// .get(featureResource.getId());
//
// if (CollectionUtils.isNotEmpty(existRoleCodes)) {
// roleCodes.removeAll(existRoleCodes);
// }
// if (CollectionUtils.isEmpty(roleCodes)) {
// return;
// }
List<SaasRole> saasRoles = saasRoleDao.listByRoleCodes(roleCodes);
if (CollectionUtils.isEmpty(saasRoles)) {
return;