Skip to content

Commit

Permalink
create shop page and update some function in HomeController
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantaphocpython committed Feb 23, 2024
1 parent 7a15613 commit b5600b9
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class HomeController {
@Autowired
private BlogService blogService;

@GetMapping("/")
@GetMapping
public ModelAndView home() throws ParseException {
ModelAndView modelAndView = new ModelAndView("home");
List<Category> categories = categoryService.getCategoryList();
Expand All @@ -60,7 +60,7 @@ public String loginForm() {
}

@PostMapping("/addCategory")
public ResponseEntity<?> addCategory(@RequestParam("name") String name, @RequestParam("image")MultipartFile file) throws IOException {
public ResponseEntity<?> addCategory(@RequestParam("name") String name, @RequestParam("image") MultipartFile file) throws IOException {
categoryService.addCategory(name, file);
return ResponseEntity.ok("success");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.ecommerce.spring.boot.vegetable.project.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/shop")
public class ShopController {

@GetMapping
public String shop() {
return "shop";
}
}
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ spring:
auth: true
starttls:
enable: true

6 changes: 6 additions & 0 deletions src/main/resources/static/css/footer.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.footer-wrapper {
background-color: rgb(243,246,250);
height: max-content;
padding-bottom: 16px;
}

.footer-left-icon {
Expand All @@ -22,6 +23,7 @@
color: #1c1c1c;
}


.footer-left-contact {
font-weight: bold;
font-size: 16px;
Expand Down Expand Up @@ -51,6 +53,10 @@
width: 120px;
}

.footer-top {
margin-bottom: 90px;
}

.footer-down-image {
display: flex;
margin-left: auto;
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/static/css/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@
display: block;
}

.nav-link.header-menu-item-btn:hover {
color: #7fad39;
}

.nav-link.header-menu-item-btn.active {
color: #7fad39;
}

.header-menu-page-wrapper:hover .header-menu-page {
display: block;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/fragments/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<body>
<div class="footer-wrapper mt-5" th:fragment="footer">
<div class="container col-9">
<div class="row">
<div class="row footer-top">
<div class="footer-left col-4 mt-5">
<img th:src="@{/img/logo.png}" alt="Logo" class="footer-left-icon d-block align-text-top footer-logo">
<span class="footer-left-information">Address: 60-49 Road 11378 New York</span>
Expand Down Expand Up @@ -47,7 +47,7 @@ <h6 class="footer-left-contact">Join Our Newletter Now</h6>
</div>
</div>
<hr class="mt-5">
<img th:src="@{/img/payment-item.png.webp}" alt="" class="footer-down-image mb-3">
<img th:src="@{/img/payment-item.png.webp}" alt="" class="footer-down-image">
</div>
</div>
</body>
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/templates/fragments/fragments.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
<html th:lang="en" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity6">
<head th:fragment="boots_trap">
<meta content="text/html; charset=utf-8" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
Expand Down Expand Up @@ -69,12 +70,12 @@
<ul class="nav col-6 ">
<li class="nav-item col-2">
<a class="nav-link header-menu-item-btn"
aria-current="page" href="#">
aria-current="page" th:href="@{/}" >
HOME
</a>
</li>
<li class="nav-item col-2">
<a class="nav-link header-menu-item-btn" href="#">SHOP</a>
<a class="nav-link header-menu-item-btn" th:href="@{/shop}">SHOP</a>

</li>
<li class="nav-item col-2 header-menu-page-wrapper">
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/home.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html th:lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
Expand Down Expand Up @@ -146,7 +146,7 @@ <h2 class="banner-text-title">Vegetable <br>100% Organic</h2>
<img th:src="@{'/getBlogImage/' + ${blog.id}}" class="blog-item-image gt-5">
<div class="createDate mt-3 mb-3">
<i class="bi bi-calendar createDate-icon"></i>
<h5 th:text="${#dates.format(blog.getCreateDate(), 'MM-d, yyyy')}" class="createDate-time"></h5>
<h5 th:text="${#dates.format(blog.getCreateDate(), 'MMMM dd, yyyy')}" class="createDate-time"></h5>
</div>
<a th:text="${blog.getTitle()}" class="blog-item-title mb-3" href="#" th:title="${blog.getTitle()}"></a>
<p class="blog-item-content mb-3" th:text="${blog.getContent()}"></p>
Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/templates/shop.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Shop</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
crossorigin="anonymous"></script>
<link rel="stylesheet" th:href="@{/css/header.css}">
</head>
<body>
<div th:replace="/fragments/fragments :: header"></div>
</body>
</html>

0 comments on commit b5600b9

Please sign in to comment.