Merge branch '60-sort-conf' into 'dev'

Resolve "Сортировка списка конференций"

Closes #60

See merge request romanov73/ng-tracker!66
environments/staging/deployments/34
Anton Romanov 5 years ago
commit b6ced3ce1a

@ -54,6 +54,11 @@ public class ConferenceController {
conferenceFilterDto.getYear()));
}
@GetMapping("/dashboard")
public void getDashboard(ModelMap modelMap) {
modelMap.put("conferences", conferenceService.findAllActiveDto());
}
@GetMapping("/conference")
public void getConference(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
if (id != null && id > 0) {

@ -6,9 +6,14 @@ import org.springframework.data.repository.query.Param;
import ru.ulstu.conference.model.Conference;
import ru.ulstu.user.model.User;
import java.util.Date;
import java.util.List;
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)")
List<Conference> filter(@Param("user") User user, @Param("year") Integer year);
@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) ORDER BY begin_date DESC")
List<Conference> findByUserAndYear(@Param("user") User user, @Param("year") Integer year);
@Query("SELECT c FROM Conference c WHERE c.beginDate > :date")
List<Conference> findAllActive(@Param("date") Date date);
}

@ -1,6 +1,7 @@
package ru.ulstu.conference.service;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ru.ulstu.conference.model.Conference;
@ -17,6 +18,7 @@ import ru.ulstu.user.service.UserService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import static org.springframework.util.ObjectUtils.isEmpty;
@ -59,7 +61,7 @@ public class ConferenceService {
public List<Conference> findAll() {
return conferenceRepository.findAll();
return conferenceRepository.findAll(new Sort(Sort.Direction.DESC, "beginDate"));
}
public List<ConferenceDto> findAllDto() {
@ -158,9 +160,17 @@ public class ConferenceService {
}
public List<ConferenceDto> filter(ConferenceFilterDto conferenceFilterDto) {
return convert(conferenceRepository.filter(
return convert(conferenceRepository.findByUserAndYear(
conferenceFilterDto.getFilterUserId() == null ? null : userService.findById(conferenceFilterDto.getFilterUserId()),
conferenceFilterDto.getYear()), ConferenceDto::new);
}
public List<ConferenceDto> findAllActiveDto() {
return convert(findAllActive(), ConferenceDto::new);
}
public List<Conference> findAllActive() {
return conferenceRepository.findAllActive(new Date());
}
}

@ -38,7 +38,7 @@
<div class="form-group">
<label for="url">URL:</label>
<input class="form-control" th:field="*{url}" id="url" type="text"
placeholder="URL адрес"/>
placeholder="http://"/>
</div>
<div class="form-group">

@ -16,11 +16,10 @@
</div>
</div>
<hr/>
<div class="row">
<div class="col-lg-12">
</div>
<div class="row justify-content-center" id="dashboard">
<th:block th:each="conference : ${conferences}">
<div th:replace="conferences/fragments/confDashboardFragment :: confDashboard(conference=${conference})"/>
</th:block>
</div>
</div>
</section>

@ -10,8 +10,14 @@
</div>
<div class="col col-10 text-right">
<h7 class="service-heading"> title</h7>
<p class="text-muted"></p>
<p th:if="${conference.url!=null and conference.url!=''}"><a target="_blank" th:href="${conference.url}"><i
class="fa fa-external-link fa-1x"
aria-hidden="true"></i></a></p>
<p th:unless="${conference.url!=null and conference.url!=''}"><i class="fa fa-fw fa-2x"
aria-hidden="true"></i></p>
<a th:href="'conference?id='+${conference.id}">
<h7 class="service-heading" th:text="${conference.title}"> title</h7>
</a>
</div>
</div>
</div>

@ -13,7 +13,7 @@
</div>
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
<a href="./actual" class="btn btn-light toolbar-button">
<a href="./dashboard" class="btn btn-light toolbar-button">
<i class="fa fa-newspaper-o" aria-hidden="true"></i>
Актуальное</a>
</div>

Loading…
Cancel
Save