Skip to content

Commit

Permalink
feat: adding permission propertie in local entity
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroVidalDev committed Apr 22, 2024
1 parent 7e2a7dc commit 2edc743
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.pedro.sphynx.application.dtos.local;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

public record LocalDataInput(
@NotBlank String name,
@NotBlank String mac) {
@NotBlank String mac,
@NotNull int permission) {
}
4 changes: 4 additions & 0 deletions src/main/java/com/pedro/sphynx/domain/LocalService.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public LocalDataComplete createVerify(LocalDataInput data, String language){
throw new Validation(messages.getString("error.macAlreadyExists"));
}

if(data.permission() > 4 || data.permission() < 1){
throw new Validation(messages.getString("error.permissionNotValid"));
}

else{
Local local = new Local(data);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ public class Local {

private String name;
private String mac;
private int permission;
private LocalDateTime dtcreate;
private LocalDateTime dtupdate;

public Local(LocalDataInput data){
this.name = data.name();
this.mac = data.mac();
this.permission = data.permission();
this.dtcreate = LocalDateTime.now();
this.dtupdate = null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table locals add permission int;
1 change: 1 addition & 0 deletions src/main/resources/messagesEn.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ error.tagDontExists=Informed TAG dont exists in database.
error.localDontExists=Informed local dont exists in database.
error.localAlreadyExists=Informed local name already exists in database.
error.macAlreadyExists=Informed MAC Address already exists in database.
error.permissionNotValid=Informed permission is not under 1 and 4.

success.201=Created.
success.200=Operation realized.
1 change: 1 addition & 0 deletions src/main/resources/messagesPt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ error.tagDontExists=TAG informada nao existe no banco.
error.localDontExists=Local informado nao existe no banco.
error.localAlreadyExists=Nome do local informado ja existe no banco de dados.
error.macAlreadyExists=MAC informado ja existe no banco de dados de locais.
error.permissionNotValid=Permissao informada nao esta entre 1 e 4.

success.201=Criado.
success.200=Operacao realizada.

0 comments on commit 2edc743

Please sign in to comment.