[#41] feat: 카페 검색 api 수정
- 프론트 테스트겸 카페 검색 api 수정(이름 조건 추가) - security 설정 관련 내용 수정(파일 이동) - flyway seed data 내용 수정(image)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
DROP PROCEDURE IF EXISTS insertCafeImages;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE insertCafeImages()
|
||||
BEGIN
|
||||
@@ -15,10 +17,10 @@ BEGIN
|
||||
|
||||
WHILE(j <= 3) DO
|
||||
INSERT IGNORE INTO `cafe_image` (img_url, created_at, created_by, updated_at, updated_by, cafe_id)
|
||||
VALUES (CONCAT('test_img_url_', idx_img), now(), 'system', now(), 'system', var_cafe_id);
|
||||
VALUES (CONCAT('https://d3qy02qh8hbgxp.cloudfront.net/cafe', idx_img, '.jpg'), now(), 'system', now(), 'system', var_cafe_id);
|
||||
|
||||
SET j = j + 1;
|
||||
SET idx_img = idx_img + 1;
|
||||
SET idx_img = idx_img % 7 + 1;
|
||||
END WHILE;
|
||||
|
||||
SET i = i + 1;
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package io.beaniejoy.dongnecafe.domain.cafe.repository
|
||||
|
||||
import io.beaniejoy.dongnecafe.domain.cafe.entity.Cafe
|
||||
import org.springframework.data.domain.Page
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
|
||||
interface CafeRepository : JpaRepository<Cafe, Long> {
|
||||
fun findByName(name: String): Cafe?
|
||||
|
||||
fun findByNameContainingIgnoreCase(name: String?, pageable: Pageable): Page<Cafe>
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package io.beaniejoy.dongnecafe.common.config
|
||||
|
||||
import io.beaniejoy.dongnecafe.security.JwtAuthenticationConfigurer
|
||||
import io.beaniejoy.dongnecafe.security.JwtTokenUtils
|
||||
import io.beaniejoy.dongnecafe.security.handler.CustomAccessDeniedHandler
|
||||
import io.beaniejoy.dongnecafe.security.handler.CustomAuthenticationEntryPoint
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.autoconfigure.security.servlet.PathRequest
|
||||
import org.springframework.context.annotation.Bean
|
||||
@@ -18,6 +20,12 @@ class SecurityConfig {
|
||||
@Autowired
|
||||
lateinit var jwtTokenUtils: JwtTokenUtils
|
||||
|
||||
@Autowired
|
||||
lateinit var customAccessDeniedHandler: CustomAccessDeniedHandler
|
||||
|
||||
@Autowired
|
||||
lateinit var customAuthenticationEntryPoint: CustomAuthenticationEntryPoint
|
||||
|
||||
@Bean
|
||||
fun filterChain(http: HttpSecurity): SecurityFilterChain {
|
||||
return http
|
||||
@@ -26,7 +34,8 @@ class SecurityConfig {
|
||||
.formLogin().disable()
|
||||
|
||||
.authorizeRequests()
|
||||
.anyRequest().authenticated()
|
||||
// .anyRequest().authenticated()
|
||||
.anyRequest().permitAll()
|
||||
|
||||
.and()
|
||||
.sessionManagement()
|
||||
@@ -34,6 +43,11 @@ class SecurityConfig {
|
||||
|
||||
.and()
|
||||
.also { jwtAuthenticationConfigurer(it) }
|
||||
.exceptionHandling()
|
||||
.authenticationEntryPoint(customAuthenticationEntryPoint) // 인증 예외 entryPoint 적용
|
||||
.accessDeniedHandler(customAccessDeniedHandler) // 인가 예외 handler 적용
|
||||
|
||||
.and()
|
||||
.build()
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,10 @@ class CafeController(
|
||||
*/
|
||||
@GetMapping
|
||||
fun searchCafeList(
|
||||
@RequestParam("name") name: String?,
|
||||
@PageableDefault(sort = ["name"], direction = Sort.Direction.ASC, page = 0, size = 10) pageable: Pageable
|
||||
): ApplicationResponse<Page<CafeSearchInfo>> {
|
||||
val searchCafes = cafeService.searchCafeList(pageable)
|
||||
val searchCafes = cafeService.searchCafeList(name, pageable)
|
||||
|
||||
return ApplicationResponse
|
||||
.success()
|
||||
|
||||
@@ -59,8 +59,8 @@ class CafeService(
|
||||
}
|
||||
}
|
||||
|
||||
fun searchCafeList(pageable: Pageable): Page<CafeSearchInfo> {
|
||||
val cafeList: Page<Cafe> = cafeRepository.findAll(pageable)
|
||||
fun searchCafeList(name: String?, pageable: Pageable): Page<CafeSearchInfo> {
|
||||
val cafeList: Page<Cafe> = cafeRepository.findByNameContainingIgnoreCase(name, pageable)
|
||||
|
||||
return cafeList.map { CafeSearchInfo.of(it) }
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ flyway info -configFiles="$PROJECT_ROOT_DIR/db/$FLYWAY_CONFIG_FILE"
|
||||
printf "\n"
|
||||
|
||||
echo "2. Flyway Migrate"
|
||||
flyway migrate -configFiles="$PROJECT_ROOT_DIR/db/$FLYWAY_CONFIG_FILE"
|
||||
flyway migrate -configFiles="$PROJECT_ROOT_DIR/db/$FLYWAY_CONFIG_FILE" -outputType=json
|
||||
printf "\n"
|
||||
|
||||
echo "3. Flyway Validate"
|
||||
flyway validate -configFiles="$PROJECT_ROOT_DIR/db/$FLYWAY_CONFIG_FILE"
|
||||
flyway validate -configFiles="$PROJECT_ROOT_DIR/db/$FLYWAY_CONFIG_FILE" -outputType=json
|
||||
|
||||
Reference in New Issue
Block a user