-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* REFACTOR: COGO 신청 로직 변경 * FEAT: Add ApplicationCleanupAspect
- Loading branch information
Showing
11 changed files
with
240 additions
and
198 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/com/soongsil/CoffeeChat/aspect/ApplicationCleanupAspect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.soongsil.CoffeeChat.aspect; | ||
|
||
import com.soongsil.CoffeeChat.repository.ApplicationRepository; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Component | ||
@Aspect | ||
public class ApplicationCleanupAspect { | ||
|
||
private final ApplicationRepository applicationRepository; | ||
|
||
public ApplicationCleanupAspect(ApplicationRepository applicationRepository) { | ||
this.applicationRepository = applicationRepository; | ||
} | ||
|
||
@Scheduled(cron = "0 0 0 * * ?") | ||
@Transactional | ||
public void deleteExpiredApplications() { | ||
// 매일 자정에 현재 시간보다 이전인 COGO 삭제 | ||
applicationRepository.deleteExpiredApplications(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 43 additions & 43 deletions
86
src/main/java/com/soongsil/CoffeeChat/dto/PossibleDateCreateGetResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,59 @@ | ||
package com.soongsil.CoffeeChat.dto; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.querydsl.core.annotations.QueryProjection; | ||
import com.soongsil.CoffeeChat.entity.PossibleDate; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.*; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
|
||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Data | ||
public class PossibleDateCreateGetResponseDto { | ||
@JsonProperty("possible_date_id") | ||
private Long possibledateId; | ||
|
||
@JsonProperty("date") | ||
@JsonFormat(pattern = "yyyy-MM-dd") | ||
private LocalDate date; | ||
|
||
@JsonProperty("start_time") | ||
@Schema(type = "string", pattern = "hh:mm:ss") | ||
private LocalTime startTime; | ||
|
||
@JsonProperty("end_time") | ||
@Schema(type = "string", pattern = "hh:mm:ss") | ||
private LocalTime endTime; | ||
|
||
@JsonIgnore | ||
|
||
@QueryProjection | ||
public PossibleDateCreateGetResponseDto(LocalDate date, LocalTime startTime, LocalTime endTime, | ||
Long possibledateId) { | ||
this.date = date; | ||
this.startTime = startTime; | ||
this.endTime = endTime; | ||
this.possibledateId = possibledateId; | ||
} | ||
|
||
public static PossibleDateCreateGetResponseDto from(PossibleDate possibleDate) { | ||
return PossibleDateCreateGetResponseDto.builder() | ||
.date(possibleDate.getDate()) | ||
.startTime(possibleDate.getStartTime()) | ||
.endTime(possibleDate.getEndTime()) | ||
.possibledateId(possibleDate.getId()) | ||
.build(); | ||
} | ||
@JsonProperty("possible_date_id") | ||
private Long possibledateId; | ||
|
||
@JsonProperty("date") | ||
@JsonFormat(pattern = "yyyy-MM-dd") | ||
private LocalDate date; | ||
|
||
@JsonProperty("start_time") | ||
@Schema(type = "string", pattern = "hh:mm:ss") | ||
private LocalTime startTime; | ||
|
||
@JsonProperty("end_time") | ||
@Schema(type = "string", pattern = "hh:mm:ss") | ||
private LocalTime endTime; | ||
|
||
@JsonProperty("is_active") | ||
private boolean isActive; | ||
|
||
@JsonIgnore | ||
|
||
@QueryProjection | ||
public PossibleDateCreateGetResponseDto(LocalDate date, LocalTime startTime, LocalTime endTime, | ||
Long possibledateId, boolean isActive) { | ||
this.date = date; | ||
this.startTime = startTime; | ||
this.endTime = endTime; | ||
this.possibledateId = possibledateId; | ||
this.isActive = isActive; | ||
} | ||
|
||
public static PossibleDateCreateGetResponseDto from(PossibleDate possibleDate) { | ||
return PossibleDateCreateGetResponseDto.builder() | ||
.date(possibleDate.getDate()) | ||
.startTime(possibleDate.getStartTime()) | ||
.endTime(possibleDate.getEndTime()) | ||
.possibledateId(possibleDate.getId()) | ||
.isActive(possibleDate.isActive()) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 19 additions & 6 deletions
25
src/main/java/com/soongsil/CoffeeChat/repository/ApplicationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
package com.soongsil.CoffeeChat.repository; | ||
|
||
import java.util.List; | ||
|
||
import com.soongsil.CoffeeChat.entity.Application; | ||
import com.soongsil.CoffeeChat.entity.Mentee; | ||
import com.soongsil.CoffeeChat.entity.Mentor; | ||
import com.soongsil.CoffeeChat.entity.PossibleDate; | ||
import com.soongsil.CoffeeChat.enums.ApplicationStatus; | ||
import jakarta.transaction.Transactional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import com.soongsil.CoffeeChat.entity.Application; | ||
import com.soongsil.CoffeeChat.entity.Mentor; | ||
import java.util.List; | ||
|
||
public interface ApplicationRepository extends JpaRepository<Application, Long> { | ||
List<Application> findApplicationByMentor(Mentor mentor); | ||
List<Application> findApplicationByMentee(Mentee mentee); | ||
List<Application> findApplicationByMentor(Mentor mentor); | ||
|
||
List<Application> findApplicationByMentee(Mentee mentee); | ||
|
||
List<Application> findByPossibleDateAndAccept(PossibleDate possibleDate, ApplicationStatus accept); | ||
|
||
@Modifying | ||
@Transactional | ||
@Query("DELETE FROM Application a WHERE a.possibleDate.date < CURRENT_DATE " + | ||
"OR (a.possibleDate.date = CURRENT_DATE AND a.possibleDate.startTime < CURRENT_TIME)") | ||
void deleteExpiredApplications(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.