Skip to content

Commit

Permalink
Merge pull request #21 from bouanani-soufiane/PIG-64-Lofts
Browse files Browse the repository at this point in the history
PIG-64-Lofts
  • Loading branch information
bouanani-soufiane authored Nov 11, 2024
2 parents 4d2aa9d + 5c083fc commit b265d8e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
@RestController
@RequestMapping("/api/v1/lofts")
@RequiredArgsConstructor
@Validated
class LoftController {

private final DefaultLoftDomainService service;

@PostMapping()
public ResponseEntity<ResponseApi<LoftResponseDTO>> createLoft ( @Valid @RequestBody LoftRequestDTO loftRequest ) {
public ResponseEntity<ResponseApi<LoftResponseDTO>> create ( @Valid @RequestBody LoftRequestDTO loftRequest ) {
LoftResponseDTO response = service.create(loftRequest);
return ResponseEntity
.status(HttpStatus.CREATED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import jakarta.validation.constraints.NotNull;

public record CoordinateRequestDTO(
@NotNull Double latitude,
@NotNull Double longitude) {

@NotNull(message = "latitude cannot be null" ) Double latitude,
@NotNull(message = "longitude cannot be null" ) Double longitude) {
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package ma.yc.PigeonSkyRace.piegon.application.dto.request;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import ma.yc.PigeonSkyRace.common.application.validation.EntityExists;
import ma.yc.PigeonSkyRace.user.domain.model.aggregate.User;

public record LoftRequestDTO(
@NotNull CoordinateRequestDTO coordinate,
@Valid
@NotNull(message = "coordinate cannot be null" )
CoordinateRequestDTO coordinate,

@EntityExists(entity = User.class, message = "The specified breeder does not exist")
@NotNull String userId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import ma.yc.PigeonSkyRace.piegon.domain.service.LoftNameGenerator;
import ma.yc.PigeonSkyRace.piegon.infrastructure.repository.LoftRepository;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.List;

@Service
@RequiredArgsConstructor
@Slf4j
@Validated
public class DefaultLoftDomainService implements LoftDomainService, LoftApplicationService {

private final LoftRepository repository;
Expand Down

0 comments on commit b265d8e

Please sign in to comment.