com.minlia.rocket.abstraction.endpoint.FindOneByIdEndpoint Maven / Gradle / Ivy
package com.minlia.rocket.abstraction.endpoint;
import com.minlia.rocket.data.interfaces.IRawService;
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.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.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@FunctionalInterface
public interface FindOneByIdEndpoint {
@Autowired
public abstract IRawService getRawService();
/**
* 使用 @Pretend(value = "**,-payload.items.code") 进行结果排除,不需要此字段在前端展示
*/
//TODO 添加权限点控制
@Loggable
@GetMapping(value = "/{id}", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
@ApiOperation(value = "Find one by id")
public default ResponseEntity> findOne(@PathVariable ID id) {
ENTITY entity = getRawService().findOne(id);
return Responses.ok(SuccessResponseBody.builder()
.payload(entity).build());
}
}