Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,16 @@ components:
type: object
properties:
id:
type: string # TODO integer
format: uuid # TODO int64 -> Krzysztof - change uuid to integer or something better suited for long for Long id of Entity. Change all uuid and resign from getMostSignificantBits everywhere
type: integer
format: int64
name:
type: string
duration:
type: integer
description: Duration of the treatment in minutes
specialistId:
type: string
format: uuid
type: integer
format: int64

TreatmentRequest:
type: object
Expand All @@ -203,8 +203,8 @@ components:
duration:
type: integer
specialistId:
type: string
format: uuid
type: integer
format: int64

TreatmentDetails:
allOf:
Expand All @@ -215,8 +215,8 @@ components:
type: object
properties:
id:
type: string
format: uuid
type: integer
format: int64
name:
type: string

Expand All @@ -228,11 +228,11 @@ components:
- dateTime
properties:
clientId:
type: string
format: uuid
type: integer
format: int64
treatmentId:
type: string
format: uuid
type: integer
format: int64
dateTime:
type: string
format: date-time
Expand All @@ -241,14 +241,14 @@ components:
type: object
properties:
id:
type: string
format: uuid
type: integer
format: int64
clientId:
type: string
format: uuid
type: integer
format: int64
treatmentId:
type: string
format: uuid
type: integer
format: int64
dateTime:
type: string
format: date-time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
Expand Down Expand Up @@ -44,8 +43,8 @@ public ResponseEntity<List<Appointment>> getAppointments(

AppointmentCriteria.AppointmentCriteriaBuilder criteria = AppointmentCriteria.builder();
status.ifPresent(t -> criteria.status(AppointmentStatus.valueOf(t)));
clientId.ifPresent(t -> criteria.clientId(UUID.fromString(t).getMostSignificantBits()));
specialistId.ifPresent(t -> criteria.specialistId(UUID.fromString(t).getMostSignificantBits())); // TODO Krzysztof resign from getMostSignificantBits everywhere, instewad of uuid we want integer
clientId.ifPresent(t -> criteria.clientId(Long.valueOf(t)));
specialistId.ifPresent(t -> criteria.specialistId(Long.valueOf(t)));

List<AppointmentCto> list = findAppointmentUc.findByCriteria(criteria.build());
List<Appointment> result =
Expand All @@ -56,7 +55,7 @@ public ResponseEntity<List<Appointment>> getAppointments(
@Override
public ResponseEntity<Void> updateAppointmentStatus(
String appointmentId, @Valid AppointmentStatusUpdate appointmentStatusUpdate) {
Long id = UUID.fromString(appointmentId).getMostSignificantBits();
Long id = Long.valueOf(appointmentId);
AppointmentStatus status =
AppointmentStatus.valueOf(appointmentStatusUpdate.getStatus().name());
manageAppointmentUc.updateAppointmentStatus(id, status);
Expand All @@ -67,7 +66,7 @@ public ResponseEntity<Void> updateAppointmentStatus(
public ResponseEntity<CheckAvailability200Response> checkAvailability(
@NotNull @Valid String specialistId,
@NotNull @Valid @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date dateTime) {
Long specialistLongId = UUID.fromString(specialistId).getMostSignificantBits();
Long specialistLongId = Long.valueOf(specialistId);
boolean available =
!findAppointmentUc.hasConflictingAppointment(specialistLongId, dateTime.toInstant());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import jakarta.validation.Valid;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
Expand All @@ -38,7 +37,7 @@ public ResponseEntity<Treatment> createTreatment(@Valid TreatmentRequest treatme

@Override
public ResponseEntity<TreatmentDetails> getTreatmentDetails(String treatmentId) {
Long id = UUID.fromString(treatmentId).getMostSignificantBits();
Long id = Long.valueOf(treatmentId);
Optional<TreatmentCto> optional = findTreatmentUc.findById(id);

return optional
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.capgemini.training.appointmentbooking.service.mapper;

import java.util.Optional;
import java.util.UUID;

import com.capgemini.training.appointmentbooking.common.to.AppointmentBookingEto;
import com.capgemini.training.appointmentbooking.common.to.AppointmentCto;
Expand All @@ -13,10 +12,12 @@ public class AppointmentApiMapper {

public AppointmentBookingEto toBookingEto(AppointmentRequest request) {
return AppointmentBookingEto.builder()
.clientId(toLong(request.getClientId()))
.treatmentId(toLong(request.getTreatmentId()))
.clientId(request.getClientId())
.treatmentId(request.getTreatmentId())
.specialistId(
0L) // specjalista nie jest częścią requestu – może być wyciągany przez treatment
0L) // TODO specjalista nie jest częścią requestu – usunąć to po usunięciu specialistId tylko z AppointmentBookingEto,
// bo jedyne użycie AppointmentBookingEto#specialistId jest w findAppointmentUc.hasConflictingAppointment
// gdzie specialistId da się wyciągnąć z treatment
.dateTime(request.getDateTime().toInstant())
.build();
}
Expand All @@ -25,19 +26,12 @@ public Appointment toApiAppointment(AppointmentCto cto) {
AppointmentEto appointmentEto = cto.appointmentEto();

Appointment result = new Appointment();
result.setId(Optional.of(toUuid(appointmentEto.id())));
result.setClientId(Optional.of(toUuid(cto.clientEto().id())));
result.setTreatmentId(Optional.of(toUuid(cto.treatmentCto().treatmentEto().id())));
result.setId(Optional.of(appointmentEto.id()));
result.setClientId(Optional.of(cto.clientEto().id()));
result.setTreatmentId(Optional.of(cto.treatmentCto().treatmentEto().id()));
result.setDateTime(Optional.of(java.util.Date.from(appointmentEto.dateTime())));
result.setStatus(Optional.of(Appointment.StatusEnum.valueOf(appointmentEto.status().name())));
return result;
}

private Long toLong(UUID uuid) {
return uuid.getMostSignificantBits();
}

private UUID toUuid(Long id) {
return new UUID(id, 0L);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.capgemini.training.appointmentbooking.service.mapper;

import java.util.Optional;
import java.util.UUID;

import com.capgemini.training.appointmentbooking.common.to.SpecialistEto;
import com.capgemini.training.appointmentbooking.common.to.TreatmentCreationTo;
Expand All @@ -18,7 +17,7 @@ public TreatmentCreationTo toCreationTo(TreatmentRequest request) {
return TreatmentCreationTo.builder()
.name(request.getName().orElse(null))
.durationMinutes(request.getDuration().orElse(0))
.specialistId(request.getSpecialistId().map(UUID::getMostSignificantBits).orElse(null))
.specialistId(request.getSpecialistId().orElse(null))
.description("Default description")
.build();
}
Expand All @@ -28,10 +27,10 @@ public Treatment toApiTreatment(TreatmentCto cto) {
SpecialistEto specialist = cto.specialistEto();

Treatment result = new Treatment();
result.setId(Optional.ofNullable(eto.id()).map(this::toUuid));
result.setId(Optional.ofNullable(eto.id()));
result.setName(Optional.ofNullable(eto.name()));
result.setDuration(Optional.of(eto.durationMinutes()));
result.setSpecialistId(Optional.ofNullable(specialist.id()).map(this::toUuid));
result.setSpecialistId(Optional.ofNullable(specialist.id()));
return result;
}

Expand All @@ -40,20 +39,17 @@ public TreatmentDetails toApiTreatmentDetails(TreatmentCto cto) {
SpecialistEto specialist = cto.specialistEto();

TreatmentDetails result = new TreatmentDetails();
result.setId(Optional.ofNullable(eto.id()).map(this::toUuid));
result.setId(Optional.ofNullable(eto.id()));
result.setName(Optional.ofNullable(eto.name()));
result.setDuration(Optional.of(eto.durationMinutes()));
result.setSpecialistId(Optional.ofNullable(specialist.id()).map(this::toUuid));
result.setSpecialistId(Optional.ofNullable(specialist.id()));

TreatmentDetailsAllOfSpecialist specialistDto = new TreatmentDetailsAllOfSpecialist();
specialistDto.setId(Optional.ofNullable(specialist.id()).map(this::toUuid));
specialistDto.setId(Optional.ofNullable(specialist.id()));
specialistDto.setName(Optional.ofNullable(specialist.specialization().name()));

result.setSpecialist(Optional.of(specialistDto));
return result;
}

private UUID toUuid(Long id) {
return new UUID(id, 0L);
}
}
Loading