Skip to content

Commit

Permalink
Merge branch 'dev' into feat/52-bid-history (#73)
Browse files Browse the repository at this point in the history
# Conflicts:
#	Api/src/main/java/picasso/server/api/auction/controller/PictureBidHistoryRestController.java
#	Api/src/main/java/picasso/server/api/auction/service/PictureBidHistoryService.java
#	Domain/src/main/java/picasso/server/domain/domains/picture/repository/PictureBidHistoryRepository.java
  • Loading branch information
donsonioc2010 authored Sep 26, 2023
1 parent ec9d54a commit 92efab8
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import picasso.server.api.admin.exception.AlreadyChangePictureException;
import picasso.server.api.mail.service.SendMailService;
import picasso.server.common.exception.NotFoundException;
import picasso.server.domain.domains.picture.items.Picture;
import picasso.server.domain.domains.picture.repository.PictureRepository;
Expand All @@ -25,6 +26,7 @@
public class AdminService {
private final PictureRepository pictureRepository;
private final UserRepository userRepository;
private final SendMailService sendMailService;

// TODO : 추후 Pagenation으로의 수정 필요함.
@Transactional(readOnly = true)
Expand Down Expand Up @@ -56,6 +58,7 @@ public void approvePicture(Long pictureId) {
pictureRepository.save(picture);
log.info("ApprovePicture Success >>> Picture Id : {}, Title : {}",
picture.getPictureId(), picture.getPictureName());
sendMailService.adminApproveMail(picture);
return;
}
log.warn("ApprovePicture Failure >>> Picture Id : {}, Title : {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public void startAuction() {
}
}
);
pictureService.saveAllPictureList(todayEndPictursList);
log.info("Today End Auctions Schedule End Time >>> {}", LocalDateTime.now());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.time.LocalDateTime;

import static picasso.server.domain.domains.picture.items.PictureStatus.AFTER_APPROVE;
import static picasso.server.domain.domains.picture.items.PictureStatus.BEFORE_APPROVE;
import static picasso.server.domain.domains.picture.items.PictureStatus.BIDDING;

/**
Expand All @@ -33,7 +34,7 @@ public class StartAuctionScheduler {
public void startApprovePictureToBiddingAuction() {
log.info("Start Todays Auctions Open Schedule Runtime : NowTime >>> {}", LocalDateTime.now());
pictureService
.changePictureStatusByPictureStatusAndBidEndDate(AFTER_APPROVE, BIDDING, LocalDate.now())
.changePictureStatusByPictureStatusAndBidStartDate(AFTER_APPROVE, BIDDING, LocalDate.now())
.forEach(sendMailService::startBiddingMail);
log.info("End Todays Auctions Open Schedule Runtime : NowTime >>> {}", LocalDateTime.now());
}
Expand All @@ -44,7 +45,7 @@ public void startApprovePictureToBiddingAuction() {
public void startNotApprovePictureToRejectAuction() {
log.info("Start Reject Picture Schedule Runtime : NowTime >>> {}", LocalDateTime.now());
pictureService
.changePictureStatusByPictureStatusAndBidEndDate(AFTER_APPROVE, BIDDING, LocalDate.now())
.changePictureStatusByPictureStatusAndBidStartDate(BEFORE_APPROVE, BIDDING, LocalDate.now())
.forEach(sendMailService::pictureRejectMailWithNotApproveAdmin);
log.info("End Todays Auctions Open Schedule Runtime : NowTime >>> {}", LocalDateTime.now());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package picasso.server.api.auction.service;

import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import picasso.server.domain.domains.picture.items.Picture;
import picasso.server.domain.domains.picture.items.PictureInfo;
import picasso.server.domain.domains.picture.items.PictureStatus;
import picasso.server.domain.domains.picture.repository.PictureRepository;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -54,6 +55,9 @@ private PictureInfo mapToPictureInfo(Picture picture) {
pictureInfo.setStartPrice(picture.getStartingPrice());
pictureInfo.setIncrementAmount(picture.getIncrementAmount());
pictureInfo.setEndDay(picture.getBidEndDate());
pictureInfo.setStartDate(picture.getBidStartDate().format(DateTimeFormatter.ofPattern("yy/MM/dd")));
pictureInfo.setEndDate(picture.getBidEndDate().format(DateTimeFormatter.ofPattern("yy/MM/dd")));

return pictureInfo;
}

Expand Down Expand Up @@ -92,6 +96,7 @@ public List<Picture> changePictureStatusByPictureStatusAndBidStartDate(PictureSt
* @param bidEndDate 찾아야 하는 경매 종료 일자
* @return Picture List를 반환한다.
*/
@Transactional(readOnly = true)
public List<Picture> changePictureStatusByPictureStatusAndBidEndDate(PictureStatus searchStatus, PictureStatus updateStatus, LocalDate bidEndDate) {
List<Picture> result = pictureRepository
.findAllByPictureStatusAndBidEndDate(searchStatus, bidEndDate);
Expand All @@ -100,7 +105,7 @@ public List<Picture> changePictureStatusByPictureStatusAndBidEndDate(PictureStat
return result;
}

@org.springframework.transaction.annotation.Transactional(readOnly = true)
@Transactional(readOnly = true)
public List<Picture> findPictureStatusByStatusAndBidEndDate(PictureStatus searchStatus, LocalDate bidEndDate) {
return pictureRepository
.findAllByPictureStatusAndBidEndDate(searchStatus, bidEndDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,5 @@ public class MailPathConstants {
// 경매 시작 안내 메일
public static final String PICTURE_BIDDING_MAIL = "mail/bidding-picture-mail";

/*TODO : 시간 될 떄 추가구현!*/
// 게시물 관리자 승인 안내 메일
public static final String PICTURE_APPROVE_MAIL = "mail/approve-picture-mail";

// 입찰자 추가 발생 안내 ( 판매자 )
public static final String PICTURE_NEW_BID_SELLER_MAIL = "mail/new-bid-picture-mail-seller";

// 입찰자 추가 발생 안내 ( 구매자 )
public static final String PICTURE_NEW_BID_BUYER_MAIL = "mail/new-bid-picture-mail-buyer";
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import picasso.server.common.exception.NotFoundException;
import picasso.server.common.mail.SendMailUtil;
import picasso.server.common.properties.PicassoProperties;
import picasso.server.domain.domains.picture.items.Picture;
import picasso.server.domain.domains.picture.items.PictureBidHistory;
import picasso.server.domain.domains.picture.repository.PictureBidHistoryRepository;

import java.util.HashMap;

import static picasso.server.api.mail.MailPathConstants.PICTURE_APPROVE_MAIL;
import static picasso.server.api.mail.MailPathConstants.PICTURE_BIDDING_MAIL;
import static picasso.server.api.mail.MailPathConstants.PICTURE_NOT_APPROVE_REJECT_MAIL;
import static picasso.server.api.mail.MailPathConstants.PICTURE_NO_BID_REJECT_MAIL;
import static picasso.server.api.mail.MailPathConstants.PICTURE_SUCCESSBID_MAIL;
import static picasso.server.api.mail.MailTitleConstant.BIDDING;
import static picasso.server.api.mail.MailTitleConstant.REJECT;
import static picasso.server.api.mail.MailTitleConstant.SUCCESS_BID;

/**
* 모든 메일 발송에 대한 기능은 해당 Service에서 담당하여 발송합니다
Expand All @@ -28,6 +34,7 @@
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class SendMailService {
private final PictureBidHistoryRepository pictureBidHistoryRepository;
private final SendMailUtil sendMailUtil;
private final PicassoProperties picassoProperties;

Expand All @@ -39,12 +46,12 @@ public class SendMailService {
@Async
public void adminApproveMail(Picture picture) {
sendMailUtil.sendMail(
"donsonic@naver.com",
picture.getUser().getEmail(),
REJECT.getMailTitle(),
PICTURE_NOT_APPROVE_REJECT_MAIL,
PICTURE_APPROVE_MAIL,
new HashMap<>() {{
put("pictureName", picture.getPictureName());
put("bidEndDate", picture.getBidEndDate().toString());
put("startBidDate", picture.getBidStartDate().toString());
put("link", picassoProperties.getDomain() + "pictures/" + picture.getPictureId());
}}
);
Expand All @@ -58,7 +65,7 @@ public void adminApproveMail(Picture picture) {
@Async
public void startBiddingMail(Picture picture) {
sendMailUtil.sendMail(
"donsonic@naver.com",
picture.getUser().getEmail(),
BIDDING.getMailTitle(),
PICTURE_BIDDING_MAIL,
new HashMap<>() {{
Expand All @@ -69,26 +76,39 @@ public void startBiddingMail(Picture picture) {
);
}


/**
* 경매 새로운 입찰이 발생하는 경우 경매 물품 등록자, 입찰자한테 메일을 발송하는 기능
*
* @param picture
*/
@Async
public void newBidMail(Picture picture) {

}


/**
* 등록한 미술품이 기간이 모두 종료되고, 낙찰자가 존해자여 낙찰자, 등록자한테 메일 발송
*
* @param picture
*/
@Async
public void pictureSuccessBidMail(Picture picture) {
PictureBidHistory topHistory = pictureBidHistoryRepository.findTopByPictureOrderByBidAmountDesc(picture)
.orElseThrow(() -> NotFoundException.EXCEPTION);

//등록자 한테 한테 메일 발송
sendMailUtil.sendMail(
picture.getUser().getEmail(),
SUCCESS_BID.getMailTitle(),
PICTURE_SUCCESSBID_MAIL,
new HashMap<>() {{
put("pictureName", picture.getPictureName());
put("bidAmount", topHistory.getBidAmount());
put("link", picassoProperties.getDomain() + "pictures/" + picture.getPictureId());
}}
);

// 낙찰자한테 메일 발송
sendMailUtil.sendMail(
topHistory.getUser().getEmail(),
SUCCESS_BID.getMailTitle(),
PICTURE_SUCCESSBID_MAIL,
new HashMap<>() {{
put("pictureName", picture.getPictureName());
put("bidAmount", topHistory.getBidAmount());
put("link", picassoProperties.getDomain() + "pictures/" + picture.getPictureId());
}}
);
}

/**
Expand All @@ -98,7 +118,15 @@ public void pictureSuccessBidMail(Picture picture) {
*/
@Async
public void pictureRejectMailWithNotApproveAdmin(Picture picture) {

sendMailUtil.sendMail(
picture.getUser().getEmail(),
REJECT.getMailTitle(),
PICTURE_NOT_APPROVE_REJECT_MAIL,
new HashMap<>() {{
put("pictureName", picture.getPictureName());
put("link", picassoProperties.getDomain() + "pictures/" + picture.getPictureId());
}}
);
}

/**
Expand All @@ -109,16 +137,13 @@ public void pictureRejectMailWithNotApproveAdmin(Picture picture) {
@Async
public void pictureRejectMailWithFinishDate(Picture picture) {
sendMailUtil.sendMail(
"donsonic@naver.com",
picture.getUser().getEmail(),
REJECT.getMailTitle(),
PICTURE_NO_BID_REJECT_MAIL,
new HashMap<>() {{
put("pictureName", picture.getPictureName());
put("bidEndDate", picture.getBidEndDate().toString());
put("link", picassoProperties.getDomain() + "pictures/" + picture.getPictureId());
}}
);
}


}
105 changes: 26 additions & 79 deletions Api/src/main/resources/templates/imageList.html
Original file line number Diff line number Diff line change
@@ -1,77 +1,16 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html
lang="ko"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout/layout}"
>
<main layout:fragment="content">
<link rel="stylesheet" type="text/css" href="/static/css/image.css"/>

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>경매</title>
<link rel="stylesheet" href="../static/css/image.css">
<link rel="stylesheet" href="../static/css/bootstrap.css">
<link rel="icon" href="data:,">
</head>
<!--<body class="img12">-->
<!--<header th:include="fragment/header2.html :: header"></header>-->
<!--<section class="special-section">-->
<!-- <div>-->
<!--&lt;!&ndash; <div th:each="imageUrl, idx : ${imageUrls}">&ndash;&gt;-->
<!--&lt;!&ndash; <div class="img-box">&ndash;&gt;-->
<!--&lt;!&ndash; <img th:src="'http://xgrnsxldyejc19608959.cdn.ntruss.com/' + ${imageUrl} + '?type=f&w=300&h=400' "&ndash;&gt;-->
<!--&lt;!&ndash; alt="Image">&ndash;&gt;-->
<!--&lt;!&ndash; <div>&ndash;&gt;-->
<!--&lt;!&ndash; <span>그림명: <span th:text="${pictureDataMap['pictureNames'][idx.index]}"></span></span><br>&ndash;&gt;-->
<!--&lt;!&ndash; <span>화가: <span th:text="${pictureDataMap['painterNames'][idx.index]}"></span></span><br>&ndash;&gt;-->
<!--&lt;!&ndash; <span>설명: <span th:text="${pictureDataMap['details'][idx.index]}"></span></span><br>&ndash;&gt;-->
<!--&lt;!&ndash; <span>가격: <span th:text="${pictureDataMap['startPrices'][idx.index]}"></span></span><br>&ndash;&gt;-->
<!--&lt;!&ndash; <span>Remaining Days: <span th:text="${pictureDataMap['dateDifferences'][idx.index]}"></span></span><br><br>&ndash;&gt;-->

<!--&lt;!&ndash; </div>&ndash;&gt;-->
<!--&lt;!&ndash; </div>&ndash;&gt;-->
<!--&lt;!&ndash; </div>&ndash;&gt;-->
<!-- <div th:each="pictureInfo : ${pictureInfoPage}">-->
<!-- <div class="img-box">-->
<!-- <img th:src="'http://xgrnsxldyejc19608959.cdn.ntruss.com/' + ${pictureInfo.imageUrl} + '?type=f&w=300&h=400' ">-->
<!-- <p>Details: <span th:text="${pictureInfo.details}"></span></p>-->
<!-- <p>Picture Name: <span th:text="${pictureInfo.pictureName}"></span></p>-->
<!-- <p>Painter Name: <span th:text="${pictureInfo.painterName}"></span></p>-->
<!-- <p>Starting Price: <span th:text="${pictureInfo.startPrice}"></span></p>-->
<!-- <p>Increment Amount: <span th:text="${pictureInfo.incrementAmount}"></span></p>-->
<!-- <p>Bid End Date: <span th:text="${pictureInfo.endDay}"></span></p>-->
<!-- </div>-->
<!-- </div>-->



<!-- &lt;!&ndash; Pagination &ndash;&gt;-->
<!--&lt;!&ndash; <div>&ndash;&gt;-->
<!--&lt;!&ndash; <button th:disabled="${!imageUrlsPage.hasPrevious()}" th:href="@{'/list?page=' + ${previousPage} + '&pageSize=' + ${pageSize} + '&status=' + ${status}}">Previous</button>&ndash;&gt;-->
<!--&lt;!&ndash; <span th:text="${nextPage}"></span>&ndash;&gt;-->
<!--&lt;!&ndash; <button th:disabled="${!imageUrlsPage.hasNext()}" th:href="@{'/list?page=' + ${nextPage} + '&pageSize=' + ${pageSize} + '&status=' + ${status}}">Next</button>&ndash;&gt;-->
<!--&lt;!&ndash; </div>&ndash;&gt;-->


<!-- </div>-->
<!--</section>-->
<!--</body>-->
<!--<div class="pagination-links">-->
<!-- <nav aria-label="...">-->
<!-- <ul class="pagination">-->
<!-- <li class="page-item">-->
<!-- <a class="page-link" href="#" onclick="changePage('Previous')">Previous</a>-->
<!-- </li>-->
<!-- <li class="page-item"><a class="page-link" href="#" onclick="changePage(0)">1</a></li>-->
<!-- <li class="page-item"><a class="page-link" href="#" onclick="changePage(1)">2</a></li>-->
<!-- <li class="page-item"><a class="page-link" href="#" onclick="changePage(2)">3</a></li>-->
<!-- <li class="page-item">-->
<!-- <a class="page-link" href="#" onclick="changePage('Next')">Next</a>-->
<!-- </li>-->
<!-- </ul>-->
<!-- </nav>-->
<!--</div>-->
<body class="img12">
<header th:include="fragment/header2.html :: header"></header>
<section class="special-section">
<div class="container">
<div class="container-fluid" style="margin-top:100px;">
<div class="row">
<div th:each="pictureInfo : ${pictureInfoPage}" class="col-md-3">
<div class="card mb-3">
Expand All @@ -80,12 +19,17 @@
class="card-img-top" alt="Picture">
</a>
<div class="card-body">
<h5 class="card-title" th:text="${pictureInfo.pictureName}"></h5>
<p class="card-text">Details: <span th:text="${pictureInfo.details}"></span></p>
<p class="card-text">Painter Name: <span th:text="${pictureInfo.painterName}"></span></p>
<p class="card-text">Starting Price: <span th:text="${pictureInfo.startPrice}"></span></p>
<p class="card-text">Increment Amount: <span th:text="${pictureInfo.incrementAmount}"></span></p>
<p class="card-text">경매 종료 날짜:<br> <span th:text="${pictureInfo.endDay}"></span></p>
<h5 class="card-title d-flex align-items-center" >
<b class="d-inline-block text-truncate" style="max-width: 180px;" th:text="${pictureInfo.pictureName}"></b>
<div class="vr" style="margin-left: 10px;margin-right: 10px;"></div>
<small class="d-inline-block text-truncate" style="max-width: 100px;" th:text="${pictureInfo.painterName}"></small>
</h5>
<div class="row">
<div class="col" >
<span th:text="${pictureInfo.getStartDate()}"></span>~
<span th:text="${pictureInfo.getEndDate()}"></span>
</div>
</div>
</div>
</div>
</div>
Expand All @@ -94,7 +38,7 @@ <h5 class="card-title" th:text="${pictureInfo.pictureName}"></h5>
</section>

<!-- Pagination -->
<div class="pagination-links">
<div class="pagination-links" style="margin-top: 40px;margin-bottom: 40px;">
<nav aria-label="...">
<ul class="pagination">
<li class="page-item">
Expand All @@ -109,8 +53,11 @@ <h5 class="card-title" th:text="${pictureInfo.pictureName}"></h5>
</ul>
</nav>
</div>
</main>
<th:block layout:fragment="script">

<script src="../static/js/imgURL.js"></script>
<script src="../static/js/onClick.js"></script>
</body>
</th:block>

</html>
Loading

0 comments on commit 92efab8

Please sign in to comment.