Files
CustomAuthenticationEntryPoint/src/main/java/io/beaniejoy/dongnecafe/cafe/controller/CafeController.java
beaniejoy c4a1c849cf [#3] cafe api 개발 및 전반적인 container 환경 설정 세팅
- docker compose 활용한 컨테이너 환경 구축
- cafe 관련 api 구축
- flyway migration db 및 seed data 설정
2021-10-09 02:41:20 +09:00

40 lines
1.4 KiB
Java

package io.beaniejoy.dongnecafe.cafe.controller;
import io.beaniejoy.dongnecafe.cafe.dto.CafeResponseDto;
import io.beaniejoy.dongnecafe.cafe.service.CafeService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.UUID;
@RestController
@RequiredArgsConstructor
@RequestMapping("/cafes")
public class CafeController {
private final CafeService cafeService;
@GetMapping("/")
public ResponseEntity<List<CafeResponseDto>> getCafeList(
@PageableDefault(sort = "name", direction = Sort.Direction.ASC, size = 10) Pageable pageable) {
List<CafeResponseDto> cafeResponseList = cafeService.getCafeList(pageable);
return ResponseEntity.ok(cafeResponseList);
}
@GetMapping("/{cafeId}")
public ResponseEntity<CafeResponseDto> getCafeInfo(@PathVariable("cafeId") UUID cafeId) {
CafeResponseDto cafeResponse = cafeService.getCafeByCafeId(cafeId);
return ResponseEntity.ok(cafeResponse);
}
}