1

Add method to find group by id

Add method to connect details.html to the controller
This commit is contained in:
kasch309
2020-03-13 14:28:16 +01:00
parent 7bbdbad28e
commit eeded221b4
2 changed files with 15 additions and 0 deletions

View File

@ -83,4 +83,11 @@ public class Gruppen2Controller {
return "redirect:/gruppen2/";
}
@GetMapping("/details")
public String showGroupDetails(KeycloakAuthenticationToken token, Model model, @RequestParam (value="group_id") Long group_id) throws EventException {
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
model.addAttribute("group", userService.getGroupById(group_id));
return "details";
}
}

View File

@ -6,6 +6,7 @@ import mops.gruppen2.domain.event.Event;
import mops.gruppen2.repository.EventRepository;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
@ -26,4 +27,11 @@ public class UserService {
List<Event> events = groupService.getGroupEvents(group_ids);
return groupService.projectEventList(events);
}
public Group getGroupById(Long group_id) throws EventException {
List<Long> group_ids = new ArrayList<>();
group_ids.add(group_id);
List<Event> events = groupService.getGroupEvents(group_ids);
return groupService.projectEventList(events).get(0);
}
}