Skip to content
Open
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
@@ -0,0 +1,35 @@
package com.cheffi.backoffice.controller;

import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.cheffi.backoffice.service.AdminRestaurantService;
import com.cheffi.common.response.ApiPageResponse;
import com.cheffi.review.domain.Restaurant;

import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;

@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("${api.prefix}/backoffice/restaurants")
public class AdminRestaurantController {

private final AdminRestaurantService adminRestaurantService;

@GetMapping
public ApiPageResponse<Restaurant> searchRestaurants(
@Parameter(hidden = true)
@PageableDefault(size = 10, sort = "createdDate", direction = Sort.Direction.DESC) Pageable pageable,
@RequestParam(required = false) String name
) {
return ApiPageResponse.success(adminRestaurantService.findAllRes(pageable, name));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.cheffi.backoffice.service;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.cheffi.review.domain.Restaurant;
import com.cheffi.review.repository.RestaurantRepository;

import lombok.RequiredArgsConstructor;

@Service
@RequiredArgsConstructor
public class AdminRestaurantService {

private final RestaurantRepository restaurantRepository;

public Page<Restaurant> findAllRes(Pageable pageable, String name) {
return restaurantRepository.findByNameContaining(name, pageable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.springframework.web.bind.annotation.RestController;

import com.cheffi.common.response.ApiResponse;
import com.cheffi.review.domain.Restaurant;
import com.cheffi.review.dto.RestaurantInfoDto;
import com.cheffi.review.dto.request.QueryRestaurantRequest;
import com.cheffi.review.dto.request.RegisterRestaurantRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.cheffi.notice.domain.Notice;
import com.cheffi.review.domain.Restaurant;

public interface RestaurantRepository extends JpaRepository<Restaurant, Long> {
Expand Down