From a3f49c2c7a5cc8819cec5a818534dea895589420 Mon Sep 17 00:00:00 2001 From: PedroVidalDev Date: Mon, 22 Apr 2024 20:06:22 -0300 Subject: [PATCH] feat: adding permission column in consumer --- .../application/dtos/consumer/ConsumerDataEditInput.java | 3 ++- .../sphynx/application/dtos/consumer/ConsumerDataInput.java | 4 +++- .../com/pedro/sphynx/infrastructure/entities/Consumer.java | 6 ++++++ .../migration/V10__alter-table-consumers-add-permission.sql | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/db/migration/V10__alter-table-consumers-add-permission.sql diff --git a/src/main/java/com/pedro/sphynx/application/dtos/consumer/ConsumerDataEditInput.java b/src/main/java/com/pedro/sphynx/application/dtos/consumer/ConsumerDataEditInput.java index 262c5c2..09d4c00 100644 --- a/src/main/java/com/pedro/sphynx/application/dtos/consumer/ConsumerDataEditInput.java +++ b/src/main/java/com/pedro/sphynx/application/dtos/consumer/ConsumerDataEditInput.java @@ -1,6 +1,7 @@ package com.pedro.sphynx.application.dtos.consumer; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; -public record ConsumerDataEditInput(@NotBlank String tag){ +public record ConsumerDataEditInput(@NotBlank String tag, @NotNull String permission){ } diff --git a/src/main/java/com/pedro/sphynx/application/dtos/consumer/ConsumerDataInput.java b/src/main/java/com/pedro/sphynx/application/dtos/consumer/ConsumerDataInput.java index e3c358f..2c1c8ec 100644 --- a/src/main/java/com/pedro/sphynx/application/dtos/consumer/ConsumerDataInput.java +++ b/src/main/java/com/pedro/sphynx/application/dtos/consumer/ConsumerDataInput.java @@ -1,8 +1,10 @@ package com.pedro.sphynx.application.dtos.consumer; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; public record ConsumerDataInput( @NotBlank String ra, - @NotBlank String tag){ + @NotBlank String tag, + @NotNull int permission){ } diff --git a/src/main/java/com/pedro/sphynx/infrastructure/entities/Consumer.java b/src/main/java/com/pedro/sphynx/infrastructure/entities/Consumer.java index e4cb6b8..3321627 100644 --- a/src/main/java/com/pedro/sphynx/infrastructure/entities/Consumer.java +++ b/src/main/java/com/pedro/sphynx/infrastructure/entities/Consumer.java @@ -24,6 +24,7 @@ public class Consumer { private Person person; private String tag; + private int permission; private LocalDateTime dtcreate; private LocalDateTime dtupdate; @@ -32,5 +33,10 @@ public void actualizeData(ConsumerDataEditInput data) { this.tag = data.tag(); this.dtupdate = LocalDateTime.now(); } + + if(data.permission() != null){ + this.tag = data.tag(); + this.dtupdate = LocalDateTime.now(); + } } } diff --git a/src/main/resources/db/migration/V10__alter-table-consumers-add-permission.sql b/src/main/resources/db/migration/V10__alter-table-consumers-add-permission.sql new file mode 100644 index 0000000..9433796 --- /dev/null +++ b/src/main/resources/db/migration/V10__alter-table-consumers-add-permission.sql @@ -0,0 +1 @@ +alter table consumers add permission int; \ No newline at end of file