-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae27899
commit fb61fdd
Showing
13 changed files
with
134 additions
and
42 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
...-data-customsequence/src/main/java/com/example/custom/sequence/mapper/CustomerMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example.custom.sequence.mapper; | ||
|
||
import com.example.custom.sequence.entities.Customer; | ||
import com.example.custom.sequence.model.response.CustomerResponse; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class CustomerMapper { | ||
public CustomerResponse mapToResponse(Customer saved) { | ||
return new CustomerResponse(saved.getId(), saved.getText()); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...oot-data-customsequence/src/main/java/com/example/custom/sequence/mapper/OrderMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.example.custom.sequence.mapper; | ||
|
||
import com.example.custom.sequence.entities.Customer; | ||
import com.example.custom.sequence.entities.Order; | ||
import com.example.custom.sequence.model.response.CustomerResponse; | ||
import com.example.custom.sequence.model.response.OrderResponse; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class OrderMapper { | ||
|
||
public OrderResponse getOrderResponse(Order order) { | ||
Customer customer = order.getCustomer(); | ||
return new OrderResponse( | ||
order.getId(), | ||
order.getText(), | ||
new CustomerResponse(customer.getId(), customer.getText())); | ||
} | ||
} |
3 changes: 0 additions & 3 deletions
3
...-customsequence/src/main/java/com/example/custom/sequence/model/response/CustomerDTO.java
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...omsequence/src/main/java/com/example/custom/sequence/model/response/CustomerResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.example.custom.sequence.model.response; | ||
|
||
public record CustomerResponse(String id, String text) {} |
2 changes: 1 addition & 1 deletion
2
...ustomsequence/src/main/java/com/example/custom/sequence/model/response/OrderResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package com.example.custom.sequence.model.response; | ||
|
||
public record OrderResponse(String id, String text, CustomerDTO customerDTO) {} | ||
public record OrderResponse(String id, String text, CustomerResponse customer) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...ot-data-customsequence/src/main/java/com/example/custom/sequence/web/api/CustomerAPI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.example.custom.sequence.web.api; | ||
|
||
import com.example.custom.sequence.entities.Customer; | ||
import com.example.custom.sequence.model.response.CustomerResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.parameters.RequestBody; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import jakarta.validation.Valid; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ProblemDetail; | ||
|
||
public interface CustomerAPI { | ||
|
||
/** | ||
* POST /api/customers | ||
* | ||
* @param customer (required) | ||
* @return Created (status code 201) or Bad Request (status code 400) | ||
*/ | ||
@Operation( | ||
operationId = "createCustomer", | ||
tags = {"customer-controller"}, | ||
responses = { | ||
@ApiResponse( | ||
responseCode = "201", | ||
description = "Created", | ||
content = { | ||
@Content( | ||
mediaType = MediaType.APPLICATION_JSON_VALUE, | ||
schema = @Schema(implementation = CustomerResponse.class)) | ||
}), | ||
@ApiResponse( | ||
responseCode = "400", | ||
description = "Bad Request", | ||
content = { | ||
@Content( | ||
mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE, | ||
schema = @Schema(implementation = ProblemDetail.class)) | ||
}) | ||
}) | ||
CustomerResponse createCustomer( | ||
@Valid @RequestBody(description = "", required = true) Customer customer); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters