From f0345add31e45a5d1eac67deed657f9b8edf6d7f Mon Sep 17 00:00:00 2001 From: Dierk Koenig Date: Wed, 23 Oct 2024 10:11:49 +0200 Subject: [PATCH] week 6 domain classes --- .../rooms/BookingController.groovy | 7 +++++++ .../controllers/rooms/PersonController.groovy | 7 +++++++ .../controllers/rooms/RoomController.groovy | 9 +++++++++ grails-app/domain/rooms/Booking.groovy | 19 +++++++++++++++++++ grails-app/domain/rooms/Person.groovy | 10 ++++++++++ grails-app/domain/rooms/Room.groovy | 15 +++++++++++++++ grails-app/init/rooms/BootStrap.groovy | 8 ++++++++ 7 files changed, 75 insertions(+) create mode 100644 grails-app/controllers/rooms/BookingController.groovy create mode 100644 grails-app/controllers/rooms/PersonController.groovy create mode 100644 grails-app/controllers/rooms/RoomController.groovy create mode 100644 grails-app/domain/rooms/Booking.groovy create mode 100644 grails-app/domain/rooms/Person.groovy create mode 100644 grails-app/domain/rooms/Room.groovy diff --git a/grails-app/controllers/rooms/BookingController.groovy b/grails-app/controllers/rooms/BookingController.groovy new file mode 100644 index 0000000..aaed7f0 --- /dev/null +++ b/grails-app/controllers/rooms/BookingController.groovy @@ -0,0 +1,7 @@ +package rooms + +class BookingController { + + static scaffold = Booking + +} diff --git a/grails-app/controllers/rooms/PersonController.groovy b/grails-app/controllers/rooms/PersonController.groovy new file mode 100644 index 0000000..7677599 --- /dev/null +++ b/grails-app/controllers/rooms/PersonController.groovy @@ -0,0 +1,7 @@ +package rooms + +class PersonController { + + static scaffold = Person + +} diff --git a/grails-app/controllers/rooms/RoomController.groovy b/grails-app/controllers/rooms/RoomController.groovy new file mode 100644 index 0000000..a344784 --- /dev/null +++ b/grails-app/controllers/rooms/RoomController.groovy @@ -0,0 +1,9 @@ +package rooms + +class RoomController { + + static scaffold = Room + + + +} diff --git a/grails-app/domain/rooms/Booking.groovy b/grails-app/domain/rooms/Booking.groovy new file mode 100644 index 0000000..4e61a66 --- /dev/null +++ b/grails-app/domain/rooms/Booking.groovy @@ -0,0 +1,19 @@ +package rooms + +class Booking { + Person person + Room room + Date date + String timeSlot + + static final AM = "08:15-11:00" + static final PM1 = "12:15-15:00" + static final PM2 = "15:15-18:00" + + static constraints = { + person nullable:false + room nullable:false + date nullable:false + timeSlot inList: [AM, PM1, PM2] + } +} diff --git a/grails-app/domain/rooms/Person.groovy b/grails-app/domain/rooms/Person.groovy new file mode 100644 index 0000000..d6a5cab --- /dev/null +++ b/grails-app/domain/rooms/Person.groovy @@ -0,0 +1,10 @@ +package rooms + +class Person { + String firstName + String lastName + + public String toString() { + return firstName + " " + lastName; + } +} diff --git a/grails-app/domain/rooms/Room.groovy b/grails-app/domain/rooms/Room.groovy new file mode 100644 index 0000000..c8d4cc3 --- /dev/null +++ b/grails-app/domain/rooms/Room.groovy @@ -0,0 +1,15 @@ +package rooms + +class Room { + String name + Integer capacity + + public String toString() { + return name + " (" + capacity + ")"; + } + + static constraints = { + name nullable:false, blank:false + capacity min:0, nullable:true + } +} diff --git a/grails-app/init/rooms/BootStrap.groovy b/grails-app/init/rooms/BootStrap.groovy index 863e8cc..5149ed1 100644 --- a/grails-app/init/rooms/BootStrap.groovy +++ b/grails-app/init/rooms/BootStrap.groovy @@ -19,6 +19,14 @@ class BootStrap { return } + Person dierk = save(new Person(firstName: "Dierk", lastName: "König")) + Person dieter = save(new Person(firstName: "Dieter", lastName: "Holz")) + + Room r51c56 = save(new Room(name: "5.1C56", capacity: 30)) + Room r52b53 = save(new Room(name: "5.2B53", capacity: 35)) + + save(new Booking(person: dierk, room:r51c56, date: today, timeSlot: Booking.AM )) + }