#60 added sorting
This commit is contained in:
parent
bc98785be9
commit
a4ae42f072
@ -9,6 +9,7 @@ import ru.ulstu.user.model.User;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface ConferenceRepository extends JpaRepository<Conference, Integer> {
|
public interface ConferenceRepository extends JpaRepository<Conference, Integer> {
|
||||||
@Query("SELECT c FROM Conference c LEFT JOIN c.users u WHERE (:user IS NULL OR u.user = :user) AND (YEAR(c.beginDate) = :year OR :year IS NULL)")
|
@Query("SELECT c FROM Conference c LEFT JOIN c.users u WHERE (:user IS NULL OR u.user = :user) " +
|
||||||
List<Conference> filter(@Param("user") User user, @Param("year") Integer year);
|
"AND (YEAR(c.beginDate) = :year OR :year IS NULL) ORDER BY begin_date DESC")
|
||||||
|
List<Conference> findByUserAndYear(@Param("user") User user, @Param("year") Integer year);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package ru.ulstu.conference.service;
|
package ru.ulstu.conference.service;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.conference.model.Conference;
|
||||||
@ -59,7 +60,7 @@ public class ConferenceService {
|
|||||||
|
|
||||||
|
|
||||||
public List<Conference> findAll() {
|
public List<Conference> findAll() {
|
||||||
return conferenceRepository.findAll();
|
return conferenceRepository.findAll(new Sort(Sort.Direction.DESC, "beginDate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ConferenceDto> findAllDto() {
|
public List<ConferenceDto> findAllDto() {
|
||||||
@ -158,7 +159,7 @@ public class ConferenceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ConferenceDto> filter(ConferenceFilterDto conferenceFilterDto) {
|
public List<ConferenceDto> filter(ConferenceFilterDto conferenceFilterDto) {
|
||||||
return convert(conferenceRepository.filter(
|
return convert(conferenceRepository.findByUserAndYear(
|
||||||
conferenceFilterDto.getFilterUserId() == null ? null : userService.findById(conferenceFilterDto.getFilterUserId()),
|
conferenceFilterDto.getFilterUserId() == null ? null : userService.findById(conferenceFilterDto.getFilterUserId()),
|
||||||
conferenceFilterDto.getYear()), ConferenceDto::new);
|
conferenceFilterDto.getYear()), ConferenceDto::new);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user