简体   繁体   English

如何发送 ArrayList 或套装<integer>作为请求正文中的列表过滤或 PUT 请求中的 URL</integer>

[英]How to send ArrayList or Sets<Integer> as list filtering in Request Body or URL in PUT Request

I'm trying to write a controller that will function as multiple seat reservation.The Integers list is used for filtering.我正在尝试编写一个 controller ,它将 function 作为多个座位预订。整数列表用于过滤。 My Entity looks like this:我的实体看起来像这样:

@Entity
@Id
private movieId;
private String movieName;
private String cinemaName;
private String cinemaHall;
private Intger seatingPlace;
private boolean booked;

How Can I pass list or sets in request body to access multiple update seatingPlace.如何通过请求正文中的列表或集合来访问多个更新座位。 Did I modyfing Enity or connect in smthing relation?我是否修改了 Enity 或以某种关系连接?

Acutally my multipleUpdate API works using JPA Query findByMovieNameAndCinemaNameAndcinemaHall and return me list wchich I checking isnt Empty and cheking (field boolean booked) if true so ok u can booked them. Acutally my multipleUpdate API works using JPA Query findByMovieNameAndCinemaNameAndcinemaHall and return me list wchich I checking isnt Empty and cheking (field boolean booked) if true so ok u can booked them. And after that i want filter by passing List seatingPlace and change boolen to false.之后,我想通过传递 List seatPlace 进行过滤并将布尔值更改为 false。

Based on my understanding of your requirements, a possible solution could be creating another entity (table) MovieSeatReservation and creating a One to Many relationship from your Entity.根据我对您的要求的理解,一个可能的解决方案可能是创建另一个实体(表)MovieSeatReservation 并从您的实体创建一对多关系。 It could look like this: (You can replace Entity class name with your real entity name)它可能看起来像这样:(您可以将实体 class 名称替换为您的真实实体名称)

@Entity
public class Entity {
    
    @Id
    @GeneratedValue
    private Long movieId;
    private String movieName;
    private String cinemaName;
    private String cinemaHall;
    @OneToMany
    private List<MovieSeatReservation> reservedSeatsStatus;

    // getters and setters
}

@Entity
public class MovieSeatReservation {

    @Id
    @GeneratedValue
    private Long id;
 
    private boolean isReserved;
 
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "movie_id")
    private Entity entity;

    // getters and setters

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何发送ArrayList <Integer> 作为HTTPPOST请求中的UrlEncodedFormEntity? - How to send ArrayList<Integer> as UrlEncodedFormEntity in HTTPPOST request? 如何在restAssured的请求正文中发送带有列表的JSON post请求 - How to send a JSON post request with a list in request body in restAssured Java如何更新JSON对象值并将其作为正文发送到PUT请求 - Java how to update a JSON object value and send it as a body to PUT request 如何将请求正文中的列表值发送到 Rest Api - How to send List value in Request Body to Rest Api 如何在网址上添加空格以供请求 - How to put whitespaces at url for request 如何将JSON数组放入请求主体以进行改造? - How to put JSON array in request body for Retrofit? 如何通过 url 和 Z65E8800B5C6800AAD8800B5C6800AAD8800B5C6800AAD896F888B2A62AFCZ 的主体发送请求主体的 json 参数之一为@FCBmapping80AFD3511Z5 - How to send one of the json parameter of a request body through url and rest through body of postman for @Postmapping 使用JoddHttp put请求发送带有.body()的JSON会损坏中文文本 - Using JoddHttp put request to send JSON with the .body() corrupts Chinese text 如何使用 Java Http 客户端发送具有多部分/表单数据主体的 PUT 请求? - How to send a PUT request with multipart/form-data body with Java Http Client? 如何将URL请求作为“引荐来源”发送 - How to send a URL request as 'Referer'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM