Fixed demo-query
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<properties>
|
||||
<java.version>8</java.version>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -45,7 +45,6 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -65,14 +64,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package es.dbiosag.command.application.dto;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@Builder
|
||||
public class CreatePhoneRequest {
|
||||
|
||||
private String name;
|
||||
|
||||
@@ -2,13 +2,12 @@ package es.dbiosag.command.domain.model;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "PHONES")
|
||||
@Builder
|
||||
public class Phone {
|
||||
|
||||
@Id
|
||||
|
||||
@@ -2,6 +2,8 @@ package es.dbiosag.command.infrasturcture.repository;
|
||||
|
||||
import es.dbiosag.command.domain.model.Phone;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PhoneRepository extends CrudRepository<Phone, Integer> {
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<properties>
|
||||
<java.version>8</java.version>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -72,14 +72,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package es.dbiosag.query.domain.service;
|
||||
|
||||
import es.dbiosag.query.application.dto.PhoneResponse;
|
||||
import es.dbiosag.query.application.exception.FindPhoneException;
|
||||
import es.dbiosag.query.domain.converter.PhoneConverter;
|
||||
import es.dbiosag.query.domain.exception.PhoneNotFoundException;
|
||||
import es.dbiosag.query.domain.model.Phone;
|
||||
import es.dbiosag.query.infrastructure.repository.PhoneRepository;
|
||||
import lombok.extern.java.Log;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -24,7 +22,7 @@ public class FindPhoneService {
|
||||
|
||||
public PhoneResponse findByName(String name) throws PhoneNotFoundException {
|
||||
Optional<Phone> phone = phoneRepository.findByName(name);
|
||||
if(phone.isEmpty()) {
|
||||
if(phone.isPresent()) {
|
||||
throw new PhoneNotFoundException(name, "Phone not found");
|
||||
}
|
||||
log.info("Find phone: {}", phone);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package es.dbiosag.query.infrastructure.configuration;
|
||||
|
||||
public class KafkaTopicConfig {
|
||||
}
|
||||
@@ -2,9 +2,11 @@ package es.dbiosag.query.infrastructure.repository;
|
||||
|
||||
import es.dbiosag.query.domain.model.Phone;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface PhoneRepository extends CrudRepository<Phone, Integer> {
|
||||
|
||||
Optional<Phone> findByName(String name);
|
||||
|
||||
@@ -31,3 +31,30 @@ services:
|
||||
- ./zk-single-kafka-single/kafka1/data:/var/lib/kafka/data
|
||||
depends_on:
|
||||
- zoo1
|
||||
|
||||
demo-command:
|
||||
image: demo-command
|
||||
hostname: demo-command
|
||||
ports:
|
||||
- "8081:8081"
|
||||
depends_on:
|
||||
- zoo1
|
||||
- kafka1
|
||||
|
||||
demo-query-1:
|
||||
image: demo-query
|
||||
hostname: demo-command
|
||||
ports:
|
||||
- "8082:8082"
|
||||
depends_on:
|
||||
- zoo1
|
||||
- kafka1
|
||||
|
||||
demo-query-2:
|
||||
image: demo-query
|
||||
hostname: demo-command
|
||||
ports:
|
||||
- "8082:8082"
|
||||
depends_on:
|
||||
- zoo1
|
||||
- kafka1
|
||||
Reference in New Issue
Block a user