first steps of items
This commit is contained in:
@ -8,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'de.jottyfan.bico'
|
||||
version = '0.0.1'
|
||||
version = '0.0.2'
|
||||
|
||||
description = """BibleClassOrganizer"""
|
||||
|
||||
@ -41,13 +41,13 @@ war {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'de.jottyfan:bicolib:2'
|
||||
implementation 'de.jottyfan:bicolib:3'
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-jooq'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
||||
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:3.0.0'
|
||||
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:latest.release'
|
||||
|
||||
implementation 'org.webjars:bootstrap:5.3.1'
|
||||
implementation 'org.webjars.npm:bootstrap-icons:1.10.5'
|
||||
|
@ -0,0 +1,27 @@
|
||||
package de.jottyfan.bico.modules.item;
|
||||
|
||||
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.PathVariable;
|
||||
|
||||
import de.jottyfan.bico.modules.CommonController;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
public class ItemController extends CommonController {
|
||||
|
||||
@Autowired
|
||||
private ItemService service;
|
||||
|
||||
@GetMapping("/item/{slot}")
|
||||
public String getItem(@PathVariable Integer slot, Model model) {
|
||||
model.addAttribute("bean", service.getItem(slot));
|
||||
return "/item";
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package de.jottyfan.bico.modules.item;
|
||||
|
||||
import static de.jottyfan.bico.db.Tables.T_LESSON;
|
||||
import static de.jottyfan.bico.db.Tables.T_LESSON_SUBJECT;
|
||||
import static de.jottyfan.bico.db.Tables.T_PERSON;
|
||||
import static de.jottyfan.bico.db.Tables.T_SLOT;
|
||||
import static de.jottyfan.bico.db.Tables.T_SOURCE;
|
||||
import static de.jottyfan.bico.db.Tables.T_SUBJECT;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Record17;
|
||||
import org.jooq.SelectConditionStep;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import de.jottyfan.bico.modules.item.model.ItemBean;
|
||||
import de.jottyfan.bico.modules.item.model.LessonBean;
|
||||
import de.jottyfan.bico.modules.item.model.PersonBean;
|
||||
import de.jottyfan.bico.modules.item.model.SourceBean;
|
||||
import de.jottyfan.bico.modules.item.model.SubjectBean;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
@Repository
|
||||
public class ItemRepository {
|
||||
private static final Logger LOGGER = LogManager.getLogger(ItemRepository.class);
|
||||
|
||||
@Autowired
|
||||
private DSLContext jooq;
|
||||
|
||||
/**
|
||||
* get the item of slot
|
||||
*
|
||||
* @param slot the ID of the slot
|
||||
* @return the bean
|
||||
*/
|
||||
public ItemBean getItem(Integer slot) {
|
||||
SelectConditionStep<Record17<Integer, LocalDate, String, String, Integer, String, String, String, Integer, String, Integer, String, String, String, String, String, String>> sql = jooq
|
||||
// @formatter:off
|
||||
.select(T_SLOT.PK_SLOT,
|
||||
T_SLOT.SLOT_DAY,
|
||||
T_SLOT.NOTE,
|
||||
T_LESSON.NOTES,
|
||||
T_PERSON.PK_PERSON,
|
||||
T_PERSON.FORENAME,
|
||||
T_PERSON.SURNAME,
|
||||
T_PERSON.ABBREVIATION,
|
||||
T_SOURCE.PK_SOURCE,
|
||||
T_SOURCE.NAME,
|
||||
T_SUBJECT.PK_SUBJECT,
|
||||
T_SUBJECT.THEME,
|
||||
T_SUBJECT.SUBTHEME,
|
||||
T_SUBJECT.WORKSHEETS,
|
||||
T_SUBJECT.BIBLEVERSE,
|
||||
T_SUBJECT.BOOK_PAGES,
|
||||
T_SOURCE.NAME)
|
||||
.from(T_SLOT)
|
||||
.leftJoin(T_LESSON).on(T_LESSON.FK_SLOT.eq(T_SLOT.PK_SLOT))
|
||||
.leftJoin(T_PERSON).on(T_PERSON.PK_PERSON.eq(T_LESSON.FK_PERSON))
|
||||
.leftJoin(T_LESSON_SUBJECT).on(T_LESSON_SUBJECT.FK_LESSON.eq(T_LESSON.PK_LESSON))
|
||||
.leftJoin(T_SUBJECT).on(T_SUBJECT.PK_SUBJECT.eq(T_LESSON_SUBJECT.FK_SUBJECT))
|
||||
.leftJoin(T_SOURCE).on(T_SOURCE.PK_SOURCE.eq(T_SUBJECT.FK_SOURCE))
|
||||
.where(T_SLOT.PK_SLOT.eq(slot));
|
||||
// @formatter:on
|
||||
LOGGER.trace(sql);
|
||||
Iterator<Record17<Integer, LocalDate, String, String, Integer, String, String, String, Integer, String, Integer, String, String, String, String, String, String>> i = sql
|
||||
.fetch().iterator();
|
||||
ItemBean bean = new ItemBean();
|
||||
while (i.hasNext()) {
|
||||
Record17<Integer, LocalDate, String, String, Integer, String, String, String, Integer, String, Integer, String, String, String, String, String, String> r = i
|
||||
.next();
|
||||
bean.setPkSlot(r.get(T_SLOT.PK_SLOT));
|
||||
bean.setSlotDay(r.get(T_SLOT.SLOT_DAY));
|
||||
bean.setSlotNote(r.get(T_SLOT.NOTE));
|
||||
bean.getLessons()
|
||||
.add(LessonBean.of(
|
||||
r.get(T_LESSON.NOTES), new PersonBean(r.get(T_PERSON.PK_PERSON), r.get(T_PERSON.FORENAME),
|
||||
r.get(T_PERSON.SURNAME), r.get(T_PERSON.ABBREVIATION)),
|
||||
new SubjectBean(new SourceBean(r.get(T_SOURCE.PK_SOURCE), r.get(T_SOURCE.NAME)), r.get(T_SUBJECT.PK_SUBJECT), r.get(T_SUBJECT.THEME),
|
||||
r.get(T_SUBJECT.SUBTHEME), r.get(T_SUBJECT.WORKSHEETS), r.get(T_SUBJECT.BIBLEVERSE),
|
||||
r.get(T_SUBJECT.BOOK_PAGES))));
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
}
|
22
src/main/java/de/jottyfan/bico/modules/item/ItemService.java
Normal file
22
src/main/java/de/jottyfan/bico/modules/item/ItemService.java
Normal file
@ -0,0 +1,22 @@
|
||||
package de.jottyfan.bico.modules.item;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import de.jottyfan.bico.modules.item.model.ItemBean;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class ItemService {
|
||||
|
||||
@Autowired
|
||||
private ItemRepository repository;
|
||||
|
||||
public ItemBean getItem(Integer slot) {
|
||||
return repository.getItem(slot);
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package de.jottyfan.bico.modules.item.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ItemBean implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer pkSlot;
|
||||
private LocalDate slotDay;
|
||||
private String slotNote;
|
||||
private List<LessonBean> lessons;
|
||||
|
||||
public ItemBean() {
|
||||
lessons = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pkSlot
|
||||
*/
|
||||
public Integer getPkSlot() {
|
||||
return pkSlot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pkSlot the pkSlot to set
|
||||
*/
|
||||
public void setPkSlot(Integer pkSlot) {
|
||||
this.pkSlot = pkSlot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the slotDay
|
||||
*/
|
||||
public LocalDate getSlotDay() {
|
||||
return slotDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slotDay the slotDay to set
|
||||
*/
|
||||
public void setSlotDay(LocalDate slotDay) {
|
||||
this.slotDay = slotDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the slotNote
|
||||
*/
|
||||
public String getSlotNote() {
|
||||
return slotNote;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slotNote the slotNote to set
|
||||
*/
|
||||
public void setSlotNote(String slotNote) {
|
||||
this.slotNote = slotNote;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lessons
|
||||
*/
|
||||
public List<LessonBean> getLessons() {
|
||||
return lessons;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package de.jottyfan.bico.modules.item.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class LessonBean implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String lessonNote;
|
||||
private List<PersonBean> persons;
|
||||
private List<SubjectBean> subjects;
|
||||
|
||||
public LessonBean() {
|
||||
persons = new ArrayList<>();
|
||||
subjects = new ArrayList<>();
|
||||
}
|
||||
|
||||
public static final LessonBean of(String lessonNote, PersonBean persons, SubjectBean subject) {
|
||||
LessonBean bean = new LessonBean();
|
||||
bean.getPersons().add(persons);
|
||||
bean.getSubjects().add(subject);
|
||||
return bean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lessonNote
|
||||
*/
|
||||
public String getLessonNote() {
|
||||
return lessonNote;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lessonNote the lessonNote to set
|
||||
*/
|
||||
public void setLessonNote(String lessonNote) {
|
||||
this.lessonNote = lessonNote;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the persons
|
||||
*/
|
||||
public List<PersonBean> getPersons() {
|
||||
return persons;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the subjects
|
||||
*/
|
||||
public List<SubjectBean> getSubjects() {
|
||||
return subjects;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package de.jottyfan.bico.modules.item.model;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public record PersonBean(Integer pkPerson, String forename, String surname, String abbreviation) {
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package de.jottyfan.bico.modules.item.model;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public record SourceBean(Integer pkSource, String name) {
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package de.jottyfan.bico.modules.item.model;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public record SubjectBean(SourceBean source, Integer pkSubject, String theme, String subtheme, String worksheets,
|
||||
String bibleverse, String bookPages) {
|
||||
|
||||
}
|
@ -35,6 +35,8 @@ public class SheetRepository {
|
||||
List<SheetBean> list = new ArrayList<>();
|
||||
for (VCalendarRecord r : sql.fetch()) {
|
||||
SheetBean bean = new SheetBean();
|
||||
bean.setPkSlot(r.getPkSlot());
|
||||
bean.setPkSubject(r.getPkSubject());
|
||||
bean.setAbbreviation(r.getAbbreviation());
|
||||
bean.setBibleverse(r.getBibleverse());
|
||||
bean.setBookPages(r.getBookPages());
|
||||
|
@ -23,6 +23,8 @@ public class SheetBean implements Serializable {
|
||||
private String subjectNotes;
|
||||
private String lessonNotes;
|
||||
private String slotNotes;
|
||||
private Integer pkSlot;
|
||||
private Integer pkSubject;
|
||||
|
||||
/**
|
||||
* @return the slotDay
|
||||
@ -191,4 +193,32 @@ public class SheetBean implements Serializable {
|
||||
public void setSlotNotes(String slotNotes) {
|
||||
this.slotNotes = slotNotes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pkSlot
|
||||
*/
|
||||
public Integer getPkSlot() {
|
||||
return pkSlot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pkSlot the pkSlot to set
|
||||
*/
|
||||
public void setPkSlot(Integer pkSlot) {
|
||||
this.pkSlot = pkSlot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pkSubject
|
||||
*/
|
||||
public Integer getPkSubject() {
|
||||
return pkSubject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pkSubject the pkSubject to set
|
||||
*/
|
||||
public void setPkSubject(Integer pkSubject) {
|
||||
this.pkSubject = pkSubject;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ toggleDarkMode = function() {
|
||||
* only because th:data-bs-theme="${theme}" does not work
|
||||
*/
|
||||
$(document).ready(function(){
|
||||
var theme = /*[[${theme}]]*/ 'dark';
|
||||
var theme = /*[[${theme}]]*/ 'light';
|
||||
$("html").attr("data-bs-theme", theme);
|
||||
});
|
||||
|
41
src/main/resources/templates/item.html
Normal file
41
src/main/resources/templates/item.html
Normal file
@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org" layout:decorate="~{template}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
|
||||
<body>
|
||||
<th:block layout:fragment="content">
|
||||
<div class="borderdist">
|
||||
<div class="container" th:if="${bean}">
|
||||
<div class="row g-2">
|
||||
<div class="col-sm-2">Tag</div>
|
||||
<div class="col-sm-10" th:text="${#temporals.format(bean.slotDay, 'yyyy-MM-dd')}"></div>
|
||||
<div class="col-sm-2">Lehreinheiten</div>
|
||||
<div class="col-sm-10">
|
||||
<div class="row g-2" th:each="l : ${bean.lessons}">
|
||||
<div class="col-sm-2">Dozent</div>
|
||||
<div class="col-sm-10">
|
||||
<div th:each="p : ${l.persons}" th:text="${p.forename} + ' ' + ${p.surname}"></div>
|
||||
</div>
|
||||
<div class="col-sm-2">Themen</div>
|
||||
<div class="col-sm-10">
|
||||
<div class="row g-2" th:each="x : ${l.subjects}">
|
||||
<div class="col-sm-2">Thema</div>
|
||||
<div class="col-sm-10" th:text="${x.theme}"></div>
|
||||
<div class="col-sm-2">Unterthema</div>
|
||||
<div class="col-sm-10" th:text="${x.subtheme}"></div>
|
||||
<div class="col-sm-2">Buchseiten</div>
|
||||
<div class="col-sm-10" th:text="${x.bookPages}"></div>
|
||||
<div class="col-sm-2">Arbeitsblätter</div>
|
||||
<div class="col-sm-10" th:text="${x.worksheets}"></div>
|
||||
<div class="col-sm-2">Bibelvers</div>
|
||||
<div class="col-sm-10" th:text="${x.bibleverse}"></div>
|
||||
<div class="col-sm-2">Quelle</div>
|
||||
<div class="col-sm-10" th:text="${x.source?.name}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</th:block>
|
||||
</body>
|
||||
</html>
|
@ -12,6 +12,7 @@
|
||||
<th>Thema</th>
|
||||
<th>Unterthema</th>
|
||||
<th>Tag-Anmerkungen</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -22,6 +23,7 @@
|
||||
<td th:text="${s.theme}"></td>
|
||||
<td th:text="${s.subtheme}"></td>
|
||||
<td th:text="${s.slotNotes}"></td>
|
||||
<td><a th:href="@{/item/{slot}(slot=${s.pkSlot})}" class="btn btn-outline-secondary"><i class="bi bi-pencil"></i></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
Reference in New Issue
Block a user