From 7e29dca76901303152afce595b3a382adb88e5b2 Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Tue, 23 Jun 2020 20:45:36 +0700 Subject: [PATCH] Add thymleaf view and testing it --- build.gradle | 2 ++ .../demo/repository/UserRepository.java | 1 - .../com/cubetiqs/demo/ui/HomeController.java | 20 +++++++++++++++++++ src/main/resources/static/js/main.js | 1 + .../templates/admin/users/index.html | 13 ++++++++++++ src/main/resources/templates/index.html | 13 ++++++++++++ 6 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/cubetiqs/demo/ui/HomeController.java create mode 100644 src/main/resources/static/js/main.js create mode 100644 src/main/resources/templates/admin/users/index.html create mode 100644 src/main/resources/templates/index.html diff --git a/build.gradle b/build.gradle index 33edf20..54bb6e5 100644 --- a/build.gradle +++ b/build.gradle @@ -13,6 +13,8 @@ repositories { } dependencies { + implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'io.springfox:springfox-swagger2:2.9.2' diff --git a/src/main/java/com/cubetiqs/demo/repository/UserRepository.java b/src/main/java/com/cubetiqs/demo/repository/UserRepository.java index 5b22941..edb3fce 100644 --- a/src/main/java/com/cubetiqs/demo/repository/UserRepository.java +++ b/src/main/java/com/cubetiqs/demo/repository/UserRepository.java @@ -8,7 +8,6 @@ import org.springframework.stereotype.Repository; import java.util.Optional; -@SuppressWarnings("ALL") @Repository public interface UserRepository extends BaseRepository { Optional findFirstByEmail(String email); diff --git a/src/main/java/com/cubetiqs/demo/ui/HomeController.java b/src/main/java/com/cubetiqs/demo/ui/HomeController.java new file mode 100644 index 0000000..9dcb132 --- /dev/null +++ b/src/main/java/com/cubetiqs/demo/ui/HomeController.java @@ -0,0 +1,20 @@ +package com.cubetiqs.demo.ui; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class HomeController { + @GetMapping(value = {"/index", "", "/", "/index.php"}) + public String index(Model model) { + model.addAttribute("myname", "Sambo"); + return "index"; + } + + @GetMapping(value = {"/admin/users"}) + public String user(Model model) { + model.addAttribute("myname", "Sambo"); + return "admin/users/index"; + } +} diff --git a/src/main/resources/static/js/main.js b/src/main/resources/static/js/main.js new file mode 100644 index 0000000..5be36cc --- /dev/null +++ b/src/main/resources/static/js/main.js @@ -0,0 +1 @@ +console.log("hello") \ No newline at end of file diff --git a/src/main/resources/templates/admin/users/index.html b/src/main/resources/templates/admin/users/index.html new file mode 100644 index 0000000..f3e0085 --- /dev/null +++ b/src/main/resources/templates/admin/users/index.html @@ -0,0 +1,13 @@ + + + + + + + Document + + +

Users

+ + \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html new file mode 100644 index 0000000..124d36e --- /dev/null +++ b/src/main/resources/templates/index.html @@ -0,0 +1,13 @@ + + + + + + + Index + + +

+ + \ No newline at end of file