source: src/main/java/tech/techharbor/Web/HomeController.java

main
Last change on this file was f4b4afa, checked in by Nikola Todoroski <nikola.todoroski@…>, 6 months ago

Pushed whole project, original project location on github:https://github.com/hehxd/Tech-Harbor

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[f4b4afa]1package tech.techharbor.Web;
2
3import jakarta.servlet.http.HttpSession;
4import org.springframework.stereotype.Controller;
5import org.springframework.ui.Model;
6import org.springframework.web.bind.annotation.GetMapping;
7import tech.techharbor.Model.UserTableModel;
8import tech.techharbor.Service.CategoryService;
9import tech.techharbor.Service.ProductService;
10import tech.techharbor.Service.SubcategoryService;
11
12
13@Controller
14public class HomeController {
15
16 private final CategoryService categoryService;
17 private final SubcategoryService subcategoryService;
18 private final ProductService productService;
19
20 public HomeController(CategoryService categoryService, SubcategoryService subcategoryService, ProductService productService) {
21 this.categoryService = categoryService;
22 this.subcategoryService = subcategoryService;
23 this.productService = productService;
24 }
25
26 @GetMapping("/")
27 public String getHomePage(Model model, HttpSession session) {
28 model.addAttribute("categories", categoryService.listCategories());
29 model.addAttribute("subcategories", subcategoryService.listSubcategories());
30 model.addAttribute("products", productService.listProducts());
31 UserTableModel user = (UserTableModel) session.getAttribute("user");
32 model.addAttribute("user", user);
33 Object deliveryManObject = session.getAttribute("deliveryMan");
34 model.addAttribute("deliveryMan", deliveryManObject);
35 return "index";
36 }
37
38 @GetMapping("/aboutUs")
39 public String getAboutUsPage(Model model, HttpSession session) {
40 UserTableModel user = (UserTableModel) session.getAttribute("user");
41 model.addAttribute("user", user);
42 Object deliveryManObject = session.getAttribute("deliveryMan");
43 model.addAttribute("deliveryMan", deliveryManObject);
44 return "aboutUs";
45 }
46
47
48}
Note: See TracBrowser for help on using the repository browser.