added support for youth group
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package de.jottyfan.bico.modules.slot;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -9,6 +12,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import de.jottyfan.bico.db.enums.EnumGroupname;
|
||||
import de.jottyfan.bico.modules.CommonController;
|
||||
import de.jottyfan.bico.modules.slot.model.SlotBean;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -33,6 +37,7 @@ public class SlotController extends CommonController {
|
||||
public String load(@PathVariable("id") Integer id, Model model) {
|
||||
model.addAttribute("bean", id == null ? new SlotBean() : service.loadSlot(id));
|
||||
model.addAttribute("hasLesson", service.slotHasLesson(id));
|
||||
model.addAttribute("groupnames", EnumGroupname.values());
|
||||
return "/slot/item";
|
||||
}
|
||||
|
||||
@@ -56,4 +61,12 @@ public class SlotController extends CommonController {
|
||||
service.saveSlot(bean);
|
||||
return "redirect:/sheet";
|
||||
}
|
||||
|
||||
@ModelAttribute("groupnamemap")
|
||||
public Map<String, String> getTranslations() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("bibleclass", "Bibelunterricht");
|
||||
map.put("youthgroup", "Jungschar");
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.jottyfan.bico.modules.slot;
|
||||
|
||||
import static de.jottyfan.bico.db.public_.Tables.T_LESSON;
|
||||
import static de.jottyfan.bico.db.public_.Tables.T_SLOT;
|
||||
import static de.jottyfan.bico.db.Tables.T_LESSON;
|
||||
import static de.jottyfan.bico.db.Tables.T_SLOT;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@@ -15,8 +15,8 @@ import org.jooq.UpdateConditionStep;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import de.jottyfan.bico.db.public_.tables.records.TLessonRecord;
|
||||
import de.jottyfan.bico.db.public_.tables.records.TSlotRecord;
|
||||
import de.jottyfan.bico.db.tables.records.TLessonRecord;
|
||||
import de.jottyfan.bico.db.tables.records.TSlotRecord;
|
||||
import de.jottyfan.bico.modules.slot.model.SlotBean;
|
||||
|
||||
/**
|
||||
@@ -52,6 +52,7 @@ public class SlotRepository {
|
||||
bean.setPkSlot(r.getPkSlot());
|
||||
bean.setSlotDay(r.getSlotDay());
|
||||
bean.setNote(r.getNote());
|
||||
bean.setGroupname(r.getGroupname());
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
@@ -67,8 +68,9 @@ public class SlotRepository {
|
||||
// @formatter:off
|
||||
.insertInto(T_SLOT,
|
||||
T_SLOT.SLOT_DAY,
|
||||
T_SLOT.GROUPNAME,
|
||||
T_SLOT.NOTE)
|
||||
.values(slot.getSlotDay(), slot.getNote())
|
||||
.values(slot.getSlotDay(), slot.getGroupname(), slot.getNote())
|
||||
.returning(T_SLOT.PK_SLOT);
|
||||
// @formatter:on
|
||||
LOGGER.trace(sql);
|
||||
@@ -86,6 +88,7 @@ public class SlotRepository {
|
||||
.update(T_SLOT)
|
||||
.set(T_SLOT.SLOT_DAY, slot.getSlotDay())
|
||||
.set(T_SLOT.NOTE, slot.getNote())
|
||||
.set(T_SLOT.GROUPNAME, slot.getGroupname())
|
||||
.where(T_SLOT.PK_SLOT.eq(slot.getPkSlot()));
|
||||
// @formatter:on
|
||||
LOGGER.trace(sql);
|
||||
@@ -139,7 +142,7 @@ public class SlotRepository {
|
||||
.selectFrom(T_LESSON)
|
||||
.where(T_LESSON.FK_SLOT.eq(slotId));
|
||||
// @formatter:on
|
||||
LOGGER.info(sql);
|
||||
LOGGER.trace(sql);
|
||||
return sql.fetch().size() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.time.LocalDate;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import de.jottyfan.bico.db.enums.EnumGroupname;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
@@ -25,6 +26,8 @@ public class SlotBean implements Serializable {
|
||||
|
||||
private String note;
|
||||
|
||||
private EnumGroupname groupname;
|
||||
|
||||
public SlotBean withNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
@@ -71,4 +74,18 @@ public class SlotBean implements Serializable {
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the groupname
|
||||
*/
|
||||
public EnumGroupname getGroupname() {
|
||||
return groupname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param groupname the groupname to set
|
||||
*/
|
||||
public void setGroupname(EnumGroupname groupname) {
|
||||
this.groupname = groupname;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user