lesson
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user