Skip to content

Commit ab0cfa2

Browse files
committed
Hackster refactoring
1 parent 4d72cff commit ab0cfa2

15 files changed

Lines changed: 94 additions & 53 deletions

File tree

config-server/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<groupId>org.springframework.boot</groupId>
3131
<artifactId>spring-boot-starter-actuator</artifactId>
3232
</dependency>
33+
3334
<dependency>
3435
<groupId>org.springframework.cloud</groupId>
3536
<artifactId>spring-cloud-config-server</artifactId>
@@ -40,6 +41,11 @@
4041
<artifactId>spring-boot-starter-test</artifactId>
4142
<scope>test</scope>
4243
</dependency>
44+
45+
<dependency>
46+
<groupId>org.springframework.cloud</groupId>
47+
<artifactId>spring-cloud-starter-eureka</artifactId>
48+
</dependency>
4349
</dependencies>
4450

4551
<dependencyManagement>

config-server/src/main/java/com/lohika/jclub/ConfigserverApplication.java renamed to config-server/src/main/java/com/lohika/jclub/ConfigServerApplication.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
56
import org.springframework.cloud.config.server.EnableConfigServer;
67

8+
@EnableDiscoveryClient
79
@SpringBootApplication
810
@EnableConfigServer
9-
public class ConfigserverApplication {
10-
11-
public static void main(String[] args) {
12-
SpringApplication.run(ConfigserverApplication.class, args);
13-
}
11+
public class ConfigServerApplication {
12+
public static void main(String[] args) {
13+
SpringApplication.run(ConfigServerApplication.class, args);
14+
}
1415
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
spring.cloud.config.server.git.uri=${JAVA_CLUB_SRC_HOME}/spring-cloud
22
spring.cloud.config.server.git.search-paths=config
3-
server.port=8888
3+
4+
spring.cloud.config.discovery.enabled=true
5+
spring.application.name=config-server
6+
7+
server.port=8888

config-server/src/test/java/com/lohika/jclub/ConfigserverApplicationTests.java renamed to config-server/src/test/java/com/lohika/jclub/ConfigServerApplicationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@RunWith(SpringRunner.class)
99
@SpringBootTest
10-
public class ConfigserverApplicationTests {
10+
public class ConfigServerApplicationTests {
1111

1212
@Test
1313
public void contextLoads() {

config/hackster-service.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
maxAllowedApartmentsPerRealtor=5

config/rating-service.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
rate=10
2+
maxAllowedApartmentsPerRealtor=5

discovery-server/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ spring.application.name=eureka-server
22
server.port=8761
33

44
eureka.client.register-with-eureka=false
5-
eureka.client.fetch-registry=false
5+
eureka.client.fetch-registry=false

hackster-service/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,17 @@
3939
<groupId>org.springframework.boot</groupId>
4040
<artifactId>spring-boot-starter-data-jpa</artifactId>
4141
</dependency>
42+
4243
<dependency>
4344
<groupId>org.springframework.cloud</groupId>
4445
<artifactId>spring-cloud-starter-eureka</artifactId>
4546
</dependency>
4647

48+
<dependency>
49+
<groupId>org.springframework.cloud</groupId>
50+
<artifactId>spring-cloud-starter-config</artifactId>
51+
</dependency>
52+
4753
<dependency>
4854
<groupId>com.h2database</groupId>
4955
<artifactId>h2</artifactId>
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
package com.lohika.jclub;
22

3+
import javax.persistence.Entity;
4+
import javax.persistence.GeneratedValue;
5+
import javax.persistence.Id;
6+
37
import lombok.Data;
48
import lombok.NoArgsConstructor;
59
import lombok.NonNull;
610
import lombok.RequiredArgsConstructor;
711

8-
import javax.persistence.Entity;
9-
import javax.persistence.GeneratedValue;
10-
import javax.persistence.Id;
11-
12-
/**
13-
* @author Andriy Levchenko
14-
*/
1512
@Data
1613
@NoArgsConstructor
1714
@RequiredArgsConstructor
1815
@Entity
1916
public class Hackster {
20-
@Id @GeneratedValue
17+
@Id
18+
@GeneratedValue
2119
private long id;
2220

2321
@NonNull
2422
private String phone;
23+
24+
@NonNull
25+
private int numberOfApartments;
2526
}

hackster-service/src/main/java/com/lohika/jclub/HacksterController.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@
66
import org.springframework.web.bind.annotation.RequestMapping;
77
import org.springframework.web.bind.annotation.RestController;
88

9-
/**
10-
* @author Andriy Levchenko
11-
*/
129
@RestController
1310
@RequestMapping(path = "/hackster")
1411
public class HacksterController {
1512

1613
@Autowired
17-
private HacksterRepository hacksterRepository;
14+
private HacksterService hacksterService;
1815

16+
/**
17+
* Check if current number correspond to hackster Rrealtor.
18+
*
19+
* @param phone Realtor phone number.
20+
* @return Is current number correspond to hackster realtor.
21+
*/
1922
@GetMapping(path = "/{phone}")
2023
public boolean isHackster(@PathVariable(name = "phone") String phone) {
21-
return hacksterRepository.findByPhone(phone).isPresent();
24+
return hacksterService.isHackster(phone);
2225
}
2326
}

0 commit comments

Comments
 (0)