Skip to content

Commit

Permalink
Merge pull request #55 from hightuv/페이지-수정
Browse files Browse the repository at this point in the history
페이지 수정
  • Loading branch information
moonwonki authored May 13, 2024
2 parents 1512be6 + 642376a commit 5f8c306
Show file tree
Hide file tree
Showing 16 changed files with 8,638 additions and 169 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.example.WebOrder.controller;

import com.example.WebOrder.service.CategoryService;
import com.example.WebOrder.service.ItemService;
import com.example.WebOrder.service.OrderService;
import com.example.WebOrder.service.ReviewService;
import com.example.WebOrder.service.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
Expand All @@ -20,12 +17,14 @@ public class OrderController {
private final OrderService orderService;
private final CategoryService categoryService;
private final ReviewService reviewService;
private final ProfileService profileService;

public OrderController(ItemService itemService, OrderService orderService, CategoryService categoryService, ReviewService reviewService) {
public OrderController(ItemService itemService, OrderService orderService, CategoryService categoryService, ReviewService reviewService, ProfileService profileService) {
this.itemService = itemService;
this.orderService = orderService;
this.categoryService = categoryService;
this.reviewService = reviewService;
this.profileService = profileService;
}


Expand All @@ -35,6 +34,7 @@ public String getShopPageByGuest(@PathVariable Long userId, @PathVariable Long s
// 인증 과정 했다 치고
model.addAttribute("categories", categoryService.getAllCategory(userId));
model.addAttribute("items",itemService.getAllItemsOfUser(userId));
model.addAttribute("profile", profileService.getUserProfileById(userId));
return "order/orderForm";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public String getBillsOfSeatByOwner(){
}

//QR코드 생성하기
@GetMapping("/owner/code/qr/{seatId}")
@GetMapping("/admin/code/qr/{seatId}")
public String getQRCodeOfSeatByOwner(@PathVariable Long seatId, Model model) throws IOException, WriterException {
String img = orderPasswordService.generateQRCode(((User) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId(), seatId);
model.addAttribute("img", img);
Expand Down
36 changes: 6 additions & 30 deletions src/main/java/com/example/WebOrder/controller/SeatController.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public String getWholeSeatByOwner(Model model){
model.addAttribute("currentTime", formattedTime);
model.addAttribute("seatList", seatService.getWholeSeatOrdersOfCurrentUser());
model.addAttribute("seatNum", seatService.getTotalSeatNum());
model.addAttribute("mostOrderedSeat", seatService.getMostOrderedSeatOfCurrentUser()); //가장 많이 주문된 좌석
model.addAttribute("leastOrderedSeat", seatService.getLeastOrderedSeatOfCurrentUser()); //가장 적게 주문된 좌석
return "seat/seatView";
}

Expand Down Expand Up @@ -69,57 +71,31 @@ public String getSeatBilled(@PathVariable("seatId") Long seatId){
return "redirect:/admin/seat/view";
}

//테이블 관리 페이지
@GetMapping("/admin/seat/manage")
public String getSeatManagePageByOwner(Model model) {
model.addAttribute("mostOrderedSeat", seatService.getMostOrderedSeatOfCurrentUser()); //가장 많이 주문된 좌석
model.addAttribute("leastOrderedSeat", seatService.getLeastOrderedSeatOfCurrentUser()); //가장 적게 주문된 좌석
model.addAttribute("totalSeatNum", seatService.getTotalSeatNum()); //총 좌석 개수
model.addAttribute("seatList", seatService.getBasicSeatListOfCurrentUser()); //좌석 이름 리스트

return "seat/seatManage";
}

//테이블 생성하기
@GetMapping("/admin/seat/create")
public String getCreateSeatForm(Model model){
model.addAttribute("seat", new SeatDto());
model.addAttribute("isCreate", true);
model.addAttribute("seatName", null);
return "seat/seatCreate";
}
@PostMapping("/admin/seat/create")
public String createSeatByOwner(String seatName){
seatService.addSeat(seatName);
return "redirect:/admin/seat/manage";
return "redirect:/admin/seat/view";
}


//테이블 삭제하기
@PostMapping("/admin/seat/delete/{seatId}")
public String deleteSeatByOwner(@PathVariable("seatId") Long seatId){
seatService.deleteSeat(seatId);
return "redirect:/admin/seat/manage";
return "redirect:/admin/seat/view";
}

//테이블 수정하기
@GetMapping("/admin/seat/update/{seatId}")
public String getUpdateSeatForm(@PathVariable("seatId") Long seatId, Model model){
model.addAttribute("seat", seatService.getSeatDto(seatId));
model.addAttribute("isCreate", false);
model.addAttribute("seatName", seatService.getSeatName(seatId));
return "seat/seatCreate";
}
@PostMapping("/admin/seat/update/{seatId}")
public String updateSeatByOwner(@PathVariable("seatId") Long seatId, String seatName){
seatService.updateSeatName(seatId, seatName);
return "redirect:/admin/seat/manage";
return "redirect:/admin/seat/view";
}

//테이블 치우기
@PostMapping("/admin/seat/clear/{seatId}")
public String clearSeatByOwner(@PathVariable("seatId") Long seatId){
seatService.clearSeat(seatId);
return "redirect:/admin/seat/manage";
return "redirect:/admin/seat/view";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ public String editMyProfile(UserEditFormDto dto, @RequestPart(value = "image", r
return "redirect:/myprofile?pwderror=true";
}


String fileName;
if (image == null) {
if (Objects.equals(image.getOriginalFilename(), "")) {
fileName = null;
}
else {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/example/WebOrder/entity/Seat.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ public class Seat {

// 해당 좌석에서 주문 받은 횟수
private Long orderedTime;

public void increaseOrderedTime() {
orderedTime += 1;
}
}
6 changes: 4 additions & 2 deletions src/main/java/com/example/WebOrder/service/SeatService.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public void makeSeatBilled(Long seatId) {
if (optionalSeat.isEmpty()) throw new RuntimeException("엔티티 없음");

Seat seat = optionalSeat.get();
seat.increaseOrderedTime();
seatRepository.save(seat);
List<Order> orderList = orderRepository.findOrdersByStatusNotBilledOrCancelAndSeat(seat);

for (Order order : orderList){
Expand All @@ -101,7 +103,7 @@ public String getMostOrderedSeatOfCurrentUser(){
if (optionalTopSeat.isEmpty()) return "테이블 없음";
Seat topSeat = optionalTopSeat.get();

return topSeat.getName() + " (" + topSeat.getOrderedTime() + ") ";
return topSeat.getName() + " : " + topSeat.getOrderedTime() + "";
}

// 현재 유저의 seat 중 가장 적게 주문을 받은 seat를 가져오기
Expand All @@ -112,7 +114,7 @@ public String getLeastOrderedSeatOfCurrentUser(){
if (optionalTopSeat.isEmpty()) return "테이블 없음";
Seat topSeat = optionalTopSeat.get();

return topSeat.getName() + " (" + topSeat.getOrderedTime() + ") ";
return topSeat.getName() + " : " + topSeat.getOrderedTime() + "";
}

// userId를 가진 user의 SeatDto 리스트 가져오기 (주문 내역은 볼 수 없음!)
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/static/css/itemForm.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

.item-form {
width: 80%;
height: 50%;
height: 70%;
background: #fff;
border-radius: 6px;
padding: 30px 60px 40px 40px;
Expand Down Expand Up @@ -69,7 +69,7 @@
align-items: center;
justify-content: center;
font-size: 5rem;
color: #fc9d7a;
color: #779b8b;
}

.wrapper .text {
Expand Down Expand Up @@ -110,7 +110,7 @@
font-weight: 500;
letter-spacing: 1px;
cursor: pointer;
background: #fc9d7a;
background: #779b8b;
}

.item-form .content .right-side {
Expand All @@ -121,7 +121,7 @@
.item-form .content .right-side .item-form-header {
font-size: 23px;
font-weight: 600;
color: #f65b2a;
color: #587769;
}

.right-side .categories {
Expand Down Expand Up @@ -169,13 +169,13 @@
border: none;
padding: 8px 16px;
border-radius: 6px;
background: #ff8056;
background: #587769;
cursor: pointer;
transition: all 0.3s ease;
}

.right-side button:hover {
background: #fc9d7a;
background: #779b8b;
}

@media(max-width:820px) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/static/css/itemManage.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
border: none;
padding: 8px 16px;
border-radius: 6px;
background: #ff8056;
background: #587769;
cursor: pointer;
transition: all 0.3s ease;
}
Expand All @@ -73,15 +73,15 @@
border: none;
padding: 8px 16px;
border-radius: 6px;
background: #ff8056;
background: #587769;
cursor: pointer;
transition: all 0.3s ease;
}

.button-container .add-item:hover,
.category-create-form button:hover,
.category-delete-form .delete-category:hover {
background: #fc9d7a;
background: #779b8b;
}

.item-button:active {
Expand Down
11 changes: 8 additions & 3 deletions src/main/resources/static/css/loginForm.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ body {
.login-form {
position: relative; z-index: 2;
}
.login-form h1 {
font-size: 32px; color: black;
text-align: center;

.login-form .image {
display: flex;
justify-content: center;
}

.login-form img {
width: 10rem;
margin-bottom: 60px;
}

Expand Down
Loading

0 comments on commit 5f8c306

Please sign in to comment.