Search in sources :

Example 96 with AuthAction

use of com.alibaba.csp.sentinel.dashboard.auth.AuthAction in project RuoYi-Cloud-Plus by JavaLionLi.

the class ParamFlowRuleController method apiDeleteRule.

@DeleteMapping("/rule/{id}")
@AuthAction(PrivilegeType.DELETE_RULE)
public Result<Long> apiDeleteRule(@PathVariable("id") Long id) {
    if (id == null) {
        return Result.ofFail(-1, "id cannot be null");
    }
    ParamFlowRuleEntity oldEntity = repository.findById(id);
    if (oldEntity == null) {
        return Result.ofSuccess(null);
    }
    try {
        repository.delete(id);
        publishRules(oldEntity.getApp(), oldEntity.getIp(), oldEntity.getPort()).get();
        return Result.ofSuccess(id);
    } catch (ExecutionException ex) {
        logger.error("Error when deleting parameter flow rules", ex.getCause());
        if (isNotSupported(ex.getCause())) {
            return unsupportedVersion();
        } else {
            return Result.ofThrowable(-1, ex.getCause());
        }
    } catch (Throwable throwable) {
        logger.error("Error when deleting parameter flow rules", throwable);
        return Result.ofFail(-1, throwable.getMessage());
    }
}
Also used : ParamFlowRuleEntity(com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity) ExecutionException(java.util.concurrent.ExecutionException) AuthAction(com.alibaba.csp.sentinel.dashboard.auth.AuthAction)

Aggregations

AuthAction (com.alibaba.csp.sentinel.dashboard.auth.AuthAction)96 Date (java.util.Date)70 FlowRuleEntity (com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity)31 ExecutionException (java.util.concurrent.ExecutionException)25 PostMapping (org.springframework.web.bind.annotation.PostMapping)20 PutMapping (org.springframework.web.bind.annotation.PutMapping)20 ParamFlowRuleEntity (com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity)15 ApiDefinitionEntity (com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity)10 ApiPredicateItemEntity (com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiPredicateItemEntity)10 GatewayFlowRuleEntity (com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayFlowRuleEntity)10 GatewayParamFlowItemEntity (com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayParamFlowItemEntity)10 AuthorityRuleEntity (com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity)10 DegradeRuleEntity (com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity)10 SystemRuleEntity (com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity)10 ApiPredicateItemVo (com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.ApiPredicateItemVo)10 GatewayParamFlowItemVo (com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.rule.GatewayParamFlowItemVo)10 GetMapping (org.springframework.web.bind.annotation.GetMapping)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)8 SentinelGatewayConstants (com.alibaba.csp.sentinel.adapter.gateway.common.SentinelGatewayConstants)5