From 21b2887d94d3721482d8819ea74c22bff970e1f9 Mon Sep 17 00:00:00 2001 From: Jottyfan Date: Sat, 8 Oct 2022 18:17:54 +0200 Subject: [PATCH] basic booking information for registered people --- build.gradle | 2 +- .../module/common/BookingBean.java | 352 ++++++++++++++++++ .../module/common/CommonController.java | 2 +- .../module/common/IndexController.java | 1 + .../module/common/IndexGateway.java | 73 ++++ .../module/common/IndexService.java | 5 + src/main/resources/static/css/style.css | 5 + src/main/resources/templates/dashboard.html | 63 +++- 8 files changed, 497 insertions(+), 6 deletions(-) create mode 100644 src/main/java/de/jottyfan/camporganizer/module/common/BookingBean.java diff --git a/build.gradle b/build.gradle index bf83808..bdb4b1c 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ apply plugin: 'war' apply plugin: 'application' group = 'de.jottyfan.camporganizer' -version = '0.0.0' +version = '0.0.1' sourceCompatibility = 17 mainClassName = "de.jottyfan.camporganizer.Main" diff --git a/src/main/java/de/jottyfan/camporganizer/module/common/BookingBean.java b/src/main/java/de/jottyfan/camporganizer/module/common/BookingBean.java new file mode 100644 index 0000000..f679ba1 --- /dev/null +++ b/src/main/java/de/jottyfan/camporganizer/module/common/BookingBean.java @@ -0,0 +1,352 @@ +package de.jottyfan.camporganizer.module.common; + +import java.io.Serializable; +import java.time.LocalDate; +import java.time.LocalDateTime; + +import de.jottyfan.camporganizer.db.jooq.enums.EnumCamprole; +import de.jottyfan.camporganizer.db.jooq.enums.EnumSex; + +/** + * + * @author jotty + * + */ +public class BookingBean implements Serializable { + private static final long serialVersionUID = 1L; + + private Integer pk; + private String forename; + private String surname; + private String street; + private String zip; + private String city; + private String phone; + private LocalDate birthdate; + private EnumCamprole camprole; + private String comment; + private Boolean consentCatalogPhoto; + private LocalDateTime created; + private String email; + private EnumSex sex; + private String locationName; + private String price; + private Double year; + private LocalDateTime arrive; + private LocalDateTime depart; + private String countries; + private String url; + private Boolean isOver; + private String campName; + + /** + * @return the forename + */ + public String getForename() { + return forename; + } + + /** + * @param forename the forename to set + */ + public void setForename(String forename) { + this.forename = forename; + } + + /** + * @return the surname + */ + public String getSurname() { + return surname; + } + + /** + * @param surname the surname to set + */ + public void setSurname(String surname) { + this.surname = surname; + } + + /** + * @return the street + */ + public String getStreet() { + return street; + } + + /** + * @param street the street to set + */ + public void setStreet(String street) { + this.street = street; + } + + /** + * @return the zip + */ + public String getZip() { + return zip; + } + + /** + * @param zip the zip to set + */ + public void setZip(String zip) { + this.zip = zip; + } + + /** + * @return the city + */ + public String getCity() { + return city; + } + + /** + * @param city the city to set + */ + public void setCity(String city) { + this.city = city; + } + + /** + * @return the phone + */ + public String getPhone() { + return phone; + } + + /** + * @param phone the phone to set + */ + public void setPhone(String phone) { + this.phone = phone; + } + + /** + * @return the birthdate + */ + public LocalDate getBirthdate() { + return birthdate; + } + + /** + * @param birthdate the birthdate to set + */ + public void setBirthdate(LocalDate birthdate) { + this.birthdate = birthdate; + } + + /** + * @return the camprole + */ + public EnumCamprole getCamprole() { + return camprole; + } + + /** + * @param camprole the camprole to set + */ + public void setCamprole(EnumCamprole camprole) { + this.camprole = camprole; + } + + /** + * @return the comment + */ + public String getComment() { + return comment; + } + + /** + * @param comment the comment to set + */ + public void setComment(String comment) { + this.comment = comment; + } + + /** + * @return the consentCatalogPhoto + */ + public Boolean getConsentCatalogPhoto() { + return consentCatalogPhoto; + } + + /** + * @param consentCatalogPhoto the consentCatalogPhoto to set + */ + public void setConsentCatalogPhoto(Boolean consentCatalogPhoto) { + this.consentCatalogPhoto = consentCatalogPhoto; + } + + /** + * @return the created + */ + public LocalDateTime getCreated() { + return created; + } + + /** + * @param created the created to set + */ + public void setCreated(LocalDateTime created) { + this.created = created; + } + + /** + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * @param email the email to set + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * @return the sex + */ + public EnumSex getSex() { + return sex; + } + + /** + * @param sex the sex to set + */ + public void setSex(EnumSex sex) { + this.sex = sex; + } + + /** + * @return the locationName + */ + public String getLocationName() { + return locationName; + } + + /** + * @param locationName the location_name to set + */ + public void setLocationName(String locationName) { + this.locationName = locationName; + } + + /** + * @return the price + */ + public String getPrice() { + return price; + } + + /** + * @param price the price to set + */ + public void setPrice(String price) { + this.price = price; + } + + /** + * @return the year + */ + public Double getYear() { + return year; + } + + /** + * @param year the year to set + */ + public void setYear(Double year) { + this.year = year; + } + + /** + * @return the arrive + */ + public LocalDateTime getArrive() { + return arrive; + } + + /** + * @param arrive the arrive to set + */ + public void setArrive(LocalDateTime arrive) { + this.arrive = arrive; + } + + /** + * @return the depart + */ + public LocalDateTime getDepart() { + return depart; + } + + /** + * @param depart the depart to set + */ + public void setDepart(LocalDateTime depart) { + this.depart = depart; + } + + /** + * @return the countries + */ + public String getCountries() { + return countries; + } + + /** + * @param countries the countries to set + */ + public void setCountries(String countries) { + this.countries = countries; + } + + /** + * @return the url + */ + public String getUrl() { + return url; + } + + /** + * @param url the url to set + */ + public void setUrl(String url) { + this.url = url; + } + + /** + * @return the is_over + */ + public Boolean getIsOver() { + return isOver; + } + + /** + * @param isOver the isOver to set + */ + public void setIsOver(Boolean isOver) { + this.isOver = isOver; + } + + public Integer getPk() { + return pk; + } + + public void setPk(Integer pk) { + this.pk = pk; + } + + public String getCampName() { + return campName; + } + + public void setCampName(String campName) { + this.campName = campName; + } + +} diff --git a/src/main/java/de/jottyfan/camporganizer/module/common/CommonController.java b/src/main/java/de/jottyfan/camporganizer/module/common/CommonController.java index e55edf7..491e3af 100644 --- a/src/main/java/de/jottyfan/camporganizer/module/common/CommonController.java +++ b/src/main/java/de/jottyfan/camporganizer/module/common/CommonController.java @@ -18,7 +18,7 @@ public abstract class CommonController { * @param request the request * @return the preferred username or null */ - private String getCurrentUser(HttpServletRequest request) { + public String getCurrentUser(HttpServletRequest request) { KeycloakSecurityContext ksc = (KeycloakSecurityContext) request .getAttribute(KeycloakSecurityContext.class.getName()); return ksc == null ? null : ksc.getIdToken().getPreferredUsername(); diff --git a/src/main/java/de/jottyfan/camporganizer/module/common/IndexController.java b/src/main/java/de/jottyfan/camporganizer/module/common/IndexController.java index 0e0aae2..f652b2b 100644 --- a/src/main/java/de/jottyfan/camporganizer/module/common/IndexController.java +++ b/src/main/java/de/jottyfan/camporganizer/module/common/IndexController.java @@ -35,6 +35,7 @@ public class IndexController extends CommonController { @GetMapping("/dashboard") public String dashboard(Model model) { super.setupSession(model, request); + model.addAttribute("mybookings", service.getBookingsOf(super.getCurrentUser(request))); return "/dashboard"; } diff --git a/src/main/java/de/jottyfan/camporganizer/module/common/IndexGateway.java b/src/main/java/de/jottyfan/camporganizer/module/common/IndexGateway.java index 5fba51b..33209b2 100644 --- a/src/main/java/de/jottyfan/camporganizer/module/common/IndexGateway.java +++ b/src/main/java/de/jottyfan/camporganizer/module/common/IndexGateway.java @@ -1,18 +1,28 @@ package de.jottyfan.camporganizer.module.common; +import static de.jottyfan.camporganizer.db.jooq.Tables.T_PERSON; +import static de.jottyfan.camporganizer.db.jooq.Tables.T_PROFILE; import static de.jottyfan.camporganizer.db.jooq.Tables.V_CAMP; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; import java.util.stream.Stream; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jooq.Condition; import org.jooq.DSLContext; +import org.jooq.Record; +import org.jooq.Record22; import org.jooq.SelectConditionStep; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; +import de.jottyfan.camporganizer.db.jooq.enums.EnumCamprole; +import de.jottyfan.camporganizer.db.jooq.enums.EnumSex; import de.jottyfan.camporganizer.db.jooq.tables.records.VCampRecord; /** @@ -33,4 +43,67 @@ public class IndexGateway { LOGGER.debug(sql.toString()); return sql.fetchStream(); } + + public List getAllBookings(String username) { + SelectConditionStep sql = jooq + // @formatter:off + .select(T_PERSON.PK, + T_PERSON.FORENAME, + T_PERSON.SURNAME, + T_PERSON.STREET, + T_PERSON.ZIP, + T_PERSON.CITY, + T_PERSON.PHONE, + T_PERSON.BIRTHDATE, + T_PERSON.CAMPROLE, + T_PERSON.COMMENT, + T_PERSON.CONSENT_CATALOG_PHOTO, + T_PERSON.CREATED, + T_PERSON.EMAIL, + T_PERSON.SEX, + V_CAMP.NAME, + V_CAMP.LOCATION_NAME, + V_CAMP.PRICE, + V_CAMP.YEAR, + V_CAMP.ARRIVE, + V_CAMP.DEPART, + V_CAMP.COUNTRIES, + V_CAMP.URL, + V_CAMP.IS_OVER) + .from(T_PROFILE) + .leftJoin(T_PERSON).on(T_PERSON.FK_PROFILE.eq(T_PROFILE.PK)) + .leftJoin(V_CAMP).on(V_CAMP.PK.eq(T_PERSON.FK_CAMP)) + .where(T_PROFILE.USERNAME.eq(username)); + // @formatter:on + LOGGER.debug(sql.toString()); + List list = new ArrayList<>(); + for (Record r : sql.fetch()) { + BookingBean bean = new BookingBean(); + bean.setPk(r.get(T_PERSON.PK)); + bean.setForename(r.get(T_PERSON.FORENAME)); + bean.setSurname(r.get(T_PERSON.SURNAME)); + bean.setStreet(r.get(T_PERSON.STREET)); + bean.setZip(r.get(T_PERSON.ZIP)); + bean.setCity(r.get(T_PERSON.CITY)); + bean.setPhone(r.get(T_PERSON.PHONE)); + bean.setBirthdate(r.get(T_PERSON.BIRTHDATE)); + bean.setCamprole(r.get(T_PERSON.CAMPROLE)); + bean.setComment(r.get(T_PERSON.COMMENT)); + bean.setConsentCatalogPhoto(r.get(T_PERSON.CONSENT_CATALOG_PHOTO)); + bean.setCreated(r.get(T_PERSON.CREATED)); + bean.setEmail(r.get(T_PERSON.EMAIL)); + bean.setSex(r.get(T_PERSON.SEX)); + bean.setLocationName(r.get(V_CAMP.LOCATION_NAME)); + bean.setPrice(r.get(V_CAMP.PRICE)); + bean.setYear(r.get(V_CAMP.YEAR)); + bean.setArrive(r.get(V_CAMP.ARRIVE)); + bean.setDepart(r.get(V_CAMP.DEPART)); + bean.setCountries(r.get(V_CAMP.COUNTRIES)); + bean.setUrl(r.get(V_CAMP.URL)); + bean.setIsOver(r.get(V_CAMP.IS_OVER)); + bean.setCampName(r.get(V_CAMP.NAME)); + list.add(bean); + } + return list; + } } diff --git a/src/main/java/de/jottyfan/camporganizer/module/common/IndexService.java b/src/main/java/de/jottyfan/camporganizer/module/common/IndexService.java index 6854a61..1442d28 100644 --- a/src/main/java/de/jottyfan/camporganizer/module/common/IndexService.java +++ b/src/main/java/de/jottyfan/camporganizer/module/common/IndexService.java @@ -1,5 +1,6 @@ package de.jottyfan.camporganizer.module.common; +import static de.jottyfan.camporganizer.db.jooq.Tables.T_PROFILE; import static de.jottyfan.camporganizer.db.jooq.Tables.V_CAMP; import java.time.LocalDateTime; @@ -35,4 +36,8 @@ public class IndexService { stream.forEach(o -> list.add(o)); return list; } + + public List getBookingsOf(String username) { + return gateway.getAllBookings(username); + } } diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/style.css index 655baeb..d1e9ca3 100644 --- a/src/main/resources/static/css/style.css +++ b/src/main/resources/static/css/style.css @@ -130,6 +130,11 @@ body { cursor: not-allowed; } +.usercard { + width: 480px; + background-color: rgba(255, 255, 255, 0.8) !important; +} + .mytoggle_collapsed { display: none; } diff --git a/src/main/resources/templates/dashboard.html b/src/main/resources/templates/dashboard.html index d349d26..f18319e 100644 --- a/src/main/resources/templates/dashboard.html +++ b/src/main/resources/templates/dashboard.html @@ -7,13 +7,68 @@
- - - - +
+
+
+  in  +
+
+
Zeit:
+
+ +
+
Preis:
+
+
Ferien:
+
+
+
+
+
+
+
+
Rolle:
+ +
ID:
+ +
Vorname:
+ +
Nachname:
+ +
Straße:
+ +
PLZ:
+ +
Ort:
+ +
Telefon:
+ +
Geburtstag:
+ +
E-Mail:
+ +
Geschlecht:
+ +
Foto-Einverständnis:
+ +
Kommentar:
+ +
+
+
+ +