Skip to content

Commit

Permalink
schedular & mail service test
Browse files Browse the repository at this point in the history
  • Loading branch information
bongsh0112 committed Oct 2, 2023
1 parent 5cdb38c commit 3f2875e
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class StartAuctionScheduler {
private final SendMailService sendMailService;

@Transactional
@Scheduled(cron = "0 0 9 * * *", zone = DateStaticConstants.ZONE_SEOUL)
@Scheduled(cron = "0 * * * * *", zone = DateStaticConstants.ZONE_SEOUL)
public void startApprovePictureToBiddingAuction() {
log.info("Start Todays Auctions Open Schedule Runtime : NowTime >>> {}", LocalDateTime.now());
pictureService
Expand Down
143 changes: 74 additions & 69 deletions Api/src/main/java/picasso/server/api/mail/service/SendMailService.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,18 @@ public class SendMailService {
* @param picture
*/
@Async
public void adminApproveMail(Picture picture) {
sendMailUtil.sendMail(
picture.getUser().getEmail(),
REJECT.getMailTitle(),
PICTURE_APPROVE_MAIL,
new HashMap<>() {{
put("pictureName", picture.getPictureName());
put("startBidDate", picture.getBidStartDate().toString());
put("link", picassoProperties.getDomain() + "pictures/" + picture.getPictureId());
}}
);
public void adminApproveMail(Picture picture) throws InterruptedException {
// sendMailUtil.sendMail(
// picture.getUser().getEmail(),
// REJECT.getMailTitle(),
// PICTURE_APPROVE_MAIL,
// new HashMap<>() {{
// put("pictureName", picture.getPictureName());
// put("startBidDate", picture.getBidStartDate().toString());
// put("link", picassoProperties.getDomain() + "pictures/" + picture.getPictureId());
// }}
// );
Thread.sleep(500);
}

/**
Expand All @@ -63,17 +64,18 @@ public void adminApproveMail(Picture picture) {
* @param picture
*/
@Async
public void startBiddingMail(Picture picture) {
sendMailUtil.sendMail(
picture.getUser().getEmail(),
BIDDING.getMailTitle(),
PICTURE_BIDDING_MAIL,
new HashMap<>() {{
put("pictureName", picture.getPictureName());
put("bidEndDate", picture.getBidEndDate().toString());
put("link", picassoProperties.getDomain() + "pictures/" + picture.getPictureId());
}}
);
public void startBiddingMail(Picture picture) throws InterruptedException {
// sendMailUtil.sendMail(
// picture.getUser().getEmail(),
// BIDDING.getMailTitle(),
// PICTURE_BIDDING_MAIL,
// new HashMap<>() {{
// put("pictureName", picture.getPictureName());
// put("bidEndDate", picture.getBidEndDate().toString());
// put("link", picassoProperties.getDomain() + "pictures/" + picture.getPictureId());
// }}
// );
Thread.sleep(500);
}

/**
Expand All @@ -82,33 +84,34 @@ public void startBiddingMail(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());
}}
);
public void pictureSuccessBidMail(Picture picture) throws InterruptedException {
// 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());
// }}
// );
Thread.sleep(500);
}

/**
Expand All @@ -117,16 +120,17 @@ public void pictureSuccessBidMail(Picture picture) {
* @param 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());
}}
);
public void pictureRejectMailWithNotApproveAdmin(Picture picture) throws InterruptedException {
// 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());
// }}
// );
Thread.sleep(500);
}

/**
Expand All @@ -135,15 +139,16 @@ public void pictureRejectMailWithNotApproveAdmin(Picture picture) {
* @param picture
*/
@Async
public void pictureRejectMailWithFinishDate(Picture picture) {
sendMailUtil.sendMail(
picture.getUser().getEmail(),
REJECT.getMailTitle(),
PICTURE_NO_BID_REJECT_MAIL,
new HashMap<>() {{
put("pictureName", picture.getPictureName());
put("link", picassoProperties.getDomain() + "pictures/" + picture.getPictureId());
}}
);
public void pictureRejectMailWithFinishDate(Picture picture) throws InterruptedException {
// sendMailUtil.sendMail(
// picture.getUser().getEmail(),
// REJECT.getMailTitle(),
// PICTURE_NO_BID_REJECT_MAIL,
// new HashMap<>() {{
// put("pictureName", picture.getPictureName());
// put("link", picassoProperties.getDomain() + "pictures/" + picture.getPictureId());
// }}
// );
Thread.sleep(500);
}
}

0 comments on commit 3f2875e

Please sign in to comment.