-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49a35b2
commit b7a4cb8
Showing
14 changed files
with
291 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/org/ecommerce/spring/boot/vegetable/project/controller/AdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.ecommerce.spring.boot.vegetable.project.controller; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import org.ecommerce.spring.boot.vegetable.project.entity.UserOrder; | ||
import org.ecommerce.spring.boot.vegetable.project.service.UserOrderService; | ||
import org.ecommerce.spring.boot.vegetable.project.service.UserService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.servlet.ModelAndView; | ||
import org.springframework.web.servlet.view.RedirectView; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/admin") | ||
public class AdminController { | ||
|
||
@Autowired private UserOrderService userOrderService; | ||
@Autowired private UserService userService; | ||
|
||
@GetMapping | ||
public ModelAndView admin(HttpServletRequest request){ | ||
ModelAndView modelAndView = new ModelAndView("admin"); | ||
modelAndView.addObject("request", request); | ||
return modelAndView; | ||
} | ||
|
||
@GetMapping("/getAllOrder") | ||
public List<UserOrder> getAllOrder() { | ||
return userOrderService.getAllOrder(); | ||
} | ||
|
||
@GetMapping("/confirm/{orderId}") | ||
public RedirectView confirmOrder(@PathVariable Long orderId) { | ||
RedirectView redirectView = new RedirectView("/admin"); | ||
userOrderService.confirmOrder(orderId); | ||
return redirectView; | ||
} | ||
|
||
@DeleteMapping("/deleteUser") | ||
public String deleteUserById(@PathVariable Long id) { | ||
userService.deleteUserById(id); | ||
return "delete success"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
|
||
.order-detail-item { | ||
padding: 10px 0; | ||
} | ||
|
||
.order-detail-item:hover { | ||
/*box-shadow: 0 0 3px 3px rgba(0, 0, 0, 0.1);*/ | ||
background-color: rgba(0, 0, 0, 0.1); | ||
cursor: pointer; | ||
} | ||
|
||
.order-radius { | ||
border-top-left-radius: 20px; | ||
border-top-right-radius: 20px; | ||
background-color: rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.order-radius + .order-detail-orderItem { | ||
display: block; | ||
border-top: 1px solid rgba(0, 0, 0, 0.1); | ||
padding: 15px 0; | ||
background-color: rgba(0, 0, 0, 0.1); | ||
border-bottom-left-radius: 20px; | ||
border-bottom-right-radius: 20px; | ||
max-height: 1000px; | ||
overflow: hidden; | ||
animation: sweepDown 3s cubic-bezier(0.2, 0, 0.5, 1) forwards; | ||
} | ||
|
||
@keyframes sweepDown { | ||
0% { | ||
max-height: 30px; | ||
} | ||
100% { | ||
max-height: 1000px; /* Chọn một giá trị đủ lớn để đảm bảo nội dung được hiển thị đầy đủ */ | ||
} | ||
} | ||
|
||
.order-detail-orderItem { | ||
display: none; | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
$(document).ready(function() { | ||
getAllOrder(); | ||
}); | ||
|
||
$(document).on('click', '.order-detail-item', function() { | ||
$(this).toggleClass('order-radius'); | ||
console.log(this); | ||
}); | ||
|
||
function getAllOrder() { | ||
$.ajax({ | ||
type: "GET", | ||
url: "/admin/getAllOrder", | ||
success: function(orders) { | ||
let html = ''; | ||
orders.forEach((order) => { | ||
html += | ||
"<div class='row mt-3 order-detail-item align-items-center'>" + | ||
"<div class=\"col-3 h-100\">" + | ||
"<div class='shopping-cart-name' style='margin-left: 0;'>"+ order.user.email +"</div>" + | ||
"</div>" + | ||
"<div class=\"col-9 h-100\">" + | ||
"<div class=\"row text-center align-items-center h-100\">" + | ||
"<div class=\"shopping-cart-property col-3\">" + | ||
"<h4 class=\"shopping-cart-product\">"+ order.address +"</h4>" + | ||
"</div>" + | ||
"<div class=\"shopping-cart-property col-3\">" + | ||
"<form method='post' action='/shop/order' class='d-flex justify-content-center'>" + | ||
"<div class='d-flex product-detail_number align-items-center'>" + | ||
"<input type='hidden' name='userId' value='1'/>" + | ||
"<input type='hidden' name='productId' value='"+ order.phoneNumber +"' disabled/>" + | ||
"<h4 class=\"shopping-cart-product\">"+ order.phoneNumber +"</h4>" + | ||
"</div>" + | ||
"</form>" + | ||
"</div>" + | ||
"<div class=\"shopping-cart-property col-3\">" + | ||
"<h4 class=\"shopping-cart-product\">"+ order.orderNote +"</h4>" + | ||
"</div>" + | ||
"<div class=\"shopping-cart-property col-3\">" + | ||
"<a class=\"btn btn-primary\" href='/admin/confirm/"+ order.id +"'>Confirm</a>" + | ||
"</div>" + | ||
" </div>" + | ||
"</div>" + | ||
"</div>"; | ||
html += | ||
'<div class="order-detail-orderItem row">' + | ||
renderOrderItem(order.orderItems) + | ||
'</div>' | ||
}); | ||
$('.order-detail').html(html); | ||
} | ||
}); | ||
} | ||
|
||
function renderOrderItem(orderItems) { | ||
let orderHtml = ''; | ||
orderItems.forEach((orderItem, index) => { | ||
orderHtml += | ||
"<div class='row align-items-center' >" + | ||
"<div class=\"col-3 h-100\">" + | ||
"<div class='shopping-cart-name'>"+ orderItem.productOrder.name +"</div>" + | ||
"</div>" + | ||
"<div class=\"col-9 h-100\">" + | ||
"<div class=\"row text-center align-items-center h-100\">" + | ||
"<div class=\"shopping-cart-property col-3\">" + | ||
"<h4 class=\"shopping-cart-product\">"+ "$"+ Math.min(orderItem.productOrder.cost, orderItem.productOrder.saleCost).toFixed(2) +"</h4>" + | ||
"</div>" + | ||
"<div class=\"shopping-cart-property col-3\">" + | ||
"<form method='post' action='/shop/order' class='d-flex justify-content-center'>" + | ||
"<div class='d-flex product-detail_number align-items-center'>" + | ||
"<h4 class=\"shopping-cart-product\">"+ orderItem.quantity +"</h4>" + | ||
"</div>" + | ||
"</form>" + | ||
"</div>" + | ||
"<div class=\"shopping-cart-property col-3\">" + | ||
"<h4 class=\"shopping-cart-product\">"+ (Math.min(orderItem.productOrder.cost, orderItem.productOrder.saleCost) * orderItem.quantity).toFixed(2) +"</h4>" + | ||
"</div>" + | ||
" </div>" + | ||
"</div>" + | ||
"</div>"; | ||
}); | ||
return orderHtml; | ||
} |
Oops, something went wrong.