From 1d05064b590d119065495a6d9ce30ae2d4aab05d Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Wed, 16 Mar 2022 09:17:37 +0330 Subject: wip --- .../com/terminaldweller/doc/DocController.java | 24 ++++++++++++++++++++++ .../java/com/terminaldweller/doc/DocService.java | 12 +++++++++++ .../com/terminaldweller/main/MainApplication.java | 10 ++++----- src/main/resources/application.properties | 7 +++++++ 4 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/terminaldweller/doc/DocController.java create mode 100644 src/main/java/com/terminaldweller/doc/DocService.java create mode 100644 src/main/resources/application.properties (limited to 'src') diff --git a/src/main/java/com/terminaldweller/doc/DocController.java b/src/main/java/com/terminaldweller/doc/DocController.java new file mode 100644 index 0000000..564f37c --- /dev/null +++ b/src/main/java/com/terminaldweller/doc/DocController.java @@ -0,0 +1,24 @@ +package com.terminaldweller.doc; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** The document controller class. */ +@RestController +@RequestMapping(path = "api/v1/doc") +public class DocController { + private final DocService docService; + + @Autowired + public DocController(DocService docService) { + this.docService = docService; + } + + @GetMapping + public List getDocs() { + return docService.getDocs(); + } +} diff --git a/src/main/java/com/terminaldweller/doc/DocService.java b/src/main/java/com/terminaldweller/doc/DocService.java new file mode 100644 index 0000000..4aee30b --- /dev/null +++ b/src/main/java/com/terminaldweller/doc/DocService.java @@ -0,0 +1,12 @@ +package com.terminaldweller.doc; + +import java.util.List; +import org.springframework.stereotype.Service; + +/** The document service class. */ +@Service +public class DocService { + public List getDocs() { + return List.of(new Doc(1L, "loco", 0L)); + } +} diff --git a/src/main/java/com/terminaldweller/main/MainApplication.java b/src/main/java/com/terminaldweller/main/MainApplication.java index c577139..146dbcf 100644 --- a/src/main/java/com/terminaldweller/main/MainApplication.java +++ b/src/main/java/com/terminaldweller/main/MainApplication.java @@ -9,11 +9,6 @@ import org.springframework.web.bind.annotation.RestController; @SpringBootApplication @RestController public class MainApplication { - @RequestMapping("/") - public String home() { - return "Hello Docker World"; - } - /** * just a dummy main. * @@ -22,4 +17,9 @@ public class MainApplication { public static void main(String[] args) { SpringApplication.run(MainApplication.class, args); } + + @RequestMapping("/") + public String home() { + return "Hello Docker World"; + } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..547f233 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,7 @@ +spring.datasource.url=jdbc:postgresql://postgres:5432 +spring.datasource.username= +spring.datasource.password= +spring.jpa.hibernate.ddl-auto=create-drop +spring.jpa.show-sql=true +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +spring.jpa.properties.hibernate.format_sql=true -- cgit v1.2.3