register already known persons
This commit is contained in:
parent
d4ae63f975
commit
453105419f
@ -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
|
||||
|
@ -8,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'de.jottyfan.camporganizer'
|
||||
version = '0.6.3'
|
||||
version = '0.6.4'
|
||||
|
||||
description = """CampOrganizer2"""
|
||||
|
||||
|
@ -38,6 +38,7 @@ public class RegistrationController extends CommonController {
|
||||
model.addAttribute("bean", bean);
|
||||
model.addAttribute("sexes", EnumConverter.getSexes());
|
||||
model.addAttribute("roles", EnumConverter.getRoles());
|
||||
model.addAttribute("wellknown", service.getWellKnownRegistrations(getCurrentUser()));
|
||||
return "/registration/registration";
|
||||
} else {
|
||||
return "/registration/isover";
|
||||
|
@ -11,6 +11,8 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -27,6 +29,7 @@ import org.jooq.Record1;
|
||||
import org.jooq.Record2;
|
||||
import org.jooq.Record5;
|
||||
import org.jooq.Record7;
|
||||
import org.jooq.Record9;
|
||||
import org.jooq.SelectConditionStep;
|
||||
import org.jooq.UpdateConditionStep;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
@ -418,4 +421,44 @@ public class RegistrationRepository {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the person information of already registered people
|
||||
*
|
||||
* @param currentUser the user that registered people
|
||||
* @return the list of found registrations, may be an empty list; if currentUser is null, return null.
|
||||
*/
|
||||
public List<RegistrationBean> getRegistrations(String currentUser) {
|
||||
SelectConditionStep<Record9<String, String, String, String, String, String, String, EnumSex, LocalDate>> sql = jooq
|
||||
// @formatter:off
|
||||
.selectDistinct(T_PERSON.FORENAME,
|
||||
T_PERSON.SURNAME,
|
||||
T_PERSON.STREET,
|
||||
T_PERSON.ZIP,
|
||||
T_PERSON.CITY,
|
||||
T_PERSON.PHONE,
|
||||
T_PERSON.EMAIL,
|
||||
T_PERSON.SEX,
|
||||
T_PERSON.BIRTHDATE)
|
||||
.from(T_PERSON)
|
||||
.innerJoin(T_PROFILE).on(T_PROFILE.PK.eq(T_PERSON.FK_PROFILE))
|
||||
.where(DSL.lower(T_PROFILE.USERNAME).eq(currentUser == null ? null : currentUser.toLowerCase()));
|
||||
// @formatter:on
|
||||
LOGGER.trace(sql);
|
||||
List<RegistrationBean> list = new ArrayList<>();
|
||||
for (Record r : sql.fetch()) {
|
||||
RegistrationBean bean = new RegistrationBean();
|
||||
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.setEmail(r.get(T_PERSON.EMAIL));
|
||||
bean.setSex(r.get(T_PERSON.SEX));
|
||||
bean.setBirthDate(r.get(T_PERSON.BIRTHDATE));
|
||||
list.add(bean);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
package de.jottyfan.camporganizer.module.registration;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import de.jottyfan.camporganizer.module.camplist.model.BookingBean;
|
||||
import de.jottyfan.camporganizer.module.registration.model.AlreadyKnownPersonBean;
|
||||
import de.jottyfan.camporganizer.module.registration.model.CampBean;
|
||||
import de.jottyfan.camporganizer.module.registration.model.RegistrationBean;
|
||||
|
||||
@ -54,7 +59,8 @@ public class RegistrationService {
|
||||
}
|
||||
Boolean result = gateway.register(bean);
|
||||
if (result && bean.getRegisterInKeycloak()) {
|
||||
keycloak.register(bean.getKcForename(), bean.getKcSurname(), bean.getLogin(), bean.getPassword(), bean.getKcEmail());
|
||||
keycloak.register(bean.getKcForename(), bean.getKcSurname(), bean.getLogin(), bean.getPassword(),
|
||||
bean.getKcEmail());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -81,4 +87,31 @@ public class RegistrationService {
|
||||
public void toggleConsent(Integer id) {
|
||||
gateway.toggleConsent(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* get already registered entries from the database
|
||||
*
|
||||
* @param currentUser the name of the current user; may be null
|
||||
* @return the list or null if current user is null
|
||||
*/
|
||||
public List<AlreadyKnownPersonBean> getWellKnownRegistrations(String currentUser) {
|
||||
if (currentUser == null) {
|
||||
return null;
|
||||
} else {
|
||||
List<RegistrationBean> r = gateway.getRegistrations(currentUser);
|
||||
if (r == null) {
|
||||
return null;
|
||||
} else {
|
||||
List<AlreadyKnownPersonBean> list = new ArrayList<>();
|
||||
for (RegistrationBean b : r) {
|
||||
AlreadyKnownPersonBean bean = new AlreadyKnownPersonBean();
|
||||
bean.setSource(b);
|
||||
bean.setOption(String.format("%s %s, %s, %s %s, %s, %s", b.getForename(), b.getSurname(), b.getStreet(),
|
||||
b.getZip(), b.getCity(), b.getEmail(), b.getPhone()));
|
||||
list.add(bean);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,16 @@
|
||||
<input type="hidden" th:field="*{fkCamp}" />
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 rowdist" th:if="${wellknown}">
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-outline-secondary dropdown-toggle form-control" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
aus bisherigen Anmeldungen vorbefüllen
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li th:each="w : ${wellknown}"><a class="dropdown-item" href="#" th:attr="onclick=|useexisting('${w.json}')|"><span
|
||||
th:text="${w.option}"></span></a></li>
|
||||
</ul>
|
||||
</div> </div>
|
||||
<div class="col-sm-6 rowdist">
|
||||
<div>Vorname</div>
|
||||
<input type="text" th:field="*{forename}" th:class="${'form-control ' + (#fields.hasErrors('forename') ? 'inputerror' : '')}" />
|
||||
@ -122,6 +132,20 @@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
function useexisting(o) {
|
||||
j = JSON.parse(o);
|
||||
$("#forename").val(j.forename);
|
||||
$("#surname").val(j.surname);
|
||||
$("#street").val(j.street);
|
||||
$("#zip").val(j.zip);
|
||||
$("#city").val(j.city);
|
||||
$("#phone").val(j.phone);
|
||||
$("#email").val(j.email);
|
||||
$("#sex").val(j.sex);
|
||||
$("#birthDate").val(j.birthDate);
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user