Skip to content

Commit

Permalink
week 6 domain classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dierk Koenig committed Oct 23, 2024
1 parent a514743 commit f0345ad
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 0 deletions.
7 changes: 7 additions & 0 deletions grails-app/controllers/rooms/BookingController.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package rooms

class BookingController {

static scaffold = Booking

}
7 changes: 7 additions & 0 deletions grails-app/controllers/rooms/PersonController.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package rooms

class PersonController {

static scaffold = Person

}
9 changes: 9 additions & 0 deletions grails-app/controllers/rooms/RoomController.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package rooms

class RoomController {

static scaffold = Room



}
19 changes: 19 additions & 0 deletions grails-app/domain/rooms/Booking.groovy
Original file line number Diff line number Diff line change
@@ -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]
}
}
10 changes: 10 additions & 0 deletions grails-app/domain/rooms/Person.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package rooms

class Person {
String firstName
String lastName

public String toString() {
return firstName + " " + lastName;
}
}
15 changes: 15 additions & 0 deletions grails-app/domain/rooms/Room.groovy
Original file line number Diff line number Diff line change
@@ -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
}
}
8 changes: 8 additions & 0 deletions grails-app/init/rooms/BootStrap.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 ))


}

Expand Down

0 comments on commit f0345ad

Please sign in to comment.