-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 일정찾기 - 키워드로 검색기능 #34
base: dev
Are you sure you want to change the base?
Changes from all commits
39095a7
e1f0c4e
30ee9e0
3d4ed75
c1ee92b
0310a1c
475f7ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.catcher.core.db; | ||
|
||
import com.catcher.core.domain.entity.Schedule; | ||
|
||
import java.util.List; | ||
|
||
public interface ScheduleRepository { | ||
|
||
/** | ||
* 키워드로 스케줄 검색 | ||
* | ||
* @param keyword | ||
* @return | ||
*/ | ||
List<Schedule> findScheduleByKeywordAndFilter( | ||
final String keyword | ||
// final Long budget, | ||
// final ZonedDateTime startAt, | ||
// final ZonedDateTime endAt | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,4 @@ public class UploadFile { | |
|
||
@Column(name = "deleted_at") | ||
private ZonedDateTime deletedAt; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
public enum ContentType { | ||
COMMENT, COMMENTREPLY, SCHEDULEDETAIL, SCHEDULE | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.catcher.core.dto; | ||
|
||
import com.catcher.core.domain.entity.Location; | ||
import lombok.Data; | ||
|
||
import java.time.ZonedDateTime; | ||
|
||
@Data | ||
public class ScheduleCondition { | ||
|
||
private String keyword; | ||
|
||
// private String them; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 없어도 되는 부분이면 지워도 좋을거같아용! |
||
|
||
private Long budget; | ||
|
||
private ZonedDateTime startAt; | ||
|
||
private ZonedDateTime endAt; | ||
|
||
private Location location; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.catcher.core.service; | ||
|
||
import com.catcher.core.db.ScheduleRepository; | ||
import com.catcher.core.domain.entity.Schedule; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ScheduleService { | ||
private final ScheduleRepository scheduleRepository; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. scheduleRepository 는 jpa repository를 직접 참조하고 있는데 수정이 필요할거같아용 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이해 안되시면 배치 서비스에 구현된 방법을 참고하셔도 될 것 같아요 |
||
|
||
public List<Schedule> getScheduleByKeywordAndFilter( | ||
final String keyword | ||
// final Long budget, | ||
// final ZonedDateTime startAt, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기도 주석이 혹시 필요한 부분일까요? |
||
// final ZonedDateTime endAt | ||
|
||
){ | ||
final List<Schedule> schedules = scheduleRepository.findScheduleByKeywordAndFilter( | ||
keyword | ||
// budget, | ||
// startAt, | ||
// endAt | ||
); | ||
return schedules; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.catcher.datasource.config; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.PersistenceContext; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class QuerydslConfig { | ||
|
||
@PersistenceContext | ||
private EntityManager entityManager; | ||
|
||
@Bean | ||
public JPAQueryFactory jpaQueryFactory() { | ||
return new JPAQueryFactory(entityManager); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.catcher.datasource.schedule; | ||
|
||
import com.catcher.core.domain.entity.Schedule; | ||
import com.catcher.core.db.ScheduleRepository; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
public interface ScheduleJpaRepository extends JpaRepository<Schedule, Long> { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.catcher.datasource.schedule; | ||
|
||
import com.catcher.core.db.ScheduleRepository; | ||
import com.catcher.core.domain.entity.QSchedule; | ||
import com.catcher.core.domain.entity.Schedule; | ||
import com.querydsl.core.types.dsl.BooleanExpression; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public class ScheduleRepositoryImpl extends QuerydslRepositorySupport implements ScheduleRepository { | ||
|
||
private final JPAQueryFactory jpaQueryFactory; | ||
private static final QSchedule SCHEDULE = QSchedule.schedule; | ||
|
||
public ScheduleRepositoryImpl(JPAQueryFactory queryFactory) { | ||
super(Schedule.class); | ||
this.jpaQueryFactory = queryFactory; | ||
} | ||
|
||
@Override | ||
public List<Schedule> findScheduleByKeywordAndFilter( | ||
final String keyword | ||
// final Long budget, | ||
// final ZonedDateTime startAt, | ||
// final ZonedDateTime endAt | ||
) { | ||
return jpaQueryFactory | ||
.select(SCHEDULE) | ||
.from(SCHEDULE) | ||
.where( | ||
containsKeywordInTitle(keyword) | ||
) | ||
.fetch(); | ||
} | ||
|
||
private BooleanExpression containsKeywordInTitle(final String keyword) { | ||
return SCHEDULE.title.contains(keyword); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.catcher.resource; | ||
|
||
import com.catcher.common.response.CommonResponse; | ||
import com.catcher.core.domain.entity.Schedule; | ||
import com.catcher.core.service.ScheduleService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
@RestController | ||
@RequestMapping("/schedule") | ||
@RequiredArgsConstructor | ||
public class ScheduleController { | ||
|
||
private final ScheduleService scheduleService; | ||
|
||
|
||
@GetMapping("/list") | ||
public CommonResponse<List<Schedule>> getScheduleByKeywordAndFilter( | ||
@RequestParam(defaultValue = "") String keyword | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 디폴트가 빈 스트링이면 아무것도 안썼을때 정상동작하나요?? |
||
){ | ||
List<Schedule> scheduleByKeywordAndFilter = scheduleService.getScheduleByKeywordAndFilter(keyword); | ||
|
||
return CommonResponse.success(200, scheduleByKeywordAndFilter); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
얘는 사용 안하는것 같은데 사용하시다가 지운건가요?