Skip to content

Commit 7642dc1

Browse files
committed
can be reset if required
1 parent 194a1ed commit 7642dc1

File tree

7 files changed

+90
-272
lines changed

7 files changed

+90
-272
lines changed

SringBoot-Projects/department-service/department-api/src/main/java/com/department/api/models/Department.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
package com.department.api.models;
2-
32
import com.fasterxml.jackson.annotation.JsonProperty;
43
import lombok.AllArgsConstructor;
54
import lombok.Data;
@@ -33,18 +32,4 @@ public class Department {
3332
@JsonProperty("capacity")
3433
private int capacity;
3534

36-
// @Value.Immutable
37-
// @Value.Style(
38-
// strictBuilder = true,
39-
// jdkOnly = true
40-
// // builder = "new"
41-
// )
42-
// public static interface Department {
43-
// UUID getId();
44-
//
45-
// String getDepartmentName();
46-
//
47-
// int getCapacity();
48-
//
49-
// }
5035
}

SringBoot-Projects/department-service/department-web/src/main/java/com/saurabh/departmentweb/DepartmentServiceApplication.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package com.saurabh.departmentweb;
22

3+
import com.saurabh.departmentweb.services.DepartmentService;
4+
import com.saurabh.departmentweb.services.DepartmentServiceImpl;
35
import org.springframework.boot.SpringApplication;
46
import org.springframework.boot.autoconfigure.SpringBootApplication;
57
import org.springframework.boot.autoconfigure.domain.EntityScan;
68
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
9+
import org.springframework.context.annotation.Bean;
710

811
@EnableDiscoveryClient
912
@SpringBootApplication
@@ -14,4 +17,9 @@ public static void main(String[] args) {
1417
SpringApplication.run(DepartmentServiceApplication.class, args);
1518
}
1619

20+
@Bean
21+
DepartmentService getDepatment(){
22+
return new DepartmentServiceImpl(null);
23+
}
24+
1725
}

SringBoot-Projects/department-service/department-web/src/main/java/com/saurabh/departmentweb/services/DepartmentServiceImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.util.Optional;
99
import java.util.UUID;
1010

11-
@Service
1211
public class DepartmentServiceImpl implements DepartmentService {
1312

1413
private final DepartmentRepository departmentRepository;

sample-rest-app/.idea/compiler.xml

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample-rest-app/.idea/encodings.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample-rest-app/.idea/workspace.xml

Lines changed: 26 additions & 212 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package com.saurabh.restsample.resources;
22

33
import com.saurabh.lib.model.Calculation;
4-
import org.springframework.web.bind.annotation.*;
4+
import org.springframework.web.bind.annotation.GetMapping;
5+
import org.springframework.web.bind.annotation.PathVariable;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.bind.annotation.RequestParam;
8+
import org.springframework.web.bind.annotation.RestController;
59

610
import java.util.ArrayList;
711
import java.util.List;
@@ -13,45 +17,46 @@
1317
@RequestMapping("calculation")
1418
public class CalculationController {
1519

16-
private static final String PATTERN = "^-?+\\d+\\.?+\\d*$";
17-
18-
19-
/**
20-
* “@RequestParam is responsible for binding the query parameter to the parameter of the controller's method. ”
21-
* @param b
22-
* @param e
23-
* @return
24-
*/
25-
@GetMapping("/power")
26-
public Calculation pow(@RequestParam(value = "base") String b,
27-
@RequestParam(value = "exponent", defaultValue = "3") String e) {
28-
List<String> input = new ArrayList<>();
29-
input.add(b);
30-
input.add(e);
31-
List<String> output = new ArrayList<>();
32-
String powValue;
33-
if (b != null && e != null && b.matches(PATTERN) && e.matches(PATTERN)) {
34-
powValue = String.valueOf(Math.pow(Double.valueOf(b), Double.valueOf(e)));
35-
} else {
36-
powValue = "Base or/and Exponent is/are not set to numeric value.";
37-
}
38-
output.add(powValue);
39-
return new Calculation(input, output, "power");
40-
}
41-
42-
43-
@RequestMapping(value = "/sqrt/{value:.+}", method = GET)
44-
public Calculation sqrt(@PathVariable(value = "value") String aValue) {
45-
List<String> input = new ArrayList<>();
46-
input.add(aValue);
47-
List<String> output = new ArrayList<>();
48-
String sqrtValue;
49-
if (aValue != null && aValue.matches(PATTERN)) {
50-
sqrtValue = String.valueOf(Math.sqrt(Double.valueOf(aValue)));
51-
} else {
52-
sqrtValue = "Input value is not set to numeric value.";
53-
}
54-
output.add(sqrtValue);
55-
return new Calculation(input, output, "sqrt");
56-
}
20+
private static final String PATTERN = "^-?+\\d+\\.?+\\d*$";
21+
22+
/**
23+
* “@RequestParam is responsible for binding the query parameter to the parameter of the controller's method. ”
24+
*
25+
* @param b
26+
* @param e
27+
*
28+
* @return
29+
*/
30+
@GetMapping("/power")
31+
public Calculation pow(@RequestParam(value = "base") String b,
32+
@RequestParam(value = "exponent", defaultValue = "3") String e) {
33+
List<String> input = new ArrayList<>();
34+
input.add(b);
35+
input.add(e);
36+
List<String> output = new ArrayList<>();
37+
String powValue;
38+
if (b != null && e != null && b.matches(PATTERN) && e.matches(PATTERN)) {
39+
powValue = String.valueOf(Math.pow(Double.parseDouble(b), Double.parseDouble(e)));
40+
} else {
41+
powValue = "Base or/and Exponent is/are not set to numeric value.";
42+
}
43+
output.add(powValue);
44+
return new Calculation(input, output, "power");
45+
}
46+
47+
48+
@RequestMapping(value = "/sqrt/{value:.+}", method = GET)
49+
public Calculation sqrt(@PathVariable(value = "value") String aValue) {
50+
List<String> input = new ArrayList<>();
51+
input.add(aValue);
52+
List<String> output = new ArrayList<>();
53+
String sqrtValue;
54+
if (aValue != null && aValue.matches(PATTERN)) {
55+
sqrtValue = String.valueOf(Math.sqrt(Double.parseDouble(aValue)));
56+
} else {
57+
sqrtValue = "Input value is not set to numeric value.";
58+
}
59+
output.add(sqrtValue);
60+
return new Calculation(input, output, "sqrt");
61+
}
5762
}

0 commit comments

Comments
 (0)