This commit is contained in:
Jottyfan
2023-11-28 22:44:00 +01:00
parent 48525b7e20
commit 690f28f4fe
15 changed files with 300 additions and 35 deletions

View File

@@ -32,6 +32,7 @@ public class SlotController extends CommonController {
@GetMapping("/slot/{id}")
public String load(@PathVariable Integer id, Model model) {
model.addAttribute("bean", id == null ? new SlotBean() : service.loadSlot(id));
model.addAttribute("hasLesson", service.slotHasLesson(id));
return "/slot/item";
}

View File

@@ -126,4 +126,20 @@ public class SlotRepository {
return null;
}
}
/**
* return true if this slot already has at least one lesson
*
* @param slotId the ID of the slot
* @return true or false
*/
public Boolean getHasLesson(Integer slotId) {
SelectConditionStep<TLessonRecord> sql = jooq
// @formatter:off
.selectFrom(T_LESSON)
.where(T_LESSON.FK_SLOT.eq(slotId));
// @formatter:on
LOGGER.trace(sql);
return sql.fetch().size() > 0;
}
}

View File

@@ -36,4 +36,8 @@ public class SlotService {
public SlotBean loadDeletableSlot(Integer id) {
return repository.getSlotIfDeletable(id);
}
public Boolean slotHasLesson(Integer id) {
return id == null ? false : repository.getHasLesson(id);
}
}