Skip to content

Commit 3ec81a6

Browse files
committed
refactor: change client id data type
1 parent 512b229 commit 3ec81a6

File tree

12 files changed

+19
-16
lines changed

12 files changed

+19
-16
lines changed

src/main/java/br/com/grupo63/serviceorder/adapter/OrderAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
public class OrderAdapter {
1313

14-
public static void fillEntity(CreateOrderRequestDTO dto, Long clientId, Order order) {
14+
public static void fillEntity(CreateOrderRequestDTO dto, String clientId, Order order) {
1515
OrderControllerDTO orderDTO = new OrderControllerDTO();
1616
orderDTO.setClientId(clientId);
1717

src/main/java/br/com/grupo63/serviceorder/api/controller/order/OrderAPIController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class OrderAPIController extends AbstractAPIController {
3535
public ResponseEntity<OrderControllerDTO> create(@Valid @RequestBody CreateOrderRequestDTO createOrderRequestDTO,
3636
HttpServletRequest request) throws ValidationException, NotFoundException {
3737
return ResponseEntity.ok(controller
38-
.create(Long.parseLong((String) request.getAttribute("clientId")),
38+
.create((String) request.getAttribute("clientId"),
3939
createOrderRequestDTO));
4040
}
4141

src/main/java/br/com/grupo63/serviceorder/controller/OrderController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class OrderController {
1919

2020
private final OrderUseCase orderUseCase;
2121

22-
public OrderControllerDTO create(Long clientId, CreateOrderRequestDTO dto) throws ValidationException, NotFoundException {
22+
public OrderControllerDTO create(String clientId, CreateOrderRequestDTO dto) throws ValidationException, NotFoundException {
2323
Order entity = new Order();
2424
OrderAdapter.fillEntity(dto, clientId, entity);
2525
entity = orderUseCase.create(entity, clientId);

src/main/java/br/com/grupo63/serviceorder/controller/dto/OrderControllerDTO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
public class OrderControllerDTO extends AbstractControllerDTO {
1717

1818
private Double totalPrice;
19-
private Long clientId;
19+
private String clientId;
2020
private List<OrderItemControllerDTO> items = new ArrayList<>();
2121

2222
}

src/main/java/br/com/grupo63/serviceorder/entity/order/Order.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
public class Order extends Entity {
1717

1818
private Double totalPrice;
19-
private Long clientId;
19+
private String clientId;
2020
private List<OrderItem> items = new ArrayList<>();
2121

22-
public Order(Long id, boolean deleted, Double totalPrice, Long clientId, List<OrderItem> items) {
22+
public Order(Long id, boolean deleted, Double totalPrice, String clientId, List<OrderItem> items) {
2323
super(id, deleted);
2424
this.totalPrice = totalPrice;
2525
this.clientId = clientId;

src/main/java/br/com/grupo63/serviceorder/gateway/identification/IIdentificationGateway.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
import java.util.Optional;
1010

11-
@FeignClient(name = "identification", url = "/identification/clients")
11+
@FeignClient(name = "identification", url = "${urls.baseurl-identification}")
1212
public interface IIdentificationGateway {
1313

14-
@RequestMapping(method = RequestMethod.GET, value = "/{id}")
15-
Optional<ClientDTO> getById(@PathVariable("id") Long orderId);
14+
@RequestMapping(method = RequestMethod.GET, value = "/identification/clients/{id}")
15+
Optional<ClientDTO> getById(@PathVariable("id") String id);
1616

1717
}

src/main/java/br/com/grupo63/serviceorder/gateway/order/entity/OrderPersistenceEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class OrderPersistenceEntity extends PersistenceEntity {
2626

2727
@Basic
2828
@Column(name = "ord_client", nullable = false)
29-
private Long clientId;
29+
private String clientId;
3030

3131
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "order")
3232
private List<OrderItemPersistenceEntity> items = new ArrayList<>();

src/main/java/br/com/grupo63/serviceorder/usecase/order/IOrderUseCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
public interface IOrderUseCase {
1010

11-
Order create(Order entity, Long clientId) throws ValidationException, NotFoundException;
11+
Order create(Order entity, String clientId) throws ValidationException, NotFoundException;
1212

1313
Order read(Long id) throws NotFoundException;
1414

src/main/java/br/com/grupo63/serviceorder/usecase/order/OrderUseCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private void fillCurrentPrices(Order order) throws NotFoundException {
3636
}
3737

3838
@Override
39-
public Order create(Order entity, Long clientId) throws NotFoundException {
39+
public Order create(Order entity, String clientId) throws NotFoundException {
4040
identificationGateway.getById(clientId).orElseThrow(NotFoundException::new);
4141

4242
fillCurrentPrices(entity);

src/main/resources/application-dev.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ jwt:
2323
key:
2424
public: "${JWT_PUBLIC_KEY:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqStd8n4SGNM0eZhV/hzU+urHA5/IMZPoP9YQ9ZcLKWiX33nI6bSuZMCrLZcJExf63xS+uxDpGxM8Mnk2zOdl+lPwANXLzP1us5P1PyA3YPycW9J7C5YTQW0GiEL3M93ZX7vMJiVoBYblP3JPlYnoYlBORuc0JPk33KtfEZP+78qXpPHM8imYrJLe8ceiDLLFDU/nh5KC2dWAy3ci1ahoJ1Q9ELhp3IZLvOTX57H/T2VKOYOya5+ST41h+JjzI+qGTVnLcKaW+k25YLlVnkSspvdx98+yQDi7kbOTS6yRZHUPD6wPk/nUozpD0nZKccoH4W+zMwmQVtsAA6JCA9gfGwIDAQAB}"
2525

26+
urls:
27+
baseurl-identification: 'base-url'
28+
2629
server:
2730
servlet:
2831
context-path: "/order"

0 commit comments

Comments
 (0)