Commit b713cb37 authored by José Alfredo Goulart Filho's avatar José Alfredo Goulart Filho
Browse files

finish birthdays

parent 1d3f30df
Showing with 13 additions and 7 deletions
+13 -7
......@@ -15,6 +15,7 @@ services:
- SPRING_DATASOURCE_USERNAME=postgres
- SPRING_DATASOURCE_PASSWORD=postgres
- SPRING_JPA_HIBERNATE_DDL_AUTO=update
- SPRINGDOC_SWAGGER_UI_PATH=/docs.html
db:
image: 'postgres:latest'
......
......@@ -87,10 +87,16 @@ public class UserService {
public List<User> getBirthdayUsers() {
Date now = Date.valueOf(LocalDate.now());
now.setTime(now.getTime() - 10800000);
return entityManager
.createQuery("select u from User u where u.birthDate>=:now", User.class)
now.setTime(now.getTime());
Date endOfWeek = Date.valueOf(LocalDate.now());
int weekAsMilli = 604800000;
endOfWeek.setTime(endOfWeek.getTime() + weekAsMilli);
String query = "select u from User u where u.birthDate between :now and :endOfWeek";
return entityManager.createQuery(query, User.class)
.setParameter("now", now)
.setParameter("endOfWeek", endOfWeek)
.getResultList();
}
}
\ No newline at end of file
package pucrs.hslcommunicationservice;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class HslCommunicationServiceApplicationTests {
@Test
void contextLoads() {
}
// @Test
// void contextLoads() {
// }
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment