From 8b2a559d37452070792e049844fd32beac257f1e Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Sat, 13 Apr 2019 23:56:24 +0400 Subject: [PATCH] #42 fix thymeleaf expressions --- src/main/java/ru/ulstu/grant/model/GrantDto.java | 16 ++++++++-------- .../ru/ulstu/grant/service/GrantService.java | 2 +- .../ru/ulstu/user/repository/UserRepository.java | 2 +- src/main/resources/templates/grants/grant.html | 13 +++++++------ 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/java/ru/ulstu/grant/model/GrantDto.java b/src/main/java/ru/ulstu/grant/model/GrantDto.java index 1a3a2e0..9ad9d21 100644 --- a/src/main/java/ru/ulstu/grant/model/GrantDto.java +++ b/src/main/java/ru/ulstu/grant/model/GrantDto.java @@ -29,7 +29,7 @@ public class GrantDto { private Set authorIds; private Set authors; private Integer leaderId; - private boolean leader; + private boolean wasLeader; private boolean birthDate; private boolean degree; @@ -47,7 +47,7 @@ public class GrantDto { @JsonProperty("authorIds") Set authorIds, @JsonProperty("authors") Set authors, @JsonProperty("leader") Integer leaderId, - @JsonProperty("leader") boolean leader, + @JsonProperty("wasLeader") boolean wasLeader, @JsonProperty("birthDate") boolean birthDate, @JsonProperty("degree") boolean degree) { this.id = id; @@ -59,7 +59,7 @@ public class GrantDto { this.project = project; this.authors = authors; this.leaderId = leaderId; - this.leader = leader; + this.wasLeader = wasLeader; this.birthDate = birthDate; this.degree = degree; } @@ -75,7 +75,7 @@ public class GrantDto { this.authorIds = convert(grant.getAuthors(), user -> user.getId()); this.authors = convert(grant.getAuthors(), UserDto::new); this.leaderId = grant.getLeader().getId(); - this.leader = false; + this.wasLeader = false; this.birthDate = false; this.degree = false; } @@ -167,12 +167,12 @@ public class GrantDto { this.leaderId = leaderId; } - public boolean isLeader() { - return leader; + public boolean isWasLeader() { + return wasLeader; } - public void setLeader(boolean leader) { - this.leader = leader; + public void setWasLeader(boolean wasLeader) { + this.wasLeader = wasLeader; } public boolean isBirthDate() { diff --git a/src/main/java/ru/ulstu/grant/service/GrantService.java b/src/main/java/ru/ulstu/grant/service/GrantService.java index aa8ffac..98b95c3 100644 --- a/src/main/java/ru/ulstu/grant/service/GrantService.java +++ b/src/main/java/ru/ulstu/grant/service/GrantService.java @@ -141,7 +141,7 @@ public class GrantService { public List getGrantAuthors(GrantDto grantDto) { List filteredUsers = userService.filterByAgeAndDegree(grantDto.isBirthDate(), grantDto.isDegree()); - if (grantDto.isLeader()) { + if (grantDto.isWasLeader()) { filteredUsers = filteredUsers .stream() .filter(getCompletedGrantLeaders()::contains) diff --git a/src/main/java/ru/ulstu/user/repository/UserRepository.java b/src/main/java/ru/ulstu/user/repository/UserRepository.java index fc7a42c..f6fbc62 100644 --- a/src/main/java/ru/ulstu/user/repository/UserRepository.java +++ b/src/main/java/ru/ulstu/user/repository/UserRepository.java @@ -29,7 +29,7 @@ public interface UserRepository extends JpaRepository { User findOneWithRolesByLogin(String login); @Query("SELECT u FROM User u " + - "WHERE (YEAR(u.birthDate) - YEAR(CURRENT_DATE) < 35 OR :hasAge = FALSE) " + + "WHERE (YEAR(CURRENT_DATE) - YEAR(u.birthDate) < 35 OR :hasAge = FALSE) " + "AND (u.degree = 'CANDIDATE' OR :hasDegree = FALSE)" + "ORDER BY u.lastName") List filterByAgeAndDegree(@Param("hasAge") boolean hasAge, diff --git a/src/main/resources/templates/grants/grant.html b/src/main/resources/templates/grants/grant.html index 05b2a03..4a45cad 100644 --- a/src/main/resources/templates/grants/grant.html +++ b/src/main/resources/templates/grants/grant.html @@ -85,16 +85,17 @@ -
- -
+ +
+ th:field="*{wasLeader}" th:onclick="|$('#filter').click();|"/>