如何在一次交易中正确删除,更新和创建REST API

时间:2019-08-04 17:50:05

标签: java rest api spring-boot

我拥有“运作”的精髓。有一个适当的端点可以删除,更新和创建:

[   
    "create": [
        {
            "name": "Operation New 1"
        },
        {
            "name": "Operation New 2"
        }
    ],
    "update": [
        {
            "id": 1
            "name": "Change operation name 1"
        }
    ],
    "delete": [
        {
            "id": 2
        }
    ]
]

但是有一个非常复杂的场景。当用户可以在界面中的多个操作中进行更改,编辑或创建新操作时,这些更改不会一直发送到服务器,而是保存在浏览器端。然后,用户可以单击“保存”按钮,所有这些更改都应发送到服务器。

最困难,最不可理解的是,所有这些必须在一次交易中完成。因为如果至少一项操作没有成功,那么一切都应该回滚。

而且我还没有合适的解决方案来满足REST API的规则。

我将举例说明如何看待该问题。传递json如下:

POST /api/operation/aggregate/create-update-delete

相应地,这三组中的数据将相应地执行:创建,更新和删除

此外,此请求使用POST方法发送到某个公共端点,例如:

 <wls:container-descriptor>
                    <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
                </wls:container-descriptor>
            The following works locally but not on other systems.
            <wls:container-descriptor>
             <wls:prefer-application-packages>
                        <wls:package-name>org.slf4j.*</wls:package-name>
                        <wls:package-name>org.springframework.*</wls:package-name>
                        <wls:package-name>org.hibernate.*</wls:package-name>
                        <wls:package-name>javax.validation.*</wls:package-name>
                        <wls:package-name>javax.validation.spi.*</wls:package-name>
                    </wls:prefer-application-packages>
                </wls:container-descriptor>
            Error:
            An attempt was made to call a method that does not exist. The attempt was made from the following location:

                org.hibernate.validator.internal.xml.config.ValidationBootstrapParameters.<init>(ValidationBootstrapParameters.java:63)

            The following method did not exist:

                javax.validation.BootstrapConfiguration.getClockProviderClassName()Ljava/lang/String;

            The method's class, javax.validation.BootstrapConfiguration, is available from the following locations:

                zip:C:/wls12213/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/demo-0.0.1-SNAPSHOT/vluesa/war/WEB-INF/lib/validation-api-2.0.1.Final.jar!/javax/validation/BootstrapConfiguration.class
                jar:file:/C:/wls12213/oracle_common/modules/javax.validation.jar!/javax/validation/BootstrapConfiguration.class

            It was loaded from the following location:

                file:/C:/wls12213/oracle_common/modules/javax.validation.jar

            The war file which is currently generated through pom.xml should work on all weblogic server at least with the same version.

请告诉我您将如何实施此方案?也许有人遇到过此类问题?

尽管就此而言,使用哪种技术都没有关系,但是我使用Spring Boot,因此,如果有针对该技术的现成解决方案,我将很乐意为您提供帮助。

0 个答案:

没有答案