fixed damaged deleting slots, see #5
This commit is contained in:
		| @@ -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 | ||||
| 	 * | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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:/"; | ||||
| 	} | ||||
|   | ||||
| @@ -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; | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user