@Override
    @Transactional(rollbackFor = Exception.class)
    public int createRule(final DataPermissionDTO dataPermissionDTO) {
        RuleDO ruleDO = ruleMapper.selectById(dataPermissionDTO.getDataId());
        if (Objects.isNull(ruleDO)) {
            return 0;
        }
        
        int count = 0;
        DataPermissionDO selectorDataPermissionDo = dataPermissionMapper.findOneByUniqueKey(ruleDO.getSelectorId(),
                dataPermissionDTO.getUserId(), AdminDataPermissionTypeEnum.SELECTOR.ordinal());
        if (Objects.isNull(selectorDataPermissionDo)) {
            DataPermissionDO selectorDataPermissionDO = DataPermissionDO.buildCreatePermissionDO(ruleDO.getSelectorId(),
                    dataPermissionDTO.getUserId(), AdminDataPermissionTypeEnum.SELECTOR.ordinal());
            count = dataPermissionMapper.insertSelective(selectorDataPermissionDO);
        }
        
        dataPermissionDTO.setDataType(AdminDataPermissionTypeEnum.RULE.ordinal());
        count += dataPermissionMapper.insertSelective(DataPermissionDO.buildPermissionDO(dataPermissionDTO));
        
        return count;
    }
create rule data permission.

@param dataPermissionDTO {@linkplain DataPermissionDTO}
@return int, effect rows count
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/DataPermissionServiceImpl.java