Skip to content

Commit

Permalink
Merge pull request #758 from GraudationProject2023/main
Browse files Browse the repository at this point in the history
PR
  • Loading branch information
dydgus1052 authored Sep 27, 2023
2 parents 8e7a942 + 9e5b695 commit 6e9f11f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
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

0 comments on commit 6e9f11f

Please sign in to comment.