-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from diegosneves/feat/controller
feat(Implemetação da Controller) ✨ Adicionar classes SplitInvoice Service, Response, Controller e DTO
- Loading branch information
Showing
5 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
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
28 changes: 28 additions & 0 deletions
28
src/main/java/diegosneves/github/rachapedido/controller/SplitInvoiceController.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,28 @@ | ||
package diegosneves.github.rachapedido.controller; | ||
|
||
import diegosneves.github.rachapedido.controller.contract.SplitInvoiceControllerContract; | ||
import diegosneves.github.rachapedido.request.SplitInvoiceRequest; | ||
import diegosneves.github.rachapedido.response.SplitInvoiceResponse; | ||
import diegosneves.github.rachapedido.service.SplitInvoiceService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/split") | ||
public class SplitInvoiceController implements SplitInvoiceControllerContract { | ||
|
||
private final SplitInvoiceService service; | ||
|
||
public SplitInvoiceController(@Autowired SplitInvoiceService service) { | ||
this.service = service; | ||
} | ||
|
||
|
||
@Override | ||
public ResponseEntity<SplitInvoiceResponse> splitInvoice(SplitInvoiceRequest request) { | ||
SplitInvoiceResponse response = this.service.updateEmail(request); // TODO - Criar a regra de negocio | ||
return ResponseEntity.ok(response); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...va/diegosneves/github/rachapedido/controller/contract/SplitInvoiceControllerContract.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,23 @@ | ||
package diegosneves.github.rachapedido.controller.contract; | ||
|
||
import diegosneves.github.rachapedido.request.SplitInvoiceRequest; | ||
import diegosneves.github.rachapedido.response.SplitInvoiceResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
|
||
public interface SplitInvoiceControllerContract { | ||
|
||
@PostMapping(value = "/invoice", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) | ||
@Operation(summary = "Receber os dados para realizar a divisão da fatura", tags = "Racha Pedido") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "Divisão da Fatura realizada com sucesso", content = @Content) | ||
}) | ||
ResponseEntity<SplitInvoiceResponse> splitInvoice(@RequestBody SplitInvoiceRequest request); | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/diegosneves/github/rachapedido/response/SplitInvoiceResponse.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,13 @@ | ||
package diegosneves.github.rachapedido.response; | ||
|
||
import diegosneves.github.rachapedido.dto.PersonDTO; | ||
import lombok.*; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Setter | ||
@Builder | ||
public class SplitInvoiceResponse { | ||
private PersonDTO buyer; // TODO - Definir os campos de retorno | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/diegosneves/github/rachapedido/service/SplitInvoiceService.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,18 @@ | ||
package diegosneves.github.rachapedido.service; | ||
|
||
import diegosneves.github.rachapedido.request.SplitInvoiceRequest; | ||
import diegosneves.github.rachapedido.response.SplitInvoiceResponse; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class SplitInvoiceService { | ||
|
||
// TODO - Criar as regras de Negocio | ||
|
||
public SplitInvoiceResponse updateEmail(SplitInvoiceRequest request) { | ||
final String TEST_EMAIL = "[email protected]"; | ||
request.getBuyer().setEmail(TEST_EMAIL); | ||
|
||
return new SplitInvoiceResponse(request.getBuyer()); | ||
} | ||
} |