From afd48943a09f2a59e6ce813b3cf4f88b0a0b6417 Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Tue, 30 Apr 2024 14:51:24 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=20?= =?UTF-8?q?=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D0=B0=20clients?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 + .../clients/api/ClientsController.java | 34 +++++----- .../autoservice/clients/api/ClientsDto.java | 30 ++++----- src/main/resources/public/css/style.css | 67 +++++++++++++++++++ src/main/resources/public/favicon.svg | 3 + src/main/resources/templates/clients.html | 36 ++++++++++ src/main/resources/templates/error.html | 11 --- src/main/resources/templates/index.html | 2 +- src/main/resources/templates/page1.html | 31 --------- 9 files changed, 140 insertions(+), 75 deletions(-) create mode 100644 src/main/resources/public/css/style.css create mode 100644 src/main/resources/public/favicon.svg create mode 100644 src/main/resources/templates/clients.html delete mode 100644 src/main/resources/templates/error.html delete mode 100644 src/main/resources/templates/page1.html diff --git a/build.gradle b/build.gradle index c099ac0..a86ea19 100644 --- a/build.gradle +++ b/build.gradle @@ -35,6 +35,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-devtools' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' + implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:3.3.0' implementation 'org.postgresql:postgresql' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' diff --git a/src/main/java/com/example/autoservice/clients/api/ClientsController.java b/src/main/java/com/example/autoservice/clients/api/ClientsController.java index a4180ad..593a6f0 100644 --- a/src/main/java/com/example/autoservice/clients/api/ClientsController.java +++ b/src/main/java/com/example/autoservice/clients/api/ClientsController.java @@ -3,6 +3,7 @@ package com.example.autoservice.clients.api; import java.util.List; import org.modelmapper.ModelMapper; +import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -11,18 +12,17 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.example.autoservice.core.configuration.Constants; import com.example.autoservice.clients.service.ClientsService; import com.example.autoservice.clients.model.ClientsEntity; import jakarta.validation.Valid; -@RestController -@RequestMapping(Constants.API_URL + "/clients") +@Controller +@RequestMapping(ClientsController.URL) public class ClientsController { + public static final String URL = "/clients"; + private static final String CLIENTS_VIEW = "clients"; private final ClientsService clientsService; private final ModelMapper modelMapper; @@ -38,20 +38,20 @@ public class ClientsController { private ClientsEntity toEntity(ClientsDto dto) { return modelMapper.map(dto, ClientsEntity.class); } - @GetMapping("/page1") - public String handlePage1(){ - return "page1"; + @GetMapping() + public String getAll(Model model){ + List lines = clientsService.getAll().stream() + .map(this::toDto) + .toList(); + model.addAttribute("clients", + lines); + return CLIENTS_VIEW; } - @GetMapping("/error") - public String handleError() { - return "error"; - } - - @GetMapping - public List getAll() { - return clientsService.getAll().stream().map(this::toDto).toList(); - } + // @GetMapping + // public List getAll() { + // return clientsService.getAll().stream().map(this::toDto).toList(); + // } @GetMapping("/{id}") public ClientsDto get(@PathVariable(name = "id") Long id) { diff --git a/src/main/java/com/example/autoservice/clients/api/ClientsDto.java b/src/main/java/com/example/autoservice/clients/api/ClientsDto.java index 366620f..57089ee 100644 --- a/src/main/java/com/example/autoservice/clients/api/ClientsDto.java +++ b/src/main/java/com/example/autoservice/clients/api/ClientsDto.java @@ -26,43 +26,43 @@ public class ClientsDto{ this.id = id; } - public String getFirst_Name(){ + public String getFirst_name(){ return first_name; } - public void setFirst_Name(String first_name){ - this.first_name = first_name; + public void setFirst_name(String firstname){ + this.first_name = firstname; } - public String getLast_Name(){ + public String getLast_name(){ return last_name; } - public void setLast_Name(String last_name){ - this.last_name = last_name; + public void setLast_name(String lastname){ + this.last_name = lastname; } - public String getMiddle_Name(){ + public String getMiddle_name(){ return middle_name; } - public void setMiddle_Name(String middle_name){ - this.middle_name = middle_name; + public void setMiddle_name(String middlename){ + this.middle_name = middlename; } - public Date getDate_Birthday(){ + public Date getDate_birthday(){ return date_birthday; } - public void setDate_Birthday(Date date_birthday){ - this.date_birthday = date_birthday; + public void setDate_birthday(Date datebirthday){ + this.date_birthday = datebirthday; } - public String getPhone_Number(){ + public String getPhone_number(){ return phone_number; } - public void setPhone_Number(String phone_number){ - this.phone_number = phone_number; + public void setPhone_number(String phonenumber){ + this.phone_number = phonenumber; } } \ No newline at end of file diff --git a/src/main/resources/public/css/style.css b/src/main/resources/public/css/style.css new file mode 100644 index 0000000..3891f75 --- /dev/null +++ b/src/main/resources/public/css/style.css @@ -0,0 +1,67 @@ +html, +body { + height: 100%; +} + +h1 { + font-size: 1.5em; +} + +h2 { + font-size: 1.25em; +} + +h3 { + font-size: 1.1em; +} + +td form { + margin: 0; + padding: 0; + margin-top: -.25em; +} + +.button-fixed-width { + width: 150px; +} + +.button-link { + padding: 0; +} + +.invalid-feedback { + display: block; +} + +.w-10 { + width: 10% !important; +} + +.my-navbar { + background-color: #3c3c3c !important; +} + +.my-navbar .link a:hover { + text-decoration: underline; +} + +.my-navbar .logo { + width: 26px; + height: 26px; +} + +.my-footer { + background-color: #2c2c2c; + height: 32px; + color: rgba(255, 255, 255, 0.5); +} + +.cart-image { + width: 3.1rem; + padding: 0.25rem; + border-radius: 0.5rem; +} + +.cart-item { + height: auto; +} \ No newline at end of file diff --git a/src/main/resources/public/favicon.svg b/src/main/resources/public/favicon.svg new file mode 100644 index 0000000..6ca0546 --- /dev/null +++ b/src/main/resources/public/favicon.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/main/resources/templates/clients.html b/src/main/resources/templates/clients.html new file mode 100644 index 0000000..6d56843 --- /dev/null +++ b/src/main/resources/templates/clients.html @@ -0,0 +1,36 @@ + + + + Getting Started: Serving Web Content + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
IDFirst NameLast NameMiddle NameDate of BirthPhone Number
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html deleted file mode 100644 index dd7255e..0000000 --- a/src/main/resources/templates/error.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - Error - - - -

Error

-

An unexpected error occurred. Please try again later.

- - diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index d2e2851..00c3033 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -5,6 +5,6 @@ -

Get your clients here

+

Get your clients here

\ No newline at end of file diff --git a/src/main/resources/templates/page1.html b/src/main/resources/templates/page1.html deleted file mode 100644 index b8476fd..0000000 --- a/src/main/resources/templates/page1.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - Getting Started: Serving Web Content - - - - - - - - - - - - - - - - - - - - - - - - -
IDFirst NameLast NameMiddle NameDate of BirthPhone Number
- - \ No newline at end of file