Untitled

 avatar
unknown
java
2 years ago
2.3 kB
6
Indexable
package br.gov.ce.seduc.transporteseduc.domain.service.Implement;

import br.gov.ce.seduc.transporteseduc.dao.mappers.postgres.MotoristaTransporteMapper;
import br.gov.ce.seduc.transporteseduc.domain.dto.MotoristaTransporteDTO;
import br.gov.ce.seduc.transporteseduc.domain.service.MotoristaTransporteService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;


@Service
@RequiredArgsConstructor
public class MotoristaTransporteImplement implements MotoristaTransporteService {

    //consulta dos dados do motorista
    private final MotoristaTransporteMapper motoristaTransporteMapper;
    
    private final MotoristaMapper motoristaMapper;

    @Override
    public List<MotoristaTransporteDTO> motoristaTransporte(@RequestParam(value = "cpfMotorista", required = false) String cpfMotorista,
                                                            @RequestParam(value = "nomeMotorista", required = false) String nomeMotorista,
                                                            @RequestParam(value = "habilitacaoMotorista", required = false) Integer habilitacaoMotorista)
    {
         List<MotoristaTransporteDTO> resultado = motoristaTransporteMapper.motoristaTransporte(cpfMotorista, nomeMotorista, habilitacaoMotorista);
         Motorista motorista = new Motorista();
         motorista.setCpf(cpfMotorista);
         //... preenche todos os dados que o motorista precisa pra salvar no banco
         
         motoristaMapper.insert(motorista);
         return resultado;
    }


    //inserção do motorista
    @Override
    public void createMotoristaTransporte(MotoristaTransporteDTO motoristaTransporteDTO) {
        motoristaTransporteMapper.createMotoristaTransporte(motoristaTransporteDTO);
    }


    //atualização do motorista
    @Override
    public void updateMotoristaTransporte(MotoristaTransporteDTO motoristaTransporteDTO) {
        motoristaTransporteMapper.updateMotoristaTransporte(motoristaTransporteDTO);
    }


    //deleção do motorista por cpf
    @Override
    public void deleteMotoristaTransporte(String cpfMotorista) {
        motoristaTransporteMapper.deleteMotoristaTransporte(cpfMotorista);
    }

}
Editor is loading...