我需要使用 requestbody 多次执行一个过程。现在,我正在使用 for 循环来做到这一点,但这不是一个好方法。例如,当一个请求失败时,捕获该请求是一个问题。请参阅示例用法。
用for循环实现存储过程;
**Controller**
public void runSP(
@RequestBody List<IdNoteModel> idNotes
){
getService().runSP(idNotes);
}
**Service**
public void runSP(List<IdNoteModel> idNotes){
for (IdNoteModel idNote : idNotes){
getRepository().runSP(idNote);
}
}
**Repository**
@Query(nativeQuery = true, value = "EXECUTE PROCEDURE SP_RUN_ID_NOTE(:id, :note)")
void runSP(Long id, String note);
有没有更好的方法来多次运行存储过程?或者你有什么想法来捕捉失败的请求?