-
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.
Merge branch 'refs/heads/main' into gib/#12
# Conflicts: # src/main/java/com/demo/chattodo/domain/controller/ScheduleController.java # src/main/java/com/demo/chattodo/domain/service/ScheduleService.java # src/main/resources/init.sql
- Loading branch information
Showing
11 changed files
with
257 additions
and
12 deletions.
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
src/main/java/com/demo/chattodo/configure/QuerydslConfig.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,20 @@ | ||
package com.demo.chattodo.configure; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
|
||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.PersistenceContext; | ||
|
||
@Configuration | ||
public class QuerydslConfig { | ||
@PersistenceContext | ||
private EntityManager entityManager; | ||
|
||
@Bean | ||
public JPAQueryFactory jpaQueryFactory() { | ||
return new JPAQueryFactory(entityManager); | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
src/main/java/com/demo/chattodo/domain/dto/response/ScheduleInfoResponseDTO.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,16 @@ | ||
package com.demo.chattodo.domain.dto.response; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class ScheduleInfoResponseDTO { | ||
private Long id; | ||
private String title; | ||
private LocalDateTime startDateTime; | ||
private LocalDateTime endDateTime; | ||
private String place; | ||
} |
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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/demo/chattodo/domain/repository/ScheduleRepositoryCustom.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,12 @@ | ||
package com.demo.chattodo.domain.repository; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import com.demo.chattodo.domain.entity.Schedule; | ||
|
||
public interface ScheduleRepositoryCustom { | ||
// 여러 조건들을 통해 일정 가져오기 | ||
List<Schedule> searchAllByConditions(String memberId, LocalDateTime startDateTime, LocalDateTime endDateTime, | ||
String title, String place); | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/com/demo/chattodo/domain/repository/ScheduleRepositoryImpl.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,58 @@ | ||
package com.demo.chattodo.domain.repository; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Repository; | ||
|
||
import com.demo.chattodo.domain.entity.QSchedule; | ||
import com.demo.chattodo.domain.entity.Schedule; | ||
import com.querydsl.core.BooleanBuilder; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class ScheduleRepositoryImpl implements ScheduleRepositoryCustom { | ||
private final JPAQueryFactory queryFactory; | ||
|
||
// 여러 조건들을 통해 일정 가져오기 | ||
@Override | ||
public List<Schedule> searchAllByConditions(String memberId, LocalDateTime startDateTime, LocalDateTime endDateTime, | ||
String title, | ||
String place) { | ||
QSchedule schedule = QSchedule.schedule; | ||
|
||
BooleanBuilder builder = new BooleanBuilder(); | ||
|
||
// 멤버 ID는 필수 조건 | ||
builder.and(schedule.memberId.eq(memberId)); | ||
|
||
// 시작일시 조건 | ||
if (startDateTime != null) { | ||
builder.and(schedule.startDateTime.goe(startDateTime)); | ||
} | ||
|
||
// 종료일시 조건 | ||
if (endDateTime != null) { | ||
builder.and(schedule.endDateTime.loe(endDateTime)); | ||
} | ||
|
||
// 제목 조건 (부분 일치) | ||
if (title != null && !title.isEmpty()) { | ||
builder.and(schedule.title.containsIgnoreCase(title)); | ||
} | ||
|
||
// 장소 조건 (부분 일치) | ||
if (place != null && !place.isEmpty()) { | ||
builder.and(schedule.place.containsIgnoreCase(place)); | ||
} | ||
|
||
return queryFactory | ||
.selectFrom(schedule) | ||
.where(builder) | ||
.orderBy(schedule.startDateTime.asc()) | ||
.fetch(); | ||
} | ||
} |
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