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

PR #758

Merged
merged 2 commits into from
Sep 27, 2023
Merged

PR #758

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 @@ -13,13 +13,11 @@
import GraduationProject.TripPlannerZ.dto.member.MemberInfo;
import GraduationProject.TripPlannerZ.dto.member.MemberTrip;
import GraduationProject.TripPlannerZ.dto.trip.TripCreate;
import GraduationProject.TripPlannerZ.dto.trip.TripDelete;
import GraduationProject.TripPlannerZ.dto.trip.TripDetail;
import GraduationProject.TripPlannerZ.repository.MemberPartyRepository;
import GraduationProject.TripPlannerZ.repository.TripImageRepository;
import GraduationProject.TripPlannerZ.service.LocationService;
import GraduationProject.TripPlannerZ.service.MemberService;
import GraduationProject.TripPlannerZ.service.PartyService;
import GraduationProject.TripPlannerZ.service.TripService;
import GraduationProject.TripPlannerZ.service.*;
import GraduationProject.TripPlannerZ.sseEmitter.SseEmitterService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
Expand Down Expand Up @@ -56,6 +54,7 @@ public class TripController {
private final LocationService locationService;
private final CommentService commentService;
private final SseEmitterService sseEmitterService;
private final LoginService loginService;


@PostMapping("/trip/create")
Expand Down Expand Up @@ -210,4 +209,19 @@ public void responseAccompany(@RequestBody CommentResponse commentResponse) {

memberPartyRepository.save(mp);
}

@PostMapping("/trip/delete")
public ResponseEntity<String> deleteTrip(@RequestBody TripDelete tripDelete) {
Member member = loginService.getLoggedInMember();
Trip trip = tripService.findByUUID(tripDelete.getTripUUID()).get();
Member creater = memberService.findByEmail(trip.getCreater().getEmail()).get();

if (member != creater) {
return ResponseEntity.ok().body("not allowed");
}

tripService.deleteTrip(trip);

return ResponseEntity.ok().body("deleted");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package GraduationProject.TripPlannerZ.dto.trip;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class TripDelete {

private String tripUUID;

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ public Page<MemberTrip> findTrip(Member member, String sortType, Pageable pageab
// 회원 탈퇴
@Transactional
public void exit(Member member) {
member.exit();
// member.exit();
memberRepository.delete(member);
List<Long> list = partyRepository.noMemberParty();

for (Long id : list) {
partyRepository.deleteById(id);
}
// List<Long> list = partyRepository.noMemberParty();
//
// for (Long id : list) {
// partyRepository.deleteById(id);
// }
}

// 비밀 번호 변경
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public Long createTrip(Trip trip){
return trip.getId();
}

@Transactional
public Long deleteTrip(Trip trip) {
tripRepository.delete(trip);
return trip.getId();
}

public Optional<Trip> findByUUID(String id){
return tripRepository.findByUUID(id);
}
Expand Down
Loading