Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Master 2024년 8월 29일 #295

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/com/readyauction/app/auction/entity/Bid.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.sql.Timestamp;

@Entity
@Table(name = "tbl_bid")
@Getter
@Setter
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
import java.util.List;

@Entity
@Table(name = "tbl_product")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@SecondaryTable(
name = "winner",
name = "tbl_winner",
pkJoinColumns = @PrimaryKeyJoinColumn(name = "product_id",referencedColumnName = "id")
)
public class Product {
Expand Down Expand Up @@ -51,7 +52,7 @@ public class Product {

@NotEmpty(message = "최소 하나의 이미지는 필수 항목입니다.")
@ElementCollection
@CollectionTable(name = "product_images", joinColumns = @JoinColumn(name = "product_id"))
@CollectionTable(name = "tbl_product_images", joinColumns = @JoinColumn(name = "product_id"))
@Column(name = "image_url")
private List<String> images;
@Enumerated(EnumType.STRING)
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/readyauction/app/auction/entity/Winner.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
@Builder
public class Winner {

@Column(name = "winner_member_id", table = "winner") // 열 이름을 명시적으로 지정
@Column(name = "winner_member_id", table = "tbl_winner") // 열 이름을 명시적으로 지정
private Long memberId;
@Column(table = "winner")
@Column(table = "tbl_winner")
private Integer price;
@Column(table = "winner")
@Column(table = "tbl_winner")
private Timestamp winnerTime;

@Column(table = "winner")
@Column(table = "tbl_winner")
@Enumerated(EnumType.STRING)
private PurchaseStatus status; // 구매 대기, 거래중, 구매확정

@Column(table = "winner")
@Column(table = "tbl_winner")
@Enumerated(EnumType.STRING)
private PurchaseCategory category;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package com.readyauction.app.cash.controller;

import com.readyauction.app.auction.dto.ProductRepDto;
import com.readyauction.app.auction.entity.Bid;
import com.readyauction.app.auction.entity.Product;
import com.readyauction.app.auction.service.ProductService;
import com.readyauction.app.cash.dto.AccountDto;
import com.readyauction.app.cash.dto.TransactionDto;
import com.readyauction.app.cash.entity.Cash;
import com.readyauction.app.cash.service.AccountService;
import com.readyauction.app.cash.service.CashService;
import com.readyauction.app.cash.service.TransactionService;
import com.readyauction.app.common.handler.UserNotFoundException;
import com.readyauction.app.inquiry.entity.Inquiry;
import com.readyauction.app.user.dto.MemberDto;
import com.readyauction.app.user.dto.ProfileDto;
import com.readyauction.app.user.service.MemberService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -16,6 +24,10 @@
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@Slf4j
@RequiredArgsConstructor
Expand All @@ -26,6 +38,31 @@ public class CashController {
private final CashService cashService;
private final ProductService productService;
private final AccountService accountService;
private final TransactionService transactionService;

@GetMapping("")
public String getCash(Model model) {
// 로그인된 사용자의 정보를 가져오기 위해 SecurityContextHolder 사용
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String currentUserName = authentication.getName(); // 로그인한 이메일
Long memberId = memberService.findMemberDtoByEmail(currentUserName).getId();

try {
// AccountDto 가져오기
AccountDto accountDto = accountService.findAccountDtoByMemberId(memberId);
model.addAttribute("accountDto", accountDto);

// 캐시와 결제 내역 조회
List<TransactionDto> transactionHistory = transactionService.getTransactionHistory(memberId, accountDto.getId());
model.addAttribute("transactionHistory", transactionHistory);

} catch (UserNotFoundException e) {
log.error("Member not found: {}", e.getMessage());
return "error/404";
}

return "cash/cash";
}

@GetMapping("/payment/{id}")
public String getProductDetail(@PathVariable("id") Long id, Model model) {
Expand Down Expand Up @@ -100,7 +137,7 @@ public String chargeCash(@ModelAttribute Cash cash, RedirectAttributes redirectA
redirectAttributes.addFlashAttribute("errorMessage", "충전 중 문제가 발생했습니다.");
}

return "redirect:/mypage";
return "redirect:/cash";
}

// 캐시 환불
Expand Down Expand Up @@ -138,6 +175,6 @@ public String refundCash(@ModelAttribute Cash cash, RedirectAttributes redirectA
return "redirect:/cash/cash-withdrawal";
}

return "redirect:/mypage";
return "redirect:/cash";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.*;

@Entity
@Table(name = "tbl_account")
@Getter
@Setter
@NoArgsConstructor
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/readyauction/app/cash/entity/Cash.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.sql.Timestamp;

@Entity
@Table(name = "tbl_cash")
@Getter
@Setter
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.sql.Timestamp;

@Entity
@Table(name = "tbl_payment")
@Getter
@Setter
@NoArgsConstructor
Expand Down
25 changes: 0 additions & 25 deletions src/main/java/com/readyauction/app/favorite/entity/Favorite.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import com.readyauction.app.user.service.MemberService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
Expand Down Expand Up @@ -59,15 +61,6 @@ public String getMyPage(Model model) {
ProfileDto profileDto = memberService.findProfileDtoById(memberId);
model.addAttribute("profileDto", profileDto);

// AccountDto 가져오기
AccountDto accountDto = accountService.findAccountDtoByMemberId(memberId);
model.addAttribute("accountDto", accountDto);

// 캐시와 결제 내역 조회
List<TransactionDto> transactionHistory = transactionService.getTransactionHistory(memberId, accountDto.getId());
log.debug("transactionHistory: {}", transactionHistory);
model.addAttribute("transactionHistory", transactionHistory);

// 경매 참여 내역 조회
// 입찰 중 내역
List<Bid> biddingBids = bidService.getBiddingBids(memberId);
Expand Down Expand Up @@ -153,6 +146,17 @@ public String updateProfile(@RequestParam("nickname") String nickname,
return "redirect:/mypage";
}

// @GetMapping("/data")
// public @ResponseBody PageResponse getPageData(@RequestParam("page") int pageNum) {
// Pageable pageable = PageRequest.of(pageNum - 1, 10); // 페이지 번호는 0부터 시작하므로 -1합니다.
// Page<MyEntity> page = myService.getEntities(pageable);
//
// PageResponse response = new PageResponse();
// response.setPageNum(pageNum);
// response.setContent(page.getContent());
// return response;
// }

// 회원정보 수정
@GetMapping("/userInfo/edit")
public String editUserInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


@Entity
@Table(name = "tbl_product_report")
@Data
@NoArgsConstructor
@AllArgsConstructor
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/readyauction/app/user/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Set;

@Entity
@Table(name = "user")
@Table(name = "tbl_user")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "user_type") // 자식클래스 타입을 결정하는 컬럼명
@Data
Expand Down Expand Up @@ -69,7 +69,7 @@ public abstract class User {
private UserStatus userStatus;

@ElementCollection(targetClass = Authority.class, fetch = FetchType.EAGER)
// @CollectionTable(name = "user", joinColumns = @JoinColumn(name = "id"))
@CollectionTable(name = "tbl_user_authorities")
@Column(name = "authority")
@Enumerated(EnumType.STRING)
private Set<Authority> authorities;
Expand Down
16 changes: 11 additions & 5 deletions src/main/resources/templates/auction/auction.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout/default}">
layout:decorate="~{layout/default}" xmlns:sec="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>경매 목록</title>
<script th:inline="javascript">

function setCategory(category) {
Expand All @@ -25,6 +24,11 @@
}
}
}

function goToProductPage(productId) {
var url = '/auction/product/' + productId;
window.location.href = url;
}
</script>
</head>
<body>
Expand Down Expand Up @@ -60,10 +64,12 @@ <h5 class="widget-title">Sports Categories</h5>
<div class="container">
<div class="row g-4" id="productList">
<div class="col-lg-4 col-md-6" th:each="product : ${products}"
th:attr="data-category=${product.category}">
th:attr="data-category=${product.category}"
th:onclick="goToProductPage([[${product.id}]])"
style="cursor: pointer">
<div class="product-card product-beta-md" style="min-width: 300px; max-width: 350px;">
<div class="product-header">
<h5 class="product-title"><a th:href="@{/auctionDetails}">[[${product.name}]]</a></h5>
<h5 class="product-title">[[${product.name}]]</h5>
<h4 class="price">₩[[${product.immediatePrice}]]</h4>
</div>
<div class="product">
Expand Down Expand Up @@ -136,7 +142,7 @@ <h6>
</script>
</div>
</div>
<a th:href="@{/auction/product/{id}(id=${product.id})}" class="bid-btn">입찰하기</a>
<a sec:authorize="!hasAuthority('ROLE_ADMIN')" th:href="@{/auction/product/{id}(id=${product.id})}" class="bid-btn">입찰하기</a>

</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/templates/auction/auctionDetails.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html lang="en" layout:decorate="~{layout/default}"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link href="https://unpkg.com/swiper/swiper-bundle.min.css" rel="stylesheet">
Expand Down Expand Up @@ -653,7 +653,7 @@ <h5 class="widget-title">상품 상세정보</h5>
</ul>

<!-- 신고하기 -->
<div class="report-dropdown" style="position: relative; text-align: right; margin-bottom: 5px;">
<div sec:authorize="!hasAuthority('ROLE_ADMIN')" class="report-dropdown" style="position: relative; text-align: right; margin-bottom: 5px;">
<button class="report-btn" style="background-color: transparent; border: none; cursor: pointer;">
<i class="fa-solid fa-flag" style="color: red;"></i> <!-- 경찰차 사이렌 대체 아이콘 -->
</button>
Expand Down Expand Up @@ -741,7 +741,7 @@ <h5 class="widget-title">상품 상세정보</h5>
});
</script>

<div class="single-widget">
<div sec:authorize="!hasAuthority('ROLE_ADMIN')" class="single-widget">
<form class="widget-form" id="bidForm">
<div class="form-group d-flex justify-content-center align-items-center">
<!-- 현재 가격을 보여주는 입력 필드 -->
Expand All @@ -755,7 +755,7 @@ <h5 class="widget-title">상품 상세정보</h5>
</form>
</div>

<div class="single-widget">
<div sec:authorize="!hasAuthority('ROLE_ADMIN')" class="single-widget">
<form class="widget-form" id="buyForm">
<div class="form-group d-flex justify-content-center align-items-center">
<!-- 현재 가격을 보여주는 입력 필드 -->
Expand Down
Loading
Loading