我一直在尝试使用spring-data-rest(SDR),并且对构建REST API的速度印象深刻。我的应用程序基于以下存储库,该存储库为我提供GET/attachements和POST/attachements
package com.deepskyblue.attachment.repository;
import java.util.List;
import org.springframework.data.repository.Repository;
import com.deepskyblue.attachment.domain.Attachment;
public interface AttachmentRepository extends Repository<Attachment, Long> {
List<Attachment> findAll();
Attachment save(Attachment attachment);
}
我感到困惑的一件事是如何添加自定义业务逻辑。如果我只想对数据使用REST API,那么SDR看起来很棒,但是传统的Spring应用程序通常会有一个服务层,在其中可以拥有业务逻辑。是否可以通过SDR添加此业务逻辑?
最佳答案
有很多可能性。