com.minlia.rocket.abstraction.endpoint.ExistsByConditionEndpoint Maven / Gradle / Ivy
package com.minlia.rocket.abstraction.endpoint;
import com.minlia.rocket.abstraction.service.ConditionalService;
import com.minlia.rocket.data.body.AbstractQueryRequestBody;
import com.minlia.rocket.loggable.annotation.Loggable;
import com.minlia.rocket.stateful.Responses;
import com.minlia.rocket.stateful.body.StatefulBody;
import com.minlia.rocket.stateful.body.WithResultBody;
import com.minlia.rocket.stateful.body.impl.SuccessResponseBody;
import io.swagger.annotations.ApiOperation;
import java.io.Serializable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FunctionalInterface
public interface ExistsByConditionEndpoint {
@Autowired
public abstract ConditionalService getConditionalService();
//TODO 添加权限点控制
@Loggable
@PostMapping(value = "/exists", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
@ApiOperation(value = "Exists by conditions")
public default ResponseEntity>> exists(
@RequestBody QUERY requestBody) {
WithResultBody body = new WithResultBody();
body.setResult(getConditionalService().existsByCondition(requestBody));
return Responses.ok(SuccessResponseBody.builder()
.payload(body).build());
}
}