dao層 和controller

佬zz發表於2024-07-29
void insertReservation(Reservation reservation);
void deleteReservation(int reservationId);
Reservation selectReservation(int reservationId);
List<Reservation> selectAllReservations();
void updateReservation(Reservation reservation);
List<Reservation> selectReservationsByTimeRange(Date startTime, Date endTime);

List<Reservation> selectReservationByRoomID(int roomId);





@Resource
private MonsterMapper monsterMapper;


@ResponseBody
@GetMapping("/monster")
public List<Reservation> getMonsterById(){
System.out.println("11111111111111111111111111111");
System.out.println(monsterService.getAll());
return monsterService.getAll();
}


@DeleteMapping("/deleteBook/{id}")
@ResponseBody
public String DeleteById(@PathVariable("id") int id){
monsterMapper.deleteReservation(id);
return "Deleted successfully";
}
@GetMapping("/rooms")
@ResponseBody
public List<Room> getRooms() {
Room[] rooms = new Room[]{
// 模擬資料1
new Room() {{
setRoom_id(1);
setRoom_name("會議室A");
setLocation("1號樓1層");
setCapacity(10);
}},
// 模擬資料2
new Room() {{
setRoom_id(2);
setRoom_name("會議室B");
setLocation("1號樓2層");
setCapacity(20);
}},
// 模擬資料3
new Room() {{
setRoom_id(3);
setRoom_name("會議室C");
setLocation("2號樓1層");
setCapacity(15);
}}
// 可以繼續新增更多的 Room 物件來模擬更多的資料記錄
};
return Arrays.asList(rooms);
}


@GetMapping("/BookId/{id}")
@ResponseBody
public List<Reservation> selectById(@PathVariable("id") int roomid){
List<Reservation> reservations = monsterMapper.selectReservationByRoomID(roomid);
return reservations;
}
@PostMapping("/addReservation")
@ResponseBody
public String add(@RequestBody ReservationDto reservation){
System.out.println(reservation.getStart());
System.out.println(reservation.getEnd());
System.out.println(reservation.getRoomId());
System.out.println(reservation.getTitle());
return "新增成功";
}

相關文章