#16 alizalang

Aberto
alizalang quer mesclar 1 commits de alizalang/ZCW-SpringZero:master em master

+ 12
- 0
initial/src/main/java/hello/Application.java Ver arquivo

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

+ 20
- 0
initial/src/main/java/hello/Greeting.java Ver arquivo

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

+ 19
- 0
initial/src/main/java/hello/GreetingController.java Ver arquivo

@@ -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
+
11
+    private static final String template = "Hello, %s!";
12
+    private final AtomicLong counter = new AtomicLong();
13
+
14
+    @RequestMapping("/greeting")
15
+    public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
16
+        return new Greeting(counter.incrementAndGet(),
17
+                String.format(template, name));
18
+    }
19
+}