added start_booking, see #14

This commit is contained in:
Jottyfan
2024-03-16 22:40:36 +01:00
parent ce819f80de
commit 03eb781a98
8 changed files with 101 additions and 43 deletions

View File

@@ -25,7 +25,7 @@ import org.jooq.DeleteConditionStep;
import org.jooq.Field;
import org.jooq.InsertResultStep;
import org.jooq.InsertReturningStep;
import org.jooq.InsertValuesStep15;
import org.jooq.InsertValuesStep16;
import org.jooq.InsertValuesStep3;
import org.jooq.Record4;
import org.jooq.Record5;
@@ -435,10 +435,12 @@ public class AdminRepository {
jooq.transaction(t -> {
LocalDate arriveDate = bean.getArrive();
LocalDate departDate = bean.getDepart();
LocalDate startBookingDate = bean.getStartBooking();
LocalDateTime arrive = arriveDate == null ? null : arriveDate.atStartOfDay();
LocalDateTime depart = departDate == null ? null : departDate.atStartOfDay();
LocalDateTime startBooking = startBookingDate == null ? null : startBookingDate.atStartOfDay();
if (bean.getPk() == null) {
InsertValuesStep15<TCampRecord, LocalDateTime, String, LocalDateTime, Integer, Integer, Integer, Boolean, Integer, Integer, String, String, Integer, Integer, Integer, Integer> sql = DSL
InsertValuesStep16<TCampRecord, LocalDateTime, String, LocalDateTime, Integer, Integer, Integer, Boolean, Integer, Integer, String, String, Integer, Integer, Integer, Integer, LocalDateTime> sql = DSL
.using(t)
// @formatter:off
.insertInto(T_CAMP,
@@ -456,10 +458,11 @@ public class AdminRepository {
T_CAMP.BEDS_FEMALE,
T_CAMP.BEDS_MALE,
T_CAMP.BLOCKED_BEDS_FEMALE,
T_CAMP.BLOCKED_BEDS_MALE)
T_CAMP.BLOCKED_BEDS_MALE,
T_CAMP.START_BOOKING)
.values(arrive, bean.getCountries(), depart, bean.getFkDocument(), bean.getFkLocation(), bean.getFkProfile(),
bean.getLockSales() != null ? bean.getLockSales() : false, bean.getMaxAge(), bean.getMinAge(), bean.getName(), bean.getPrice(),
bean.getBedsFemale(), bean.getBedsMale(), bean.getBlockedBedsFemale(), bean.getBlockedBedsMale());
bean.getBedsFemale(), bean.getBedsMale(), bean.getBlockedBedsFemale(), bean.getBlockedBedsMale(), startBooking);
// @formatter:on
LOGGER.debug(sql.toString());
sql.execute();
@@ -482,6 +485,7 @@ public class AdminRepository {
.set(T_CAMP.BEDS_MALE, bean.getBedsMale())
.set(T_CAMP.BLOCKED_BEDS_FEMALE, bean.getBlockedBedsFemale())
.set(T_CAMP.BLOCKED_BEDS_MALE, bean.getBlockedBedsMale())
.set(T_CAMP.START_BOOKING, startBooking)
.where(T_CAMP.PK.eq(bean.getPk()));
// @formatter:on
LOGGER.debug(sql.toString());

View File

@@ -57,6 +57,9 @@ public class CampBean implements Serializable {
@NotNull
@Min(value = 0)
private Integer blockedBedsMale;
@NotNull
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate startBooking;
/**
* generate a camp bean out of r
@@ -71,6 +74,7 @@ public class CampBean implements Serializable {
CampBean bean = new CampBean();
LocalDateTime arrive = r.getArrive();
LocalDateTime depart = r.getDepart();
LocalDateTime startBooking = r.getStartBooking();
bean.setArrive(arrive == null ? null : arrive.toLocalDate());
bean.setCountries(r.getCountries());
bean.setDepart(depart == null ? null : depart.toLocalDate());
@@ -87,6 +91,7 @@ public class CampBean implements Serializable {
bean.setBedsMale(r.getBedsMale());
bean.setBlockedBedsFemale(r.getBlockedBedsFemale());
bean.setBlockedBedsMale(r.getBlockedBedsMale());
bean.setStartBooking(startBooking == null ? null : startBooking.toLocalDate());
return bean;
}
@@ -344,4 +349,18 @@ public class CampBean implements Serializable {
public void setBlockedBedsMale(Integer blockedBedsMale) {
this.blockedBedsMale = blockedBedsMale;
}
/**
* @return the startBooking
*/
public LocalDate getStartBooking() {
return startBooking;
}
/**
* @param startBooking the startBooking to set
*/
public void setStartBooking(LocalDate startBooking) {
this.startBooking = startBooking;
}
}

View File

@@ -6,6 +6,7 @@ import static de.jottyfan.camporganizer.db.jooq.Tables.T_PERSONDOCUMENT;
import static de.jottyfan.camporganizer.db.jooq.Tables.T_PROFILE;
import static de.jottyfan.camporganizer.db.jooq.Tables.T_PROFILEROLE;
import static de.jottyfan.camporganizer.db.jooq.Tables.T_RSS;
import static de.jottyfan.camporganizer.db.jooq.Tables.V_CAMP;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -42,11 +43,11 @@ 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.TCampRecord;
import de.jottyfan.camporganizer.db.jooq.tables.records.TPersonRecord;
import de.jottyfan.camporganizer.db.jooq.tables.records.TPersondocumentRecord;
import de.jottyfan.camporganizer.db.jooq.tables.records.TProfileRecord;
import de.jottyfan.camporganizer.db.jooq.tables.records.TRssRecord;
import de.jottyfan.camporganizer.db.jooq.tables.records.VCampRecord;
import de.jottyfan.camporganizer.module.camplist.model.BookingBean;
import de.jottyfan.camporganizer.module.camplist.model.LambdaResultWrapper;
import de.jottyfan.camporganizer.module.registration.model.CampBean;
@@ -73,15 +74,17 @@ public class RegistrationRepository {
* @return the camp bean or null
*/
public CampBean getCamp(Integer pk) {
SelectConditionStep<TCampRecord> sql = jooq.selectFrom(T_CAMP).where(T_CAMP.PK.eq(pk));
SelectConditionStep<VCampRecord> sql = jooq.selectFrom(V_CAMP).where(V_CAMP.PK.eq(pk));
LOGGER.debug(sql.toString());
TCampRecord r = sql.fetchOne();
VCampRecord r = sql.fetchOne();
if (r != null) {
CampBean bean = new CampBean();
bean.setPk(r.getPk());
bean.setName(r.getName());
LocalDateTime arrive = r.getArrive();
bean.setYear(arrive == null ? null : arrive.getYear());
bean.setBookingHasStarted(r.getBookingHasStarted());
bean.setStartBooking(r.getStartBooking());
return bean;
} else {
return null;

View File

@@ -1,6 +1,7 @@
package de.jottyfan.camporganizer.module.registration.model;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
*
@@ -13,6 +14,8 @@ public class CampBean implements Serializable {
private Integer pk;
private String name;
private Integer year;
private LocalDateTime startBooking;
private Boolean bookingHasStarted;
/**
* @return the pk
@@ -55,4 +58,32 @@ public class CampBean implements Serializable {
public void setYear(Integer year) {
this.year = year;
}
/**
* @return the bookingHasStarted
*/
public Boolean getBookingHasStarted() {
return bookingHasStarted;
}
/**
* @param bookingHasStarted the bookingHasStarted to set
*/
public void setBookingHasStarted(Boolean bookingHasStarted) {
this.bookingHasStarted = bookingHasStarted;
}
/**
* @return the startBooking
*/
public LocalDateTime getStartBooking() {
return startBooking;
}
/**
* @param startBooking the startBooking to set
*/
public void setStartBooking(LocalDateTime startBooking) {
this.startBooking = startBooking;
}
}