From 421fb0c7cc0129ecde0de20b8db4a3e975d07d2b Mon Sep 17 00:00:00 2001 From: Dierk Koenig Date: Fri, 1 Nov 2019 13:46:39 +0100 Subject: [PATCH] after week 7, first part --- grails-app/conf/application.yml | 1 + grails-app/controllers/webec/BookingController.groovy | 7 +++++++ grails-app/domain/webec/Booking.groovy | 2 ++ grails-app/init/webec/BootStrap.groovy | 3 ++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/grails-app/conf/application.yml b/grails-app/conf/application.yml index 1a6271c..02a13fc 100644 --- a/grails-app/conf/application.yml +++ b/grails-app/conf/application.yml @@ -107,6 +107,7 @@ dataSource: environments: development: dataSource: +# logSql: true dbCreate: create-drop url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE test: diff --git a/grails-app/controllers/webec/BookingController.groovy b/grails-app/controllers/webec/BookingController.groovy index 0dbb1a2..f076270 100644 --- a/grails-app/controllers/webec/BookingController.groovy +++ b/grails-app/controllers/webec/BookingController.groovy @@ -2,5 +2,12 @@ package webec class BookingController { + def probiere() { + // find the last names of all people that booked + // room named "1.313" + def booker = Person.findByLastName('Holz') + def result = Booking.findAllByBooker(booker)*.room + render text: result.toString() + } static scaffold = Booking } diff --git a/grails-app/domain/webec/Booking.groovy b/grails-app/domain/webec/Booking.groovy index 661e0e0..c25e348 100644 --- a/grails-app/domain/webec/Booking.groovy +++ b/grails-app/domain/webec/Booking.groovy @@ -12,6 +12,8 @@ class Booking { static String PM2 = "15:15 18:00" static List SLOTS = [AM, PM1, PM2] + String toString() { "$booker.lastName booked room $room.name at $day, slot $slot"} + static constraints = { slot inList: Booking.SLOTS } diff --git a/grails-app/init/webec/BootStrap.groovy b/grails-app/init/webec/BootStrap.groovy index 851705c..c8d612a 100644 --- a/grails-app/init/webec/BootStrap.groovy +++ b/grails-app/init/webec/BootStrap.groovy @@ -1,5 +1,6 @@ package webec +import grails.web.servlet.context.support.GrailsEnvironment import org.codehaus.groovy.runtime.DateGroovyMethods class BootStrap { @@ -19,7 +20,7 @@ class BootStrap { new Booking(booker: dierk, room: oben, day: today + i, slot: Booking.AM).save(failOnError:true) } - new Booking(booker: dierk, room: oben, day: today, slot: Booking.AM).save(failOnError:true) + new Booking(booker: dieter, room: oben, day: today, slot: Booking.AM).save(failOnError:true) }