Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backend] 항공권 좋아요 API 응답값 수정 #93

Merged
merged 4 commits into from
Jun 16, 2024
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 @@ -56,11 +56,11 @@ public ResponseEntity<String> getFlightSearchUrl(@AuthenticationPrincipal Custom

/** 항공권 좋아요 저장 API **/
@PostMapping("/like")
public ResponseEntity<Void> addLikeFlight(@AuthenticationPrincipal CustomUserDetails customUserDetails,
public ResponseEntity<Long> addLikeFlight(@AuthenticationPrincipal CustomUserDetails customUserDetails,
@RequestBody FlightLikeRequest flightLikeRequest) {
String memberUid = customUserDetails.getUsername();
flightOfferService.addLikeFlight(memberUid, flightLikeRequest);
return ResponseEntity.status(HttpStatus.CREATED).build();
Long flightId = flightOfferService.addLikeFlight(memberUid, flightLikeRequest);
return ResponseEntity.status(HttpStatus.CREATED).body(flightId);
}

/** 항공권 나의 좋아요 목록 불러오기 API **/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.isp.backend.domain.flight.service;

import com.amadeus.exceptions.ResponseException;
import com.isp.backend.domain.country.entity.Country;
import com.isp.backend.domain.flight.dto.request.FlightLikeRequest;
import com.isp.backend.domain.flight.dto.request.FlightSearchRequest;
import com.isp.backend.domain.flight.dto.request.SkyScannerRequest;
import com.isp.backend.domain.flight.dto.response.FlightLikeResponse;
import com.isp.backend.global.exception.schedule.CountryNotFoundException;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
Expand All @@ -18,7 +16,7 @@ public interface FlightOfferService {
String generateSkyscannerUrl(SkyScannerRequest request);

@Transactional
void addLikeFlight(String uid, FlightLikeRequest flightLikeRequest);
Long addLikeFlight(String uid, FlightLikeRequest flightLikeRequest);

List<FlightLikeResponse> getLikedFlights(String memberUid);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,13 @@ private String buildChildrenParam(int count) {
return childrenBuilder.toString();
}

/** 항공권 좋아요 저장 **/
/**
* 항공권 좋아요 저장
*
**/
@Override
@Transactional
public void addLikeFlight(String uid, FlightLikeRequest flightLikeRequest) {
public Long addLikeFlight(String uid, FlightLikeRequest flightLikeRequest) {
// 유저 정보 확인
Member findMember = scheduleService.validateUserCheck(uid);

Expand All @@ -126,6 +129,7 @@ public void addLikeFlight(String uid, FlightLikeRequest flightLikeRequest) {
// 데이터 변환 및 저장
Flight flight = flightMapper.toEntity(flightLikeRequest, findMember, departureIataCode, arrivalIataCode);
flightRepository.save(flight);
return flight.getId();
}


Expand Down
Loading