我是Springboot的新手,我开发了通过ID删除记录的资源,现在我喜欢删除选定的多条记录。示例:我喜欢在单个请求中删除 10 条记录中的 3 条记录
控制器类:
@ApiHeader(
apiOperation = "delete a Content Manage by id",
apiOperationNotes = "delete a Content Manage by id"
)
@PostMapping(value = UriConstants.CONTENT_MANAGE_DELETE)
@ResponseStatus(HttpStatus.OK)
public void deleteContentManage(@PathVariable("content_manage_id") int contentmanageId) {
contentManageService.deleteContentManage(contentmanageId);
}
Run Code Online (Sandbox Code Playgroud)
服务等级:
@Transactional(rollbackFor = Exception.class)
public void deleteContentManage(int contentmanageId) {
Optional<UserContentManage> optional = userContentManageRepository.findById(contentmanageId);
if(!optional.isPresent()){
log.error("Exception occurs while not found content manage ({}) in deletion. ", contentmanageId);
throw new GenericBadException(StaffNotificationExceptionEnum.CONTENT_MANAGE_NOT_FOUND_EXCEPTION);
}
userContentManageRepository.deleteById(contentmanageId);
}
Run Code Online (Sandbox Code Playgroud)
JPA类:
public interface UserContentManageRepository extends JpaRepository<UserContentManage, Integer> {
}
Run Code Online (Sandbox Code Playgroud)
请建议我如何删除选定的多条记录。