Skip to content

Commit

Permalink
Merge pull request #21 from Joaquimborges/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
hugaodamm committed Oct 26, 2021
2 parents 9c0d882 + 7428a63 commit 22da562
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public ResponseEntity<RepresentanteDTO> salvar(@RequestBody RepresentanteForm re
return new ResponseEntity<>(RepresentanteDTO.converteEmRepresentanteDTO(representante), HttpStatus.CREATED);
}

@GetMapping("/obter/{id}")
public ResponseEntity<RepresentanteDTO> obter(@PathVariable Integer codigo) {
@GetMapping("/obter/{codigo}")
public ResponseEntity<RepresentanteDTO> obter(@PathVariable String codigo) {
Representante representante = representanteService.obter(codigo);
return new ResponseEntity<>(RepresentanteDTO.converteEmRepresentanteDTO(representante), HttpStatus.OK);
}
Expand All @@ -42,8 +42,8 @@ public ResponseEntity<RepresentanteDTO> alterar(@RequestBody RepresentanteForm r
return new ResponseEntity<>(RepresentanteDTO.converteEmRepresentanteDTO(representante), HttpStatus.OK);
}

@DeleteMapping("/apagar")
public ResponseEntity<RepresentanteDTO> apagar(@PathVariable Integer codigo){
@DeleteMapping("/apagar/{codigo}")
public ResponseEntity<RepresentanteDTO> apagar(@PathVariable String codigo){
Representante representante = representanteService.apagar(codigo);
return new ResponseEntity<>(RepresentanteDTO.converteEmRepresentanteDTO(representante), HttpStatus.ACCEPTED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ public ResponseEntity<VendedorDTO> salvar(@RequestBody VendedorForm vendedorForm
return new ResponseEntity<>(VendedorDTO.converter(vendedor), HttpStatus.CREATED);
}

@GetMapping("/obter/{id}")
public ResponseEntity<VendedorDTO> obter(@PathVariable Integer codigo){
Vendedor vendedor = vendedorService.obter(codigo);
@GetMapping("/obter/{codigo}")
public ResponseEntity<VendedorDTO> obter(@PathVariable String codigo){
Vendedor vendedor = vendedorService.obter(
codigo);
return new ResponseEntity<>(VendedorDTO.converter(vendedor), HttpStatus.OK);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
@Getter
public class VendedorDTO {

private Integer codigo;
private String codigo;
private String nome;
private String sobrenome;

public VendedorDTO(Integer codigo, String nome, String sobrenome) {
public VendedorDTO(String codigo, String nome, String sobrenome) {
this.codigo = codigo;
this.nome = nome;
this.sobrenome = sobrenome;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Representante buscarRepresentante(Integer codigo) {
}

public List<Setor> listarSetores() {
return setorService.listar();
return setorService.listarSetores();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import com.bootcamp_w3_g3.model.entity.Armazem;
import com.bootcamp_w3_g3.model.entity.Representante;
import com.bootcamp_w3_g3.model.entity.Setor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -45,6 +46,35 @@ private boolean validarArmazem(String codigoArmazem) {
return false;
}

/**
* @autor Alex Cruz
* metodo para verificar se o representante pertence ao armazem
*/
private boolean representantePertenceAoArmazem(String codigo){
for (Setor setor : setorService.listarSetores()){
if (setor.getArmazem().getRepresentante().getCodigo().equals(codigo)){
Representante representante = setor.getArmazem().getRepresentante();
return representante != null;
}
}
return false;
}

/**
* @autor JoaquimBorges
* metodo para verificar se o setor corresponde
* a categoria de produto que esta sendo enviado na ordem de entrada
*/

private boolean setorCorrespondeAoTipoDeProduto(String tipoDeProduto) {
for (Setor setor : setorService.listarSetores()) {
if (setor.getTipoProduto().equals(tipoDeProduto)) {
return true;
}
}
return false;
}




Expand Down

0 comments on commit 22da562

Please sign in to comment.