Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metodo para verificar se o setor corresponde ao tipo de produto. #54

Merged
merged 1 commit into from Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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
Expand Up @@ -57,7 +57,7 @@ public Representante buscarRepresentante(Integer codigo) {
}

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

}
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