- Timestamp:
- 01/03/23 23:03:00 (23 months ago)
- Branches:
- main
- Children:
- 6832924
- Parents:
- feffc2f
- Location:
- src/main
- Files:
-
- 9 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/autopartz/controller/HomeController.java
rfeffc2f r60de3eb 2 2 3 3 import com.example.autopartz.model.User; 4 import com.example.autopartz.repository.PartsForCarTypeAndCategoryRepository; 5 import com.example.autopartz.service.CarService; 6 import com.example.autopartz.service.CategoryService; 4 7 import com.example.autopartz.service.LoginService; 5 8 import com.example.autopartz.service.PartService; … … 16 19 private final LoginService loginService; 17 20 private final PartService partService; 21 private final PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository; 22 private final CarService carService; 23 private final CategoryService categoryService; 18 24 19 public HomeController(LoginService loginService, PartService partService ) {25 public HomeController(LoginService loginService, PartService partService, PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository, CarService carService, CategoryService categoryService) { 20 26 this.loginService = loginService; 21 27 this.partService = partService; 28 this.partsForCarTypeAndCategoryRepository = partsForCarTypeAndCategoryRepository; 29 this.carService = carService; 30 this.categoryService = categoryService; 22 31 } 23 32 … … 25 34 public String getHomePage(Model model){ 26 35 model.addAttribute("parts",partService.findAll()); 27 return "homepage"; 36 model.addAttribute("cars",carService.findAll()); 37 model.addAttribute("categories",categoryService.findAll()); 38 model.addAttribute("bodyContent","homepage"); 39 return "master-template"; 40 } 41 @GetMapping("/filtered") 42 public String getPartsForCarTypeAndCategory(@RequestParam String cartype, @RequestParam String category, Model model){ 43 model.addAttribute("filtered", partsForCarTypeAndCategoryRepository.findAllByCartypeAndCategory(cartype,category)); 44 model.addAttribute("bodyContent","filteredParts"); 45 return "master-template"; 28 46 } 29 47 @GetMapping("/login") 30 public String getLoginPage(){ 31 return "login"; 48 public String getLoginPage(Model model){ 49 model.addAttribute("bodyContent","login"); 50 return "master-template"; 32 51 } 33 52 @GetMapping("/register") 34 public String getRegisterPage(){ 35 return "register"; 53 public String getRegisterPage(Model model){ 54 model.addAttribute("bodyContent","register"); 55 return "master-template"; 36 56 } 37 57 @PostMapping("/login") 38 58 public void handleLogin(@RequestParam String username, @RequestParam String password){ 39 59 User u = loginService.login(username,password); 60 System.out.println(u.getName_user()); 40 61 } 41 62 @PostMapping("/register") -
src/main/java/com/example/autopartz/controller/PartController.java
rfeffc2f r60de3eb 29 29 model.addAttribute("part",temp); 30 30 model.addAttribute("amount",amount); 31 return "partinfo"; 31 model.addAttribute("bodyContent","partinfo"); 32 return "master-template"; 32 33 } 33 34 @GetMapping("/delivery/{id}") … … 35 36 model.addAttribute("repairShops",repairShopService.findAll()); 36 37 model.addAttribute("partId",id); 37 return "deliveryForPart"; 38 model.addAttribute("bodyContent","deliveryForPart"); 39 return "master-template"; 38 40 } 39 41 @PostMapping("/repairshopdelivery") -
src/main/java/com/example/autopartz/controller/UserController.java
rfeffc2f r60de3eb 16 16 private final UserService userService; 17 17 private final RepairShopReviewSummaryRepository repairShopReviewSummaryRepository; 18 private final PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository;19 18 20 19 private final OrdersForUserRepository ordersForUserRepository; 21 20 private final RepairsForUserRepository repairsForUserRepository; 22 21 private final ReviewsForUserRepository reviewsForUserRepository; 23 public UserController(UserService userService, RepairShopReviewSummaryRepository repairShopReviewSummaryRepository, PartsForCarTypeAndCategoryRepository partsForCarTypeAndCategoryRepository,OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository) {22 public UserController(UserService userService, RepairShopReviewSummaryRepository repairShopReviewSummaryRepository, OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository) { 24 23 this.userService = userService; 25 24 this.repairShopReviewSummaryRepository = repairShopReviewSummaryRepository; 26 this.partsForCarTypeAndCategoryRepository = partsForCarTypeAndCategoryRepository;27 25 this.ordersForUserRepository = ordersForUserRepository; 28 26 this.repairsForUserRepository = repairsForUserRepository; … … 37 35 return userService.findAllUsers(); 38 36 } 39 @GetMapping("parts")40 public List<PartsForCarTypeAndCategory> getPartsForCarTypeAndCategory(@RequestParam String cartype, @RequestParam String category){41 return partsForCarTypeAndCategoryRepository.findAllByCartypeAndCategory(cartype,category);42 }43 37 @GetMapping("orders/{id}") 44 38 public String getOrdersForUser(@PathVariable Long id, Model model){ 45 39 model.addAttribute("userOrders",ordersForUserRepository.findAllByUserid(id)); 46 return "ordersForUser"; 40 model.addAttribute("bodyContent","ordersForUser"); 41 return "master-template"; 47 42 } 48 43 @GetMapping("repairs/{id}") 49 44 public String getRepairsForUser(@PathVariable Long id,Model model){ 50 45 model.addAttribute("userRepairs",repairsForUserRepository.findAllByUserid(id)); 51 return "repairsForUser"; 46 model.addAttribute("bodyContent","repairsForUser"); 47 return "master-template"; 52 48 } 53 49 @GetMapping("reviews/{id}") 54 50 public String getReviewsForUser(@PathVariable Long id, Model model){ 55 51 model.addAttribute("userReviews",reviewsForUserRepository.findAllByUserid(id)); 56 return "reviewsForUser"; 52 model.addAttribute("bodyContent","reviewsForUser"); 53 return "master-template"; 57 54 } 58 55 } -
src/main/java/com/example/autopartz/model/Car.java
rfeffc2f r60de3eb 18 18 Integer in_production_since; 19 19 Integer in_production_till; 20 String car_type; 20 @Column(name = "car_type") 21 String cartype; 21 22 @ManyToOne 22 23 @JoinColumn(name = "id_car_manufacturer") -
src/main/java/com/example/autopartz/model/Category.java
rfeffc2f r60de3eb 1 1 package com.example.autopartz.model; 2 2 3 import jakarta.persistence.Entity; 4 import jakarta.persistence.Id; 5 import jakarta.persistence.JoinColumn; 6 import jakarta.persistence.ManyToOne; 3 import jakarta.persistence.*; 7 4 import lombok.*; 8 5 import org.hibernate.Hibernate; … … 18 15 @Id 19 16 Long ID_category; 20 String category_name; 17 @Column(name = "category_name") 18 String cname; 21 19 @ManyToOne 22 20 @JoinColumn(name = "id_parent_category") -
src/main/java/com/example/autopartz/model/views/PartsForCarTypeAndCategory.java
rfeffc2f r60de3eb 25 25 String cartype; 26 26 String category; 27 String pmname; 27 28 } -
src/main/resources/templates/deliveryForPart.html
rfeffc2f r60de3eb 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Податоци за достава</title> 6 </head> 7 <body> 1 <div> 8 2 <header> 9 3 <h1>Податоци за достава</h1> … … 33 27 </main> 34 28 35 </body> 36 </html> 29 </div> -
src/main/resources/templates/homepage.html
rfeffc2f r60de3eb 1 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" 2 lang="en"> 3 <head> 4 <meta charset="utf-8"/> 5 <title>Почетна</title> 6 </head> 7 <body> 1 <div> 8 2 <header> 9 3 <a th:href="${'/orders/4'}">Мои нарачки</a> … … 13 7 <main> 14 8 <h1>Сите производи</h1> 9 <form th:action="@{/filtered}"> 10 <label for="cartype"></label><select id="cartype" required name="cartype"> 11 <option th:each="car : ${cars}" 12 th:text="${car.getCartype()}" 13 th:value="${car.getCartype()}"> 14 </option> 15 </select> 16 <label for="category"></label><select id="category" required name="category"> 17 <option th:each="cat : ${categories}" 18 th:text="${cat.getCname()}" 19 th:value="${cat.getCname()}"> 20 </option> 21 </select> 22 <button type="submit">Филтрирај</button> 23 </form> 15 24 <table> 16 25 <thead> 17 26 <tr> 18 27 <th>Name</th> 19 <th>Description</th>20 28 <th>Manufacturer</th> 21 29 <th>Details</th> … … 25 33 <tr th:each="part : ${parts}"> 26 34 <td th:text="${part.getName()}"></td> 27 <td th:text="${part.getDescription()}"></td>28 35 <td th:text="${part.getManufacturer().getName()}"></td> 29 36 <td> … … 36 43 </table> 37 44 </main> 38 </body> 39 </html> 45 </div> -
src/main/resources/templates/login.html
rfeffc2f r60de3eb 1 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" lang="en"> 2 <head> 3 <title>Најава</title> 4 <!-- <link href="/main.css" rel="stylesheet"/>--> 5 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"/> 6 <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> 7 <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> 8 <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> 9 </head> 10 <body> 1 <div> 11 2 <form th:method="POST" th:action="@{/login}"> 12 3 <div class="container"> … … 26 17 </form> 27 18 <a href="/register" class="btn btn-block btn-light">Регистрирај се</a> 28 </body> 29 </html> 19 </div> -
src/main/resources/templates/ordersForUser.html
rfeffc2f r60de3eb 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Мои нарачки</title> 6 </head> 7 <body> 1 <div> 8 2 <h1>Мои нарачки</h1> 9 3 <table> … … 27 21 </tbody> 28 22 </table> 29 </body> 30 </html> 23 </div> -
src/main/resources/templates/partinfo.html
rfeffc2f r60de3eb 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Детали</title> 6 </head> 7 <body> 1 <div> 8 2 <p th:text="${part.getName()}"></p> 9 3 <p th:text="${part.getDescription()}"></p> … … 16 10 <button type="submit">Купи</button> 17 11 </form> 18 </body> 19 </html> 12 </div> -
src/main/resources/templates/register.html
rfeffc2f r60de3eb 1 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" lang="en"> 2 <head> 3 <title>Login form</title> 4 <!-- <link href="/main.css" rel="stylesheet"/>--> 5 <title>Login</title> 6 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"/> 7 <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> 8 <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> 9 <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> 10 </head> 11 <body> 1 <div> 12 2 <form th:method="POST" th:action="@{/register}"> 13 3 <div class="container"> … … 43 33 </form> 44 34 <a href="/login" class="btn btn-block btn-light">Веќе имате сметка? Најавете се</a> 45 </body> 46 </html> 35 </div> -
src/main/resources/templates/repairsForUser.html
rfeffc2f r60de3eb 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Мои поправки</title> 6 </head> 7 <body> 1 <div> 8 2 <h1>Мои поправки</h1> 9 3 <table> … … 12 6 <th>Датум на нарачка</th> 13 7 <th>Нарачан дел</th> 14 <th>Број на шасија</th> 0olji8 <th>Број на шасија</th> 15 9 <th>Име на сервис</th> 16 10 </tr> … … 25 19 </tbody> 26 20 </table> 27 </body> 28 </html> 21 </div> -
src/main/resources/templates/reviewsForUser.html
rfeffc2f r60de3eb 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Мои критики</title> 6 </head> 7 <body> 1 <div> 8 2 <h1>Мои критики</h1> 9 3 <table> … … 25 19 </tbody> 26 20 </table> 27 </body> 28 </html> 21 </div>
Note:
See TracChangeset
for help on using the changeset viewer.