Skip to content

Commit

Permalink
Changed dockerfile and added some logs
Browse files Browse the repository at this point in the history
  • Loading branch information
midhatdrops committed Jul 10, 2022
1 parent d483308 commit 84c6892
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 3 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
# Experian Challenge
# Experian Challenge

#### Essa é minha solução para o desafio proposto, foram colocadas as seguintes tecnologias no projeto:

- Spring Data JPA
- Spring Web
- Hibernate Validator
- Spring Actuator
- Lombok
- H2

> O projeto pode ser utilizado localmente através do profile "local" ou então através do Dockerfile,
> sendo necessário configurar, nesse último caso, as variáveis de ambiente dispostas no application.yml
>
1 change: 1 addition & 0 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ RUN mvn -f /home/app/pom.xml clean package -DskipTests -q
FROM openjdk:11-jre-slim
COPY --from=build /home/app/target/experianChallenge-0.0.1-SNAPSHOT.jar /usr/local/lib/demo.jar
EXPOSE 8080
ENV DATABASE_URL="jdbc:h2:mem:mydb" DATABASE_USERNAME="sa" DATABASE_PASSWORD="password"
ENTRYPOINT ["java","-jar","/usr/local/lib/demo.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ public Atuacao(AtuacaoRequestDTO requestDTO) {
this.region = requestDTO.getRegiao();
this.states = requestDTO.getEstados();
}

@Override
public String toString() {
return "Atuacao{" +
"region='" + region + '\'' +
", states=" + states +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import br.com.midhatdrops.experianChallenge.domain.atuacao.infrasctructure.dto.AtuacaoResponseDTO;
import br.com.midhatdrops.experianChallenge.domain.atuacao.infrasctructure.repository.AtuacaoRepository;
import br.com.midhatdrops.experianChallenge.domain.atuacao.service.AtuacaoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class AtuacaoServiceImpl implements AtuacaoService {

@Autowired
Expand All @@ -18,7 +20,9 @@ public class AtuacaoServiceImpl implements AtuacaoService {

@CacheEvict(value = "vendedors",allEntries = true)
public AtuacaoResponseDTO insert(AtuacaoRequestDTO requestDTO) {
Atuacao save = repository.save(new Atuacao(requestDTO));
final Atuacao atuacao = new Atuacao(requestDTO);
log.info("Atuacao will be saved!" + atuacao);
Atuacao save = repository.save(atuacao);
return AtuacaoResponseDTO.builder()
.estados(save.getStates())
.regiao(save.getRegion())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,19 @@ private boolean validateCellphone(String cellphone) {
return cellphone.matches("[0-9]{2}[9][0-9]{4,11}") && cellphone.length() == 11;
}


@Override
public String toString() {
String[] split = name.split("\\s");
return "Vendedor{" +
"id=" + id +
", First name='" + split[0] + '\'' +
", cellphone 4-digits='" + cellphone.substring(0,4) + '\'' +
", age=" + age +
", city='" + city + '\'' +
", state=" + state +
", region='" + region + '\'' +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class VendedorServiceImpl implements VendedorService {
public VendedorRequestDTO insert(VendedorRequestDTO requestDTO) {
try {
final Vendedor vendedor = new Vendedor(requestDTO);
log.info("Vendedor wil be saved! " + vendedor);
final Vendedor savedEntity = repository.save(vendedor);
return new VendedorRequestDTO(savedEntity);
} catch (MalformedCellphoneException malformedCellphoneException) {
Expand Down

0 comments on commit 84c6892

Please sign in to comment.