Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ManagerSignupRequestDto {
private String password;

@NotBlank
@Pattern(regexp = "^[a-zA-Z가-]{2,12}$")
@Pattern(regexp = "^[a-zA-Z가-힣0-9]{2,12}$", message = "2~12자 사이의 영문, 한글, 숫자만 입력 가능합니다.")
@Schema(description = "이름(예시)", example = "김노웻")
private String nickname;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ public ResponseEntity<?> getStoreById(@PathVariable Long storeId) {
@GetMapping("/search")
@Operation(summary = "주점 이름으로 주점 검색", description = "주점 이름을 기준으로 주점을 검색합니다.")
@ApiResponse(responseCode = "200", description = "주점 검색 성공")
public ResponseEntity<?> searchStores(@RequestParam("name") String name) {
public ResponseEntity<?> searchStores(@RequestParam("keyword") String keyword) {
return ResponseEntity
.ok()
.body(
ApiUtils.success(
storeService.searchStoresByName(name)
storeService.searchByKeywordNative(keyword)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public interface StoreService {

StorePageReadDto getStoreByStoreId(Long storeId);

List<StorePageReadDto> searchStoresByName(String name);
List<StorePageReadDto> searchByKeywordNative(String name);

}
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,14 @@ public StorePageReadDto getStoreByStoreId(Long storeId) {
}

@Override
public List<StorePageReadDto> searchStoresByName(String name) {
if (name == null || name.isBlank()) {
public List<StorePageReadDto> searchByKeywordNative(String keyword) {
if (keyword == null || keyword.isBlank()) {
throw new StoreParamEmptyException();
}

// 1) 페이징된 Store 스냅샷 조회
List<Store> stores = storeRepository.findByNameContainingIgnoreCaseAndDeletedFalse(name);
// List<Store> stores = storeRepository.findByNameContainingIgnoreCaseAndDeletedFalse(keyword);
List<Store> stores = storeRepository.searchByKeywordNative(keyword);

// 2) 각 StoreId / Department ID 추출
List<Long> storeIds = stores.stream()
Expand Down
1 change: 0 additions & 1 deletion nowait-domain/domain-core-rdb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok:1.18.26'

//QueryDsl
// TODO Q클래스 생성시 오류 발생 해결 필요
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.nowait.domainadminrdb.config;
package com.nowait.domaincorerdb.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.nowait.domaincorerdb.store.repository;

public interface StoreCustomRepository {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.nowait.domaincorerdb.store.repository;

import org.springframework.stereotype.Repository;

import com.nowait.domaincorerdb.store.entity.QStore;
import com.querydsl.jpa.impl.JPAQueryFactory;

import lombok.RequiredArgsConstructor;

@Repository
@RequiredArgsConstructor
public class StoreCustomRepositoryImpl implements StoreCustomRepository {

private final JPAQueryFactory queryFactory;

private final QStore store = QStore.store;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,30 @@
import org.springframework.data.domain.Slice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.nowait.domaincorerdb.store.entity.Store;

@Repository
public interface StoreRepository extends JpaRepository<Store, Long> {
public interface StoreRepository extends JpaRepository<Store, Long>, StoreCustomRepository {

List<Store> findAllByDeletedFalse();

Optional<Store> findByStoreIdAndDeletedFalse(Long storeId);

List<Store> findByNameContainingIgnoreCaseAndDeletedFalse(String name);

Slice<Store> findAllByDeletedFalseOrderByStoreIdAsc(Pageable pageable);

// TODO queryDSL으로 전환?
@Query("select s.storeId from Store s where s.isActive = true and s.deleted = false")
List<Long> findAllActiveStoreIds();
@Query(value = """
SELECT DISTINCT s.*
FROM stores s
LEFT JOIN departments d ON s.department_id = d.id
WHERE s.deleted = false
AND (
MATCH(s.name) AGAINST(:kw)
OR MATCH(d.name) AGAINST(:kw)
)
""",
nativeQuery = true)
List<Store> searchByKeywordNative(@Param("kw") String booleanKeyword);
}