Merge branch 'release/20250219' into 'master'
Release/20250219 See merge request universal/infrastructure/backend/tyr!434
This commit is contained in:
commit
7b288ae110
@ -41,6 +41,5 @@ public class ChangeGroupLeaderRoleReq {
|
|||||||
/**
|
/**
|
||||||
* 权限名列表
|
* 权限名列表
|
||||||
*/
|
*/
|
||||||
@NotEmpty
|
|
||||||
private List<Long> roleIdList = Lists.newArrayList();
|
private List<Long> roleIdList = Lists.newArrayList();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,6 +53,12 @@ public class ListRoleUserRelationParam {
|
|||||||
@CriteriaField(field = "resourceId", operator = Operator.IN)
|
@CriteriaField(field = "resourceId", operator = Operator.IN)
|
||||||
private Set<Long> resourceIds;
|
private Set<Long> resourceIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源Id
|
||||||
|
*/
|
||||||
|
@CriteriaField(field = "resourceId", operator = Operator.IN)
|
||||||
|
private Set<Long> resourceIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否显示
|
* 是否显示
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -84,6 +84,29 @@ public class RocketMQEventConfiguration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Profile("!unittest")
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RocketMQMessageListener(topic = "%RETRY%GID_topic_thrones_${spring.profiles.active}",
|
||||||
|
consumerGroup = "GID_topic_thrones_${spring.application.name}_${spring.profiles.active}",
|
||||||
|
messageModel = MessageModel.BROADCASTING,
|
||||||
|
nameServer = "${rocketmq.name-server}"
|
||||||
|
)
|
||||||
|
public static class RetryThronesListener extends BaseListener implements RocketMQListener<MessageExt> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EventConsumer eventConsumer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessage(MessageExt message) {
|
||||||
|
try {
|
||||||
|
super.onEvent(message, eventConsumer);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.warn("retry consumer thrones message error,", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Profile("!unittest")
|
@Profile("!unittest")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@ -103,6 +126,29 @@ public class RocketMQEventConfiguration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Profile("!unittest")
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RocketMQMessageListener(topic = "%RETRY%GID_topic_tyr_${spring.profiles.active}",
|
||||||
|
consumerGroup = "GID_topic_tyr_${spring.application.name}_${spring.profiles.active}",
|
||||||
|
messageModel = MessageModel.BROADCASTING,
|
||||||
|
nameServer = "${rocketmq.name-server}"
|
||||||
|
)
|
||||||
|
public static class RetryTyrListener extends BaseListener implements RocketMQListener<MessageExt> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EventConsumer eventConsumer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessage(MessageExt message) {
|
||||||
|
try {
|
||||||
|
super.onEvent(message, eventConsumer);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.warn("retry consumer tyr message error,", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Profile("!unittest")
|
@Profile("!unittest")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@ -118,7 +164,34 @@ public class RocketMQEventConfiguration {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(MessageExt message) {
|
public void onMessage(MessageExt message) {
|
||||||
super.onEvent(message, eventConsumer);
|
try {
|
||||||
|
super.onEvent(message, eventConsumer);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.warn("consumer apisixPlat message error,", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Profile("!unittest")
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RocketMQMessageListener(topic = "%RETRY%GID_topic_apisix_plat_${spring.profiles.active}",
|
||||||
|
consumerGroup = "GID_topic_apisix_plat_${spring.application.name}_${spring.profiles.active}",
|
||||||
|
messageModel = MessageModel.BROADCASTING,
|
||||||
|
nameServer = "${rocketmq.name-server}"
|
||||||
|
)
|
||||||
|
public static class RetryApiSixPlatListener extends BaseListener implements RocketMQListener<MessageExt> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EventConsumer eventConsumer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessage(MessageExt message) {
|
||||||
|
try {
|
||||||
|
super.onEvent(message, eventConsumer);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.warn("retry consumer apisixPlat message error,", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ public enum EventTypeEnum {
|
|||||||
PAGE_ELEMENT_FEATURE_RESOURCE_UPSERT("page-element-feature-resource", "page-element-feature-resource-upsert", "菜单-页面元素绑定关系更新"),
|
PAGE_ELEMENT_FEATURE_RESOURCE_UPSERT("page-element-feature-resource", "page-element-feature-resource-upsert", "菜单-页面元素绑定关系更新"),
|
||||||
SAAS_ROLE_USER_RELATION_REMOVED("saas-role-user-relation", "saas-role-user-relation-removed", "删除用户角色信息"),
|
SAAS_ROLE_USER_RELATION_REMOVED("saas-role-user-relation", "saas-role-user-relation-removed", "删除用户角色信息"),
|
||||||
SAAS_ROLE_USER_RELATION_UPSERT("saas-role-user-relation", "saas-role-user-relation-upsert", "更新用户角色信息"),
|
SAAS_ROLE_USER_RELATION_UPSERT("saas-role-user-relation", "saas-role-user-relation-upsert", "更新用户角色信息"),
|
||||||
|
SAAS_ROLE_UPSERT("saas-role", "saas-role-upsert", "更新角色信息"),
|
||||||
;
|
;
|
||||||
|
|
||||||
EventTypeEnum(String model, String name, String desc) {
|
EventTypeEnum(String model, String name, String desc) {
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
package cn.axzo.tyr.server.event.payload;
|
||||||
|
|
||||||
|
import cn.axzo.tyr.server.repository.entity.SaasRole;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class SaasRoleUpsertPayload implements Serializable {
|
||||||
|
|
||||||
|
private SaasRole newRole;
|
||||||
|
|
||||||
|
private SaasRole oldRole;
|
||||||
|
}
|
||||||
@ -55,6 +55,7 @@ import cn.axzo.tyr.client.model.vo.SaveOrUpdateRoleVO;
|
|||||||
import cn.axzo.tyr.server.config.MqProducer;
|
import cn.axzo.tyr.server.config.MqProducer;
|
||||||
import cn.axzo.tyr.server.event.payload.RolePermissionCreatedPayload;
|
import cn.axzo.tyr.server.event.payload.RolePermissionCreatedPayload;
|
||||||
import cn.axzo.tyr.server.event.payload.SaasFeatureResourceUpsertPayload;
|
import cn.axzo.tyr.server.event.payload.SaasFeatureResourceUpsertPayload;
|
||||||
|
import cn.axzo.tyr.server.event.payload.SaasRoleUpsertPayload;
|
||||||
import cn.axzo.tyr.server.model.RelationOperateLogResourceBindRoleDO;
|
import cn.axzo.tyr.server.model.RelationOperateLogResourceBindRoleDO;
|
||||||
import cn.axzo.tyr.server.model.RelationOperateLogRoleBindResourceDO;
|
import cn.axzo.tyr.server.model.RelationOperateLogRoleBindResourceDO;
|
||||||
import cn.axzo.tyr.server.model.ResourcePermission;
|
import cn.axzo.tyr.server.model.ResourcePermission;
|
||||||
@ -144,6 +145,7 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
import static cn.axzo.tyr.server.event.inner.EventTypeEnum.ROLE_PERMISSION_CREATED;
|
import static cn.axzo.tyr.server.event.inner.EventTypeEnum.ROLE_PERMISSION_CREATED;
|
||||||
import static cn.axzo.tyr.server.event.inner.EventTypeEnum.SAAS_FEATURE_RESOURCE_UPSERT;
|
import static cn.axzo.tyr.server.event.inner.EventTypeEnum.SAAS_FEATURE_RESOURCE_UPSERT;
|
||||||
|
import static cn.axzo.tyr.server.event.inner.EventTypeEnum.SAAS_ROLE_UPSERT;
|
||||||
import static cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelation.NEW_FEATURE;
|
import static cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelation.NEW_FEATURE;
|
||||||
import static cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelation.OLD_FEATURE;
|
import static cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelation.OLD_FEATURE;
|
||||||
|
|
||||||
@ -502,6 +504,10 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
|
|||||||
List<SaveOrUpdateRoleVO.GroupInfoVO> groupTrees = saveOrUpdateRole.getGroupTree();
|
List<SaveOrUpdateRoleVO.GroupInfoVO> groupTrees = saveOrUpdateRole.getGroupTree();
|
||||||
// 验证角色分组信息
|
// 验证角色分组信息
|
||||||
validRoleGroup(groupTrees);
|
validRoleGroup(groupTrees);
|
||||||
|
SaasRole oldSaasRole = Optional.ofNullable(saveOrUpdateRole.getId())
|
||||||
|
.map(id -> saasRoleDao.getById(id))
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
SaasRole saasRole = validAndBuildRole(saveOrUpdateRole, now);
|
SaasRole saasRole = validAndBuildRole(saveOrUpdateRole, now);
|
||||||
//验证权限集信息
|
//验证权限集信息
|
||||||
SaasPermissionGroup saasPermissionGroup = validPermissionGroupCommon(saveOrUpdateRole);
|
SaasPermissionGroup saasPermissionGroup = validPermissionGroupCommon(saveOrUpdateRole);
|
||||||
@ -549,6 +555,15 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
|
|||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
mqProducer.send(event);
|
mqProducer.send(event);
|
||||||
|
// 上面是因为原来做权限的缓存,需要角色权限的事件,因为代码没有收口,所以这里把最基本的角色相关的事件补上
|
||||||
|
mqProducer.send(Event.builder()
|
||||||
|
.targetType("saasRoleId")
|
||||||
|
.eventCode(SAAS_ROLE_UPSERT.getEventCode())
|
||||||
|
.data(SaasRoleUpsertPayload.builder()
|
||||||
|
.newRole(saasRoleDao.getById(saasRole.getId()))
|
||||||
|
.oldRole(oldSaasRole)
|
||||||
|
.build())
|
||||||
|
.build());
|
||||||
return saasRole.getId();
|
return saasRole.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,7 @@ import cn.axzo.tyr.client.model.roleuser.req.RoleUserReq;
|
|||||||
import cn.axzo.tyr.client.model.roleuser.req.SuperAdminParam;
|
import cn.axzo.tyr.client.model.roleuser.req.SuperAdminParam;
|
||||||
import cn.axzo.tyr.client.model.roleuser.req.WorkerManagerRoleUserReq;
|
import cn.axzo.tyr.client.model.roleuser.req.WorkerManagerRoleUserReq;
|
||||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||||
|
import cn.axzo.tyr.server.common.util.DingTalkUtil;
|
||||||
import cn.axzo.tyr.server.config.MqProducer;
|
import cn.axzo.tyr.server.config.MqProducer;
|
||||||
import cn.axzo.tyr.server.event.payload.SaasRoleUserRelationUpsertPayload;
|
import cn.axzo.tyr.server.event.payload.SaasRoleUserRelationUpsertPayload;
|
||||||
import cn.axzo.tyr.server.model.RoleUserInfo;
|
import cn.axzo.tyr.server.model.RoleUserInfo;
|
||||||
@ -58,6 +59,7 @@ import cn.axzo.tyr.server.service.SaasRoleGroupService;
|
|||||||
import cn.axzo.tyr.server.service.SaasRoleUserRelationService;
|
import cn.axzo.tyr.server.service.SaasRoleUserRelationService;
|
||||||
import cn.axzo.tyr.server.service.SaasRoleUserService;
|
import cn.axzo.tyr.server.service.SaasRoleUserService;
|
||||||
import cn.axzo.tyr.server.utils.RpcExternalUtil;
|
import cn.axzo.tyr.server.utils.RpcExternalUtil;
|
||||||
|
import cn.azxo.framework.common.constatns.Constants;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
@ -69,6 +71,7 @@ import com.google.common.collect.Sets;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
|
import org.slf4j.MDC;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -124,7 +127,12 @@ public class RoleUserService implements SaasRoleUserService {
|
|||||||
|
|
||||||
@Value("#{${axzo.role.superAdmin}}")
|
@Value("#{${axzo.role.superAdmin}}")
|
||||||
private Map<Integer, String> superAdminCodes;
|
private Map<Integer, String> superAdminCodes;
|
||||||
|
@Value("${spring.profiles.active}")
|
||||||
|
private String env;
|
||||||
|
|
||||||
|
// 更新角色时,personId = 0的情况,线上有很多这样的数据,要排查到原因
|
||||||
|
private static final String ACCESS_TOKEN = "11cdf26d77211ee887184844910bf249b94aa2675c7ce36d75a7aa87d619490f";
|
||||||
|
private static final String SECRET = "SEC3c1be9e4fe4cc09f16eb4b2eebf91659f21d5bdfb1d764b52f3e47825e6bed3f";
|
||||||
/**
|
/**
|
||||||
* 获取分包负责人等特殊角色
|
* 获取分包负责人等特殊角色
|
||||||
* @return
|
* @return
|
||||||
@ -305,6 +313,20 @@ public class RoleUserService implements SaasRoleUserService {
|
|||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
mqProducer.send(event);
|
mqProducer.send(event);
|
||||||
|
|
||||||
|
// 历史有的记录personId = 0,故加上告警,排查问题
|
||||||
|
if (Objects.isNull(req.getPersonId()) || Objects.equals(req.getPersonId(), 0L)) {
|
||||||
|
String traceId = MDC.get(Constants.CTX_LOG_ID_MDC);
|
||||||
|
StringBuilder sb = new StringBuilder()
|
||||||
|
.append("环境:").append(env).append("\n")
|
||||||
|
.append("添加用户角色时,personId异常")
|
||||||
|
.append("personId:")
|
||||||
|
.append(req.getPersonId())
|
||||||
|
.append("\n")
|
||||||
|
.append("traceId:")
|
||||||
|
.append(traceId);
|
||||||
|
DingTalkUtil.sendMessage(sb.toString(), ACCESS_TOKEN, SECRET);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -408,6 +408,8 @@ public class SaasFeatureResourceServiceImpl extends ServiceImpl<SaasFeatureResou
|
|||||||
Optional<PageElementResp> pageElementOptional = saasPageElementFeatureResourceRelationService.list(pageElementFeatureResourceRelationReq)
|
Optional<PageElementResp> pageElementOptional = saasPageElementFeatureResourceRelationService.list(pageElementFeatureResourceRelationReq)
|
||||||
.stream()
|
.stream()
|
||||||
.map(PageElementFeatureResourceRelationResp::getPageElement)
|
.map(PageElementFeatureResourceRelationResp::getPageElement)
|
||||||
|
// 兼容菜单组件跟前端资源关联关系在,但是前端资源已经不存在的场景
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.findFirst();
|
.findFirst();
|
||||||
|
|
||||||
if (!pageElementOptional.isPresent()) {
|
if (!pageElementOptional.isPresent()) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user