preparations for adding camp locations

This commit is contained in:
2023-03-10 23:37:44 +01:00
parent 27ee382f4a
commit b3a186f5ca
9 changed files with 192 additions and 8 deletions

View File

@@ -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";
}
}

View File

@@ -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<LocationBean> getLocations() {
SelectWhereStep<TLocationRecord> sql = jooq.selectFrom(T_LOCATION);
LOGGER.debug(sql.toString());
List<LocationBean> list = new ArrayList<>();
for (TLocationRecord r : sql.fetch()) {
list.add(LocationBean.of(r));
}
return null;
}
}

View File

@@ -75,4 +75,13 @@ public class AdminService {
public Integer deleteDocument(Integer id) {
return adminRepository.deleteDocument(id);
}
/**
* get all locations
*
* @return the locations
*/
public List<LocationBean> getLocations() {
return adminRepository.getLocations();
}
}

View File

@@ -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;
}
}