Skip to content

Commit

Permalink
[feat] Schedular Sample (#31)
Browse files Browse the repository at this point in the history
* chore : HTML Library추가

- FontAwesome

* feat : 경매 시작, 종료 Scheduler 구현 완료

- 현재 주입받아야할 메일, 그림관련 기능이 없어 실행되는 스케쥴링만 구현 완료
  • Loading branch information
donsonioc2010 authored Sep 18, 2023
1 parent 98d5c64 commit 7f44b48
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Api/src/main/java/picasso/server/api/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableScheduling;

// EnableJpaRepositories Reference : https://stackoverflow.com/questions/46732402/spring-boot-autowiring-of-beans-is-not-working-in-maven-multi-module-project
@Slf4j
@EntityScan("picasso.server.domain")
@ComponentScan(basePackages = {"picasso.server"})
@EnableJpaRepositories(basePackages = {"picasso.server.domain"})
@EnableScheduling // Schedule사용을 위한 Annotation
@SpringBootApplication
@RequiredArgsConstructor
public class Application {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package picasso.server.api.auction.scheduler;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import picasso.server.common.util.DateStaticConstants;

import java.time.LocalDate;

/**
* 18시에 경매 전 상태인 게시물들을 처리하는 스케쥴러
*/

@Slf4j
@Component
@EnableAsync
@RequiredArgsConstructor
public class EndAuctionScheduler {
@Scheduled(cron = "0 0 18 * * *", zone = DateStaticConstants.ZONE_SEOUL)
public void startAuction() {
log.info("End Todays Auctions Open : TodayDate >>> {}", LocalDate.now());

// TODO : 입찰자가 존재하는 경우 입찰 안내 메일 발송 로직 추가 및 상태값 변경

// TODO : 입찰자가 존재하지 않는 경우 유찰 안내 메일 발송 로직 추가 및 상태값 변경
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package picasso.server.api.auction.scheduler;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import picasso.server.common.util.DateStaticConstants;

import java.time.LocalDate;

/**
* 9시에 경매 전 상태인 게시물들을 처리하는 스케쥴러
*/

@Slf4j
@Component
@EnableAsync
@RequiredArgsConstructor
public class StartAuctionScheduler {

@Scheduled(cron = "0 0 9 * * *", zone = DateStaticConstants.ZONE_SEOUL)
public void startAuction() {
log.info("Starting Todays Auctions Open : TodayDate >>> {}", LocalDate.now());
// TODO : 관리자 승인된 게시물 경매 시작 상태로 Status 변경 로직 추가

// TODO : 관리자 승인이 되지 않은 게시물 유찰상태로 변경Status로직 추가 및 메일발송 로직 추가
}
}
3 changes: 3 additions & 0 deletions Api/src/main/resources/templates/fragment/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

<!-- Bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9" crossorigin="anonymous">

<!-- FontAwesome -->
<script src="https://kit.fontawesome.com/6ac784f4b9.js" crossorigin="anonymous"></script>
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<title>Picasso</title>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package picasso.server.common.util;

public class DateStaticConstants {
public static final String ZONE_SEOUL = "Asia/Seoul";
}

0 comments on commit 7f44b48

Please sign in to comment.