This commit is contained in:
@@ -42,6 +42,30 @@ public class BookingBean implements Serializable {
|
||||
private Boolean accept;
|
||||
private String subscriber;
|
||||
|
||||
public Boolean isFemale() {
|
||||
return EnumSex.female.equals(sex);
|
||||
}
|
||||
|
||||
public Boolean isMale() {
|
||||
return EnumSex.male.equals(sex);
|
||||
}
|
||||
|
||||
public Boolean isTeacher() {
|
||||
return EnumCamprole.teacher.equals(camprole);
|
||||
}
|
||||
|
||||
public Boolean isStudent() {
|
||||
return EnumCamprole.student.equals(camprole);
|
||||
}
|
||||
|
||||
public Boolean isDirector() {
|
||||
return EnumCamprole.director.equals(camprole);
|
||||
}
|
||||
|
||||
public Boolean isFeeder() {
|
||||
return EnumCamprole.feeder.equals(camprole);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the forename
|
||||
*/
|
||||
|
||||
@@ -9,6 +9,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -36,9 +38,16 @@ public class IndexController extends CommonController {
|
||||
public String dashboard(Model model) {
|
||||
super.setupSession(model, request);
|
||||
model.addAttribute("mybookings", service.getBookingsOf(super.getCurrentUser(request)));
|
||||
model.addAttribute("bookingBean", new BookingBean());
|
||||
return "/dashboard";
|
||||
}
|
||||
|
||||
@PostMapping("/dashboard/update")
|
||||
public String updateBooking(Model model, @ModelAttribute BookingBean bean) {
|
||||
service.update(bean);
|
||||
return dashboard(model);
|
||||
}
|
||||
|
||||
@GetMapping("/logout")
|
||||
public String getLogout(HttpServletRequest request) throws ServletException {
|
||||
request.logout();
|
||||
|
||||
@@ -14,11 +14,13 @@ import org.jooq.Condition;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.SelectConditionStep;
|
||||
import org.jooq.UpdateConditionStep;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import de.jottyfan.camporganizer.db.jooq.tables.TProfile;
|
||||
import de.jottyfan.camporganizer.db.jooq.tables.records.TPersonRecord;
|
||||
import de.jottyfan.camporganizer.db.jooq.tables.records.VCampRecord;
|
||||
|
||||
/**
|
||||
@@ -110,7 +112,7 @@ public class IndexGateway {
|
||||
String forename = r.get(REGISTRATOR.FORENAME);
|
||||
String surname = r.get(REGISTRATOR.SURNAME);
|
||||
if (forename != null) {
|
||||
buf.append(forename).append(" ");
|
||||
buf.append(forename).append(" ");
|
||||
}
|
||||
buf.append(surname != null ? surname : "");
|
||||
bean.setRegistrator(buf.toString());
|
||||
@@ -118,7 +120,7 @@ public class IndexGateway {
|
||||
String regForename = r.get(T_PROFILE.FORENAME);
|
||||
String regSurname = r.get(T_PROFILE.SURNAME);
|
||||
if (regForename != null) {
|
||||
buf.append(regForename).append(" ");
|
||||
buf.append(regForename).append(" ");
|
||||
}
|
||||
buf.append(regSurname != null ? regSurname : "");
|
||||
bean.setSubscriber(buf.toString());
|
||||
@@ -126,4 +128,28 @@ public class IndexGateway {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* update defined fields of the bean
|
||||
*
|
||||
* @param bean the bean
|
||||
* @return number of affected database rows; should be 1
|
||||
*/
|
||||
public Integer update(BookingBean bean) {
|
||||
UpdateConditionStep<TPersonRecord> sql = jooq
|
||||
// @formatter:off
|
||||
.update(T_PERSON)
|
||||
.set(T_PERSON.FORENAME, bean.getForename())
|
||||
.set(T_PERSON.SURNAME, bean.getSurname())
|
||||
.set(T_PERSON.STREET, bean.getStreet())
|
||||
.set(T_PERSON.ZIP, bean.getZip())
|
||||
.set(T_PERSON.CITY, bean.getCity())
|
||||
.set(T_PERSON.PHONE, bean.getPhone())
|
||||
.set(T_PERSON.EMAIL, bean.getEmail())
|
||||
.set(T_PERSON.COMMENT, bean.getComment())
|
||||
.where(T_PERSON.PK.eq(bean.getPk()));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
return sql.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,23 @@ public class IndexService {
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* get all bookings that the user can see
|
||||
*
|
||||
* @param username the name of the user
|
||||
* @return a list of beans
|
||||
*/
|
||||
public List<BookingBean> getBookingsOf(String username) {
|
||||
return gateway.getAllBookings(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* update defined contents of the bean
|
||||
*
|
||||
* @param bean the bean
|
||||
* @return true or false
|
||||
*/
|
||||
public Boolean update(BookingBean bean) {
|
||||
return gateway.update(bean) == 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user