在Spring Data Rest中仅对子资源级别启用存储库?

时间:2018-07-09 13:56:53

标签: rest spring-data-jpa spring-data-rest

我有2个具有一对多关系的jpa实体Document和DispatchDetail。即文档可以具有dispatchDetails的列表。我为每个实体创建了2个存储库。

现在我要尝试获取文档。

http://localhost:7070/booking-documents-service/docs/5999571

{
    "docType": "SAP_ACCOUNTS_PAYABLE",
    "docStoreId": 456651,
    "qualityChecked": true,
    "format": "pdf",
    "bookingId": -1,
    "_links": {
        "self": {
            "href": "http://localhost:7070/booking-documents-service/docs/5999571"
        },
        "generatedDocument": {
            "href": "http://localhost:7070/booking-documents-service/docs/5999571"
        },
        "dispatchDetails": {
            "href": "http://localhost:7070/booking-documents-service/docs/5999571/dispatchDetails"
        }
    }
}

现在,当我尝试对列为dispatchDetails的链接进行GET请求时。就是这样。

http://localhost:7070/booking-documents-service/docs/5999571/dispatchDetails

{
    "_embedded": {
        "dispatchDetails": [
            {
                "dispatchQueId": 207443,
                "dispatchStatus": "S",
                "recipient": "fldcvisla12678.wdw.disney.com|#|/opt/apps/shared/shuttle/SAP/OUT/|#|f-tbxshuttlenp|#|D1$NeY984|#|SFTP|#|22|#|null",
                "description": "Upload :FileUploadDispatcher; FTP:null/null;\n2d89df3d-ca51-4d35-9528-439923fa48d4..",
                "dispatcher": "AD",
                "_links": {
                    "self": {
                        "href": "http://localhost:7070/booking-documents-service/dispatchDetails/1"
                    },
                    "dispatchDetail": {
                        "href": "http://localhost:7070/booking-documents-service/dispatchDetails/1"
                    },
                    "generatedDocument": {
                        "href": "http://localhost:7070/booking-documents-service/dispatchDetails/1/generatedDocument"
                    }
                }
            }
        ]
    },
    "_links": {
        "self": {
            "href": "http://localhost:7070/booking-documents-service/docs/5999571/dispatchDetails"
        }
    }
}

但是我不希望将调度详细信息作为独立资源(在上面的链接中列出)。 也就是说,我不要这个端点

http://localhost:7070/booking-documents-service/dispatchDetails

我只需要这个。

http://localhost:7070/booking-documents-service/docs/5999571/dispatchDetails

如何实现?即仅允许子资源级别的操作。

0 个答案:

没有答案