#14 J-N000

Open
J-N000 wants to merge 1 commits from J-N000/ZCW-SpringZero:master into master

+ 11
- 0
initial/src/main/java/hello/App.java View File

@@ -0,0 +1,11 @@
1
+package hello;
2
+
3
+import org.springframework.boot.SpringApplication;
4
+import org.springframework.boot.autoconfigure.SpringBootApplication;
5
+
6
+@SpringBootApplication
7
+public class App {
8
+    public static void main(String[] args) {
9
+        SpringApplication.run(App.class, args);
10
+    }
11
+}

+ 19
- 0
initial/src/main/java/hello/Greeting.java View File

@@ -0,0 +1,19 @@
1
+package hello;
2
+
3
+public class Greeting {
4
+    private final long id;
5
+    private final String content;
6
+
7
+    public Greeting(long id, String content) {
8
+        this.id = id;
9
+        this.content = content;
10
+    }
11
+
12
+    public long getId() {
13
+        return id;
14
+    }
15
+
16
+    public String getContent() {
17
+        return content;
18
+    }
19
+}

+ 19
- 0
initial/src/main/java/hello/GreetingController.java View File

@@ -0,0 +1,19 @@
1
+package hello;
2
+
3
+import java.util.concurrent.atomic.AtomicLong;
4
+import org.springframework.web.bind.annotation.RequestMapping;
5
+import org.springframework.web.bind.annotation.RequestParam;
6
+import org.springframework.web.bind.annotation.RestController;
7
+
8
+@RestController
9
+public class GreetingController {
10
+    private static final String template = "Hello, %s!";
11
+    private final AtomicLong counter = new AtomicLong();
12
+
13
+    @RequestMapping("/greeting")
14
+    public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
15
+        return new Greeting(counter.incrementAndGet(),
16
+                String.format(template, name));
17
+    }
18
+}
19
+