Skip to content

Commit

Permalink
Merge pull request slabiak#25 from slabiak/develop
Browse files Browse the repository at this point in the history
release 1.0.3
  • Loading branch information
slabiak authored Dec 23, 2020
2 parents 46be264 + 058a375 commit 24a7981
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.example.slabiak</groupId>
<artifactId>appointmentscheduler</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
<name>appointmentscheduler</name>
<description>Demo project for Spring Boot</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.example.slabiak.appointmentscheduler.entity.Appointment;
import com.example.slabiak.appointmentscheduler.model.AppointmentRegisterForm;
import com.example.slabiak.appointmentscheduler.model.TimePeroid;
import com.example.slabiak.appointmentscheduler.security.CustomUserDetails;
import com.example.slabiak.appointmentscheduler.service.AppointmentService;
import com.example.slabiak.appointmentscheduler.service.NotificationService;
Expand All @@ -14,8 +13,8 @@
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@RequestMapping("/api")
@RestController
Expand Down Expand Up @@ -44,18 +43,15 @@ else if (currentUser.hasRole("ROLE_ADMIN"))
@GetMapping("/availableHours/{providerId}/{workId}/{date}")
public List<AppointmentRegisterForm> getAvailableHours(@PathVariable("providerId") int providerId, @PathVariable("workId") int workId, @PathVariable("date") String date, @AuthenticationPrincipal CustomUserDetails currentUser) {
LocalDate localDate = LocalDate.parse(date);
List<TimePeroid> peroids = appointmentService.getAvailableHours(providerId, currentUser.getId(), workId, localDate);
List<AppointmentRegisterForm> appointments = new ArrayList<>();
for (TimePeroid peroid : peroids) {
appointments.add(new AppointmentRegisterForm(workId, providerId, peroid.getStart().atDate(localDate), peroid.getEnd().atDate(localDate)));
}
return appointments;
return appointmentService.getAvailableHours(providerId, currentUser.getId(), workId, localDate)
.stream()
.map(timePeriod -> new AppointmentRegisterForm(workId, providerId, timePeriod.getStart().atDate(localDate), timePeriod.getEnd().atDate(localDate)))
.collect(Collectors.toList());
}

@GetMapping("/user/notifications")
public int getUnreadNotificationsCount(@AuthenticationPrincipal CustomUserDetails currentUser) {
return notificationService.getUnreadNotifications(currentUser.getId()).size();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<th></th>
<th></th>
<th></th>
<th></th>
<th sec:authorize="hasRole('ROLE_ADMIN')"></th>
</tr>
</tfoot>
</table>
Expand Down

0 comments on commit 24a7981

Please sign in to comment.