when I am doing this get mapping I also want to post this data in another entity called bookings.java so that I can see the booked buses there. I am learning right now if my question is wrong please correct me.
this is the DashboardController.java
@RestController
@RequestMapping("/dashboard")
public class DashboardController {
@Autowired
private BusDataRepository busDataRepo;
@GetMapping("/buses")
public List<BusData> showall() {
return busDataRepo.findAll();
}
@GetMapping("/book/{id}")
public Optional<BusData> show(@PathVariable int id) {
return busDataRepo.findById(id);
}
}
this is BusData.java entity where i have put data through MySql
@Entity
@Data
public class BusData {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private String filterDate;
private String toDestination;
private String fromDestination;
private Double price;
private String BusName;
private String time;
}
this is Bookings.java entity where i want the data which i booked
@Entity
@Data
public class Bookings {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private String filterDate;
private String toDestination;
private String fromDestination;
private String BusName;
private String time;
}