1

fix search funktion

This commit is contained in:
tomvahl
2020-03-17 12:35:06 +01:00
parent 8387b58e35
commit cbf69e387b
2 changed files with 9 additions and 6 deletions

View File

@ -19,8 +19,8 @@ public interface EventRepository extends CrudRepository<EventDTO, Long> {
//@Query("SELECT * FROM event WHERE event_id > ?#{[0]}") //@Query("SELECT * FROM event WHERE event_id > ?#{[0]}")
//Iterable<EventDTO> findNewEventSinceStatus(@Param("status") Long status); //Iterable<EventDTO> findNewEventSinceStatus(@Param("status") Long status);
@Query("select * from event where visibility =:vis") @Query("select distinct group_id from event where visibility =:vis")
List<EventDTO> findEventDTOByVisibility(@Param("vis") Boolean visibility); List<Long> findGroup_idsWhereVisibility(@Param("vis") Boolean visibility);
@Query("SELECT DISTINCT group_id FROM event WHERE event_id > :status") @Query("SELECT DISTINCT group_id FROM event WHERE event_id > :status")
public List<Long> findNewEventSinceStatus(@Param("status") Long status); public List<Long> findNewEventSinceStatus(@Param("status") Long status);

View File

@ -3,6 +3,7 @@ package mops.gruppen2.service;
import mops.gruppen2.domain.EventDTO; import mops.gruppen2.domain.EventDTO;
import mops.gruppen2.domain.Exceptions.EventException; import mops.gruppen2.domain.Exceptions.EventException;
import mops.gruppen2.domain.Group; import mops.gruppen2.domain.Group;
import mops.gruppen2.domain.Visibility;
import mops.gruppen2.domain.event.Event; import mops.gruppen2.domain.event.Event;
import mops.gruppen2.repository.EventRepository; import mops.gruppen2.repository.EventRepository;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -76,14 +77,16 @@ public class GroupService {
* @return * @return
* @throws EventException * @throws EventException
*/ */
public List<Group> getAllGroupWithVisibilityPublic() throws EventException { public List<Group> getAllGroupWithVisibilityPublic() throws EventException {
return projectEventList(eventService.translateEventDTOs(eventRepository.findEventDTOByVisibility(Boolean.TRUE))); List<Long> group_ids = eventRepository.findGroup_idsWhereVisibility(Boolean.TRUE);
List<EventDTO> eventDTOS = eventRepository.findAllEventsOfGroups(group_ids);
List<Event> events = eventService.translateEventDTOs(eventDTOS);
List<Group> groups = projectEventList(events);
return groups;
} }
/** /**
* Filtert alle öffentliche Gruppen nach dem suchbegriff und gibt diese als Liste von Gruppen zurück. * Filtert alle öffentliche Gruppen nach dem suchbegriff und gibt diese als Liste von Gruppen zurück.
* Groß und kleinschreibung wird beachtet. * Groß und kleinschreibung wird beachtet.