Add method to find group by id
Add method to connect details.html to the controller
This commit is contained in:
@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user