fixed damaged deleting slots, see #5

This commit is contained in:
Jottyfan
2024-11-11 23:03:21 +01:00
parent a1ad23920a
commit bf88306d85
12 changed files with 59 additions and 25 deletions

View File

@ -42,7 +42,7 @@ public abstract class CommonController {
return false;
}
}
@ModelAttribute("hasDateRole")
public Boolean hasDateRole(Principal principal) {
OAuth2AuthenticationToken token = (OAuth2AuthenticationToken) principal;
@ -56,6 +56,21 @@ public abstract class CommonController {
return false;
}
}
@ModelAttribute("hasAnyRole")
public Boolean hasAnyRole(Principal principal) {
OAuth2AuthenticationToken token = (OAuth2AuthenticationToken) principal;
if (token != null) {
OAuth2User user = token.getPrincipal();
@SuppressWarnings("unchecked")
List<String> roles = (List<String>) user.getAttributes().get("roles");
return roles.size() > 0;
} else {
LOGGER.warn("token is null, no roles can be detected");
return false;
}
}
/**
* get the theme for the current session
*

View File

@ -23,10 +23,10 @@ import de.jottyfan.bico.db.tables.records.TLessonRecord;
import de.jottyfan.bico.db.tables.records.TPersonRecord;
/**
*
* @author jotty
*
*/
*
* @author jotty
*
*/
@Repository
public class LessonRepository {
private final static Logger LOGGER = LogManager.getLogger(LessonRepository.class);

View File

@ -25,7 +25,7 @@ public class ProfileController extends CommonController {
* @param theme the theme
*/
@PostMapping("/updateTheme/{theme}")
public ResponseEntity<?> updateTheme(@PathVariable String theme) {
public ResponseEntity<?> updateTheme(@PathVariable("theme") String theme) {
// TODO: add profile's user name
String username = "jotty";
service.updateTheme(username, theme);

View File

@ -30,20 +30,20 @@ public class SlotController extends CommonController {
}
@GetMapping("/slot/{id}")
public String load(@PathVariable Integer id, Model model) {
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));
return "/slot/item";
}
@GetMapping("/slot/{id}/delete")
public String loadEnsurance(@PathVariable Integer id, Model model) {
public String loadEnsurance(@PathVariable("id") Integer id, Model model) {
model.addAttribute("bean", service.loadDeletableSlot(id));
return "/slot/delete";
}
@GetMapping("/slot/{id}/destroy")
public String destroy(@PathVariable Integer id, Model model) {
public String destroy(@PathVariable("id") Integer id, Model model) {
service.removeSlot(id);
return "redirect:/";
}

View File

@ -139,7 +139,7 @@ public class SlotRepository {
.selectFrom(T_LESSON)
.where(T_LESSON.FK_SLOT.eq(slotId));
// @formatter:on
LOGGER.trace(sql);
LOGGER.info(sql);
return sql.fetch().size() > 0;
}
}