예매조회 생성과 조회 기능 구현 중, Response Entity를 똑같이 설정했는데도, ResponseBody에 다르게 뜨는 이슈 발생.
Post Method(예매 생성)
{
"reservationId": 1,
"userId": 1,
"showId": 2,
"price": 150000,
"seat_info": "VIP"
}
Get Method(예매 조회)
{
"reservationId": 1,
"userId": 1,
"showId": 2,
"price": null,
"seat_info": null
}
@ManyToOne(fetchType=LAZY)
@JoinColumn(name = "user_id")
User user;
연관객체 코드 구현을 하는 것이 아니라
private Long userId;
private Long showId;
private Long seatId;
단순하게, Long으로 id로 value 값을 지정.
seatRepository에서 seatId로 price와 seat_info 값을 따로 찾아 저장하니, 해결.
그리고 reservationId도 기존처럼
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
``````
로 구현하는 것이 아니라
Service.class 에서
Long id = redisTemplate.opsForValue().increment("reservation:id");
로 바꿔야 1,2,3...순으로 저장된다.