Skip to content

Commit

Permalink
Add ResponseEntity<BaseResponse>>
Browse files Browse the repository at this point in the history
  • Loading branch information
Fagorym committed Feb 29, 2024
1 parent e769e5d commit 4fb5062
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,28 @@

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import ru.nsu.fit.directors.userservice.dto.CompanyDto;
import ru.nsu.fit.directors.userservice.dto.request.ReviewCreationDto;
import ru.nsu.fit.directors.userservice.dto.response.BaseResponse;
import ru.nsu.fit.directors.userservice.dto.response.EstablishmentListDto;
import ru.nsu.fit.directors.userservice.dto.response.ResponseReviewDto;
import ru.nsu.fit.directors.userservice.model.Company;

@FeignClient("establishment-service")
public interface EstablishmentServiceClient {
@RequestMapping(method = RequestMethod.GET, value = "/establishment", produces = MediaType.APPLICATION_JSON_VALUE)
Company getCompanyById(@RequestParam Long establishmentId);
ResponseEntity<BaseResponse<Company>> getCompanyById(@RequestParam Long establishmentId);

@RequestMapping(method = RequestMethod.GET, value = "/internal/establishment", produces = MediaType.APPLICATION_JSON_VALUE)
List<CompanyDto> getCompaniesByIds(@RequestParam List<Long> ids);
ResponseEntity<BaseResponse<List<CompanyDto>>> getCompaniesByIds(@RequestParam List<Long> ids);

@RequestMapping(method = RequestMethod.GET, value = "/establishment/all", produces = MediaType.APPLICATION_JSON_VALUE)
EstablishmentListDto searchEstablishments(
ResponseEntity<BaseResponse<EstablishmentListDto>> searchEstablishments(
@RequestParam Optional<String> name,
@RequestParam Optional<Boolean> hasMap,
@RequestParam Optional<Boolean> hasCardPayment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import ru.nsu.fit.directors.userservice.dto.response.BaseResponse;
import ru.nsu.fit.directors.userservice.dto.response.ResponseOrderDto;

@FeignClient("order-service")
public interface OrderServiceClient {
@RequestMapping(method = RequestMethod.GET, value = "/order", produces = MediaType.APPLICATION_JSON_VALUE)
List<ResponseOrderDto> getUserOrders(@RequestParam Long userId, @RequestParam Optional<Integer> status);
@RequestMapping(method = RequestMethod.GET, value = "/order", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<BaseResponse<List<ResponseOrderDto>>> getUserOrders(@RequestParam Long userId, @RequestParam Optional<Integer> status);

@RequestMapping(method = RequestMethod.GET, value = "/order/id", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseOrderDto getOrderById(@RequestParam Long id);
@RequestMapping(method = RequestMethod.GET, value = "/order/id", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<BaseResponse<ResponseOrderDto>> getOrderById(@RequestParam Long id);
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public class CompanyService {
private final EstablishmentServiceClient establishmentServiceClient;

public Company getCompanyById(Long establishmentId) {
return establishmentServiceClient.getCompanyById(establishmentId);
return establishmentServiceClient.getCompanyById(establishmentId).getBody().getResult();
}

public List<CompanyDto> getCompaniesByIds(List<Long> ids) {
return establishmentServiceClient.getCompaniesByIds(ids);
return establishmentServiceClient.getCompaniesByIds(ids).getBody().getResult();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public EstablishmentListDto getEstablishmentByParams(RequestGetEstablishmentPara
Optional.ofNullable(parameters.hasMap()),
Optional.ofNullable(parameters.hasCardPayment()),
Optional.ofNullable(parameters.category())
);
).getBody().getResult();
establishmentInfoList.establishments().forEach(
info -> info.setFavourite(favouritesService.getFavouritesIds().contains(info.getId()))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void cancelOrder(Long orderId) {
@Nonnull
public List<ResponseOrderDto> getOrders(@Nullable Integer status) {
User loggedUser = securityService.getLoggedInUser();
return orderServiceClient.getUserOrders(loggedUser.getId(), Optional.ofNullable(status));
return orderServiceClient.getUserOrders(loggedUser.getId(), Optional.ofNullable(status)).getBody().getResult();
}

@Override
Expand Down

0 comments on commit 4fb5062

Please sign in to comment.