All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.scaff.crud.web.reactive.ReactiveDeleteController Maven / Gradle / Ivy

The newest version!
package org.zodiac.scaff.crud.web.reactive;

import io.swagger.annotations.ApiOperation;
//import io.swagger.v3.oas.annotations.Operation;

import org.zodiac.authorization.api.annotation.Authorize;
import org.zodiac.authorization.api.annotation.DeleteAction;
import org.zodiac.commons.exception.HttpNotFoundException;
import org.zodiac.fastorm.rdb.mapping.ReactiveRepository;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import reactor.core.publisher.Mono;

public interface ReactiveDeleteController {

    @Authorize(ignore = true)
    ReactiveRepository getRepository();

    @DeleteMapping("/{id:.+}")
    @DeleteAction
    //@Operation(summary = "Delete the data according to the ID.")
    @ApiOperation(value = "Delete the data according to the ID.")
    default Mono delete(@PathVariable K id) {
        return getRepository()
                .findById(Mono.just(id))
                .switchIfEmpty(Mono.error(HttpNotFoundException::new))
                .flatMap(e -> getRepository()
                        .deleteById(Mono.just(id))
                        .thenReturn(e));
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy