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