From b3a186f5caaa42253e7621d7c4fb1b69f3d3e841 Mon Sep 17 00:00:00 2001 From: jotty Date: Fri, 10 Mar 2023 23:37:44 +0100 Subject: [PATCH] preparations for adding camp locations --- .settings/org.eclipse.buildship.core.prefs | 11 +++ .settings/org.eclipse.wst.common.component | 20 +++-- build.gradle | 2 +- .../module/admin/AdminController.java | 7 ++ .../module/admin/AdminRepository.java | 16 ++++ .../module/admin/AdminService.java | 9 ++ .../module/admin/LocationBean.java | 84 +++++++++++++++++++ .../resources/templates/admin/location.html | 48 +++++++++++ src/main/resources/templates/admin/main.html | 3 + 9 files changed, 192 insertions(+), 8 deletions(-) create mode 100644 src/main/java/de/jottyfan/camporganizer/module/admin/LocationBean.java create mode 100644 src/main/resources/templates/admin/location.html diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs index e889521..e479558 100644 --- a/.settings/org.eclipse.buildship.core.prefs +++ b/.settings/org.eclipse.buildship.core.prefs @@ -1,2 +1,13 @@ +arguments= +auto.sync=false +build.scans.enabled=false +connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) connection.project.dir= eclipse.preferences.version=1 +gradle.user.home= +java.home= +jvm.arguments= +offline.mode=false +override.workspace.settings=false +show.console.view=false +show.executions.view=false diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 59fc2ab..31a62d0 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,8 +1,14 @@ - - - - - - - + + + + + + + + + + + + + diff --git a/build.gradle b/build.gradle index 28c56cb..0cc91da 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ apply plugin: 'war' apply plugin: 'application' group = 'de.jottyfan.camporganizer' -version = '0.3.0' +version = '0.3.1' sourceCompatibility = 17 mainClassName = "de.jottyfan.camporganizer.Main" diff --git a/src/main/java/de/jottyfan/camporganizer/module/admin/AdminController.java b/src/main/java/de/jottyfan/camporganizer/module/admin/AdminController.java index 245f205..ac09a20 100644 --- a/src/main/java/de/jottyfan/camporganizer/module/admin/AdminController.java +++ b/src/main/java/de/jottyfan/camporganizer/module/admin/AdminController.java @@ -109,4 +109,11 @@ public class AdminController extends CommonController { service.deleteDocument(id); return "redirect:/admin/document"; } + + @GetMapping("/admin/location") + public String getLocations(Model model, HttpServletRequest request) { + super.setupSession(model, request); + model.addAttribute("locations", service.getLocations()); + return "/admin/location"; + } } diff --git a/src/main/java/de/jottyfan/camporganizer/module/admin/AdminRepository.java b/src/main/java/de/jottyfan/camporganizer/module/admin/AdminRepository.java index 066c413..7b8302d 100644 --- a/src/main/java/de/jottyfan/camporganizer/module/admin/AdminRepository.java +++ b/src/main/java/de/jottyfan/camporganizer/module/admin/AdminRepository.java @@ -20,6 +20,7 @@ import org.jooq.InsertResultStep; import org.jooq.InsertReturningStep; import org.jooq.Record5; import org.jooq.SelectSeekStep1; +import org.jooq.SelectWhereStep; import org.jooq.UpdateConditionStep; import org.jooq.UpdateSetMoreStep; import org.jooq.exception.DataAccessException; @@ -242,4 +243,19 @@ public class AdminRepository { return lrw.getCounter(); } + /** + * get all locations from the database + * + * @return the locations + */ + public List getLocations() { + SelectWhereStep sql = jooq.selectFrom(T_LOCATION); + LOGGER.debug(sql.toString()); + List list = new ArrayList<>(); + for (TLocationRecord r : sql.fetch()) { + list.add(LocationBean.of(r)); + } + return null; + } + } diff --git a/src/main/java/de/jottyfan/camporganizer/module/admin/AdminService.java b/src/main/java/de/jottyfan/camporganizer/module/admin/AdminService.java index d6d2db9..d947f1c 100644 --- a/src/main/java/de/jottyfan/camporganizer/module/admin/AdminService.java +++ b/src/main/java/de/jottyfan/camporganizer/module/admin/AdminService.java @@ -75,4 +75,13 @@ public class AdminService { public Integer deleteDocument(Integer id) { return adminRepository.deleteDocument(id); } + + /** + * get all locations + * + * @return the locations + */ + public List getLocations() { + return adminRepository.getLocations(); + } } diff --git a/src/main/java/de/jottyfan/camporganizer/module/admin/LocationBean.java b/src/main/java/de/jottyfan/camporganizer/module/admin/LocationBean.java new file mode 100644 index 0000000..35cf45b --- /dev/null +++ b/src/main/java/de/jottyfan/camporganizer/module/admin/LocationBean.java @@ -0,0 +1,84 @@ +package de.jottyfan.camporganizer.module.admin; + +import java.io.Serializable; + +import de.jottyfan.camporganizer.db.jooq.tables.records.TLocationRecord; + +/** + * + * @author jotty + * + */ +public class LocationBean implements Serializable { + private static final long serialVersionUID = 1L; + + private Integer pk; + private String name; + private Integer fkDocument; + private String url; + + public static LocationBean of(TLocationRecord r) { + LocationBean bean = new LocationBean(); + bean.setPk(r.getPk()); + bean.setName(r.getName()); + bean.setFkDocument(r.getFkDocument()); + bean.setUrl(r.getUrl()); + return bean; + } + + /** + * @return the pk + */ + public Integer getPk() { + return pk; + } + + /** + * @param pk the pk to set + */ + public void setPk(Integer pk) { + this.pk = pk; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the fkDocument + */ + public Integer getFkDocument() { + return fkDocument; + } + + /** + * @param fkDocument the fkDocument to set + */ + public void setFkDocument(Integer fkDocument) { + this.fkDocument = fkDocument; + } + + /** + * @return the url + */ + public String getUrl() { + return url; + } + + /** + * @param url the url to set + */ + public void setUrl(String url) { + this.url = url; + } +} diff --git a/src/main/resources/templates/admin/location.html b/src/main/resources/templates/admin/location.html new file mode 100644 index 0000000..158f947 --- /dev/null +++ b/src/main/resources/templates/admin/location.html @@ -0,0 +1,48 @@ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
NameURLWegbeschreibung
neues Freizeitheim anlegen
+ +
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/admin/main.html b/src/main/resources/templates/admin/main.html index c136e44..faad95d 100644 --- a/src/main/resources/templates/admin/main.html +++ b/src/main/resources/templates/admin/main.html @@ -18,6 +18,9 @@ +