@EventListener(SelectorCreatedEvent.class)
    public void onSelectorCreated(final SelectorCreatedEvent event) {
        // check selector add
        Boolean existed;
        try {
            existed = dataPermissionMapper.existed(JwtUtils.getUserInfo().getUserId());
        } catch (Exception e) {
            existed = false;
        }
        if (Boolean.TRUE.equals(existed)) {
            DataPermissionDTO dataPermissionDTO = new DataPermissionDTO();
            dataPermissionDTO.setUserId(JwtUtils.getUserInfo().getUserId());
            dataPermissionDTO.setDataId(event.getSelector().getId());
            dataPermissionDTO.setDataType(AdminConstants.SELECTOR_DATA_TYPE);
            dataPermissionMapper.insertSelective(DataPermissionDO.buildPermissionDO(dataPermissionDTO));
        } else {
            String namespaceId = event.getSelector().getNamespaceId();
            if (StringUtils.isNoneBlank(namespaceId)) {
                // support namespace
                List<NamespaceUserRelDO> namespaceUserRelDOList = namespaceUserRelMapper.selectListByNamespaceId(namespaceId);
                if (CollectionUtils.isNotEmpty(namespaceUserRelDOList)) {
                    namespaceUserRelDOList.forEach(namespaceUserRelDO -> {
                        DataPermissionDTO dataPermissionDTO = new DataPermissionDTO();
                        dataPermissionDTO.setUserId(namespaceUserRelDO.getUserId());
                        dataPermissionDTO.setDataId(event.getSelector().getId());
                        dataPermissionDTO.setDataType(AdminConstants.SELECTOR_DATA_TYPE);
                        dataPermissionMapper.insertSelective(DataPermissionDO.buildPermissionDO(dataPermissionDTO));
                    });
                }
            }
        }
    }
listen {@link SelectorCreatedEvent} add data permission.

@param event event
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/DataPermissionServiceImpl.java