diff --git a/src/main/java/com/example/likelion12/common/response/status/BaseExceptionResponseStatus.java b/src/main/java/com/example/likelion12/common/response/status/BaseExceptionResponseStatus.java index 08b3ac6..b09546f 100644 --- a/src/main/java/com/example/likelion12/common/response/status/BaseExceptionResponseStatus.java +++ b/src/main/java/com/example/likelion12/common/response/status/BaseExceptionResponseStatus.java @@ -47,6 +47,10 @@ public enum BaseExceptionResponseStatus implements ResponseStatus{ NOT_MEMBERSOCIALRING_CAPTAIN(8001, HttpStatus.BAD_REQUEST.value(), "소셜링 수정,삭제에 접근할수없는 권한입니다."), CANNOT_FOUND_MEMBERSOCIALRING_LIST(8002, HttpStatus.BAD_REQUEST.value(), "해당하는 멤버소셜링 리스트를 찾을 수 없습니다."), ALREADY_EXIST_IN_SOCIALRING(8003, HttpStatus.BAD_REQUEST.value(), "해당 소셜링에 이미 등록된 멤버입니다."), + N0T_EXIST_JOIN_SOCIALRING(8004, HttpStatus.BAD_REQUEST.value(), "참가 중인 소셜링이 존재하지 않습니다."), + N0T_EXIST_JOIN_BEFORE_SOCIALRING(8005, HttpStatus.BAD_REQUEST.value(), "참가 예정인 소셜링이 존재 하지않습니다."), + N0T_EXIST_JOIN_COMPLETE_SOCIALRING(8006, HttpStatus.BAD_REQUEST.value(), "참가 완료한 소셜링이 존재 하지않습니다."), + CANNOT_CANCEL_BY_CAPTAIN(8007, HttpStatus.BAD_REQUEST.value(), "소셜링 모임장은 소셜링을 나갈 수 없습니다. 소셜링 삭제를 이용해주세요"), /** * 9000 : crew 관련 @@ -64,6 +68,7 @@ public enum BaseExceptionResponseStatus implements ResponseStatus{ ALREADY_EXIST_IN_CREW(10002, HttpStatus.BAD_REQUEST.value(), "해당 크루에 이미 등록된 멤버입니다."), NOT_MEMBERCREW_CAPTAIN(10003, HttpStatus.BAD_REQUEST.value(), "크루 수정,삭제에 접근할수없는 권한입니다."), NOT_CREW_MEMBERCREW(10004, HttpStatus.BAD_REQUEST.value(), "해당 크루에 참여 상태가 아닙니다."), + CANNOT_CREW_CANCEL(10005, HttpStatus.BAD_REQUEST.value(), "해당 크루를 탈퇴 할 수 없습니다. 크루 삭제를 이용해주세요."), /** * 11000 : Review 관련 diff --git a/src/main/java/com/example/likelion12/config/SecurityConfig.java b/src/main/java/com/example/likelion12/config/SecurityConfig.java index d9d1e90..ca10697 100644 --- a/src/main/java/com/example/likelion12/config/SecurityConfig.java +++ b/src/main/java/com/example/likelion12/config/SecurityConfig.java @@ -4,11 +4,17 @@ import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpMethod; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configurers.CsrfConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.CorsConfigurationSource; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; + +import java.util.Arrays; @Configuration @RequiredArgsConstructor @@ -19,16 +25,30 @@ public class SecurityConfig { public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http .csrf(CsrfConfigurer::disable) + .cors(cors -> cors.configurationSource(corsConfigurationSource())) .authorizeHttpRequests(requests -> requests - .requestMatchers("/test", "/auth/kakao/callback", "/user/signup","/main").permitAll() // 이 URL은 모두에게 허용 - .anyRequest().authenticated() // 그 외의 모든 요청은 인증 필요 + .requestMatchers(HttpMethod.OPTIONS, "/**").permitAll() + .requestMatchers("/test", "/auth/kakao/callback", "/user/signup", "/main").permitAll() + .anyRequest().authenticated() ) .sessionManagement(sessionManagement -> sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS) - ) // 세션을 사용하지 않으므로 STATELESS 설정 - .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); // JwtAuthenticationFilter를 UsernamePasswordAuthenticationFilter 전에 추가 + ) + .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); return http.build(); } + + @Bean + public CorsConfigurationSource corsConfigurationSource() { + CorsConfiguration configuration = new CorsConfiguration(); + configuration.setAllowedOrigins(Arrays.asList("http://localhost:3000")); // 허용할 도메인 설정 + configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PATCH", "DELETE")); // 허용할 HTTP 메서드 설정 + configuration.setAllowedHeaders(Arrays.asList("Authorization", "Cache-Control", "Content-Type")); // 허용할 헤더 설정 + configuration.setAllowCredentials(true); // 자격 증명 허용 설정 + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + source.registerCorsConfiguration("/**", configuration); + return source; + } } diff --git a/src/main/java/com/example/likelion12/controller/CrewController.java b/src/main/java/com/example/likelion12/controller/CrewController.java index cc057d1..a0f7647 100644 --- a/src/main/java/com/example/likelion12/controller/CrewController.java +++ b/src/main/java/com/example/likelion12/controller/CrewController.java @@ -99,4 +99,14 @@ public BaseResponse cancelCrew(@RequestHeader("Authorization") String auth return new BaseResponse<>(null); } + /** + * 참여중인 크루 조회 + */ + @GetMapping("/join") + public BaseResponse> getJoinCrew(@RequestHeader("Authorization") String authorization) { + log.info("[CrewController.getJoinCrew]"); + Long memberId = jwtProvider.extractIdFromHeader(authorization); + List joinCrewResponses = crewService.getJoinCrew(memberId); + return new BaseResponse<>(joinCrewResponses); + } } diff --git a/src/main/java/com/example/likelion12/controller/SocialringController.java b/src/main/java/com/example/likelion12/controller/SocialringController.java index c4d125e..dc86c1a 100644 --- a/src/main/java/com/example/likelion12/controller/SocialringController.java +++ b/src/main/java/com/example/likelion12/controller/SocialringController.java @@ -79,6 +79,26 @@ public BaseResponse> searchFilterSocialr } /** + * 참가 예정인 소셜링 + */ + @GetMapping("/join/before") + public BaseResponse> joinBeforeSocialring(@RequestHeader("Authorization") String authorization){ + log.info("[SocialringController.joinBeforeSocialring]"); + Long memberId = jwtProvider.extractIdFromHeader(authorization); + return new BaseResponse<>(socialringService.joinBeforeSocialring(memberId)); + } + + /** + * 참가 완료한 소셜링 + */ + @GetMapping("/join/complete") + public BaseResponse> joinCompleteSocialring(@RequestHeader("Authorization") String authorization){ + log.info("[SocialringController.joinCompleteSocialring]"); + Long memberId = jwtProvider.extractIdFromHeader(authorization); + return new BaseResponse<>(socialringService.joinCompleteSocialring(memberId)); + } + + /** * 소셜링 삭제하기 */ @PatchMapping("/delete") @@ -89,4 +109,17 @@ public BaseResponse deleteSocialring(@RequestHeader("Authorization") Strin socialringService.deleteSocialring(memberId, socialringId); return new BaseResponse<>(BaseExceptionResponseStatus.SUCCESS, null); } + + /** + * 소셜링 취소하기 + */ + @PatchMapping("/cancel") + public BaseResponse cancelSocialring(@RequestHeader("Authorization") String authorization, + @RequestParam("socialringId") Long socialringId) { + log.info("[SocialringController.cancelSocialring]"); + Long memberId = jwtProvider.extractIdFromHeader(authorization); + socialringService.cancelSocialring(memberId, socialringId); + return new BaseResponse<>(BaseExceptionResponseStatus.SUCCESS, null); + } + } diff --git a/src/main/java/com/example/likelion12/domain/MemberSocialring.java b/src/main/java/com/example/likelion12/domain/MemberSocialring.java index 2304e8d..b8bfbae 100644 --- a/src/main/java/com/example/likelion12/domain/MemberSocialring.java +++ b/src/main/java/com/example/likelion12/domain/MemberSocialring.java @@ -46,6 +46,11 @@ public MemberSocialring(BaseRole baseRole, Socialring socialring, Member member, this.status = baseStatus; } + // 상태를 'delete'로 변경하는 메서드 + public void setStatusToDelete() { + this.status = BaseStatus.DELETE; + } + public void setStatus(BaseStatus status) { this.status = status; } diff --git a/src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java b/src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java new file mode 100644 index 0000000..90bb2dc --- /dev/null +++ b/src/main/java/com/example/likelion12/dto/crew/GetJoinCrewResponse.java @@ -0,0 +1,24 @@ +package com.example.likelion12.dto.crew; + +import com.example.likelion12.domain.MemberCrew; +import com.example.likelion12.domain.base.BaseLevel; +import com.example.likelion12.domain.base.BaseRole; +import com.example.likelion12.domain.base.BaseStatus; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +public class GetJoinCrewResponse { + + private String crewName; + private String crewImg; + private String commentSimple; + private String exercise_name; + private String activty_area_name; + private BaseLevel level; +} diff --git a/src/main/java/com/example/likelion12/dto/socialring/GetSocialringJoinStatusResponse.java b/src/main/java/com/example/likelion12/dto/socialring/GetSocialringJoinStatusResponse.java new file mode 100644 index 0000000..bc7f805 --- /dev/null +++ b/src/main/java/com/example/likelion12/dto/socialring/GetSocialringJoinStatusResponse.java @@ -0,0 +1,25 @@ +package com.example.likelion12.dto.socialring; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.time.LocalDate; + +@Getter +@AllArgsConstructor +public class GetSocialringJoinStatusResponse { + + /** + * 소셜링 참여상태 response dto + */ + private Long socialringId; + private String socialringName; + private String socialringImg; + private String activityRegionName; + private LocalDate socialringDate; + private int socialringCost; + private String commentSimple; + private int currentRecruits; + private int totalRecruits; + +} diff --git a/src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterResponse.java b/src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterResponse.java index ba714a9..eda89c5 100644 --- a/src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterResponse.java +++ b/src/main/java/com/example/likelion12/dto/socialring/GetSocialringSearchFilterResponse.java @@ -2,6 +2,13 @@ import lombok.AllArgsConstructor; import lombok.Getter; +import com.example.likelion12.domain.base.BaseGender; +import com.example.likelion12.domain.base.BaseLevel; +import com.example.likelion12.domain.base.BaseRole; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.time.LocalDate; @Getter @AllArgsConstructor @@ -10,6 +17,14 @@ public class GetSocialringSearchFilterResponse { /** * 소셜링 검색결과필터링 response dto */ - private long socialringId; + private Long socialringId; + private String socialringName; + private String socialringImg; + private String activityRegionName; + private LocalDate socialringDate; + private int socialringCost; + private String commentSimple; + private int currentRecruits; + private int totalRecruits; } diff --git a/src/main/java/com/example/likelion12/repository/MemberSocialringRepository.java b/src/main/java/com/example/likelion12/repository/MemberSocialringRepository.java index 18b6203..d67925b 100644 --- a/src/main/java/com/example/likelion12/repository/MemberSocialringRepository.java +++ b/src/main/java/com/example/likelion12/repository/MemberSocialringRepository.java @@ -12,6 +12,7 @@ public interface MemberSocialringRepository extends JpaRepository findByMember_MemberIdAndSocialring_SocialringIdAndStatus(Long memberId, Long socialringId, BaseStatus status); Optional> findBySocialring_SocialringIdAndStatus(Long socialringId, BaseStatus baseStatus); boolean existsByMember_MemberIdAndSocialring_SocialringIdAndStatus(Long memberId, Long socialringId, BaseStatus status); + Optional> findByMember_MemberIdAndAndStatus(Long memberId, BaseStatus baseStatus); } diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index 89646d0..e386088 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -1,9 +1,11 @@ package com.example.likelion12.service; import com.example.likelion12.common.exception.*; +import com.example.likelion12.common.response.BaseResponse; import com.example.likelion12.domain.*; import com.example.likelion12.domain.base.BaseGender; import com.example.likelion12.domain.base.BaseLevel; +import com.example.likelion12.domain.base.BaseRole; import com.example.likelion12.domain.base.BaseStatus; import com.example.likelion12.dto.crew.*; import com.example.likelion12.repository.*; @@ -313,22 +315,60 @@ public void cancelCrew(Long memberId, Long crewId) { // 크루를 탈퇴하고자 하는 member Member member = memberRepository.findByMemberIdAndStatus(memberId, BaseStatus.ACTIVE) - .orElseThrow(()-> new MemberException(CANNOT_FOUND_MEMBER)); + .orElseThrow(() -> new MemberException(CANNOT_FOUND_MEMBER)); //탈퇴하고자 하는 크루 Crew crew = crewRepository.findByCrewIdAndStatus(crewId, BaseStatus.ACTIVE) - .orElseThrow(()->new CrewException(CANNOT_FOUND_CREW)); + .orElseThrow(() -> new CrewException(CANNOT_FOUND_CREW)); //탈퇴하고자 하는 크루의 멤버크루 //해당크루와 관계없음(해당크루에 등록되있지 않음), 멤버크루가 존재하지않음 - MemberCrew memberCrew = memberCrewRepository.findByMember_MemberIdAndCrew_CrewIdAndStatus( memberId, crewId, BaseStatus.ACTIVE) - .orElseThrow(()->new MemberCrewException(NOT_CREW_MEMBERCREW)); + MemberCrew memberCrew = memberCrewRepository.findByMember_MemberIdAndCrew_CrewIdAndStatus(memberId, crewId, BaseStatus.ACTIVE) + .orElseThrow(() -> new MemberCrewException(NOT_CREW_MEMBERCREW)); + + //CAPTAIN일 경우 예외처리 --> 크루삭제 + if (BaseRole.CAPTAIN.equals(memberCrew.getRole())){ + throw new MemberCrewException(CANNOT_CREW_CANCEL); + } + //크루 탈퇴 + else { + //멤버크루 삭제 + memberCrew.DeleteMemberCrewInfo(BaseStatus.DELETE); + memberCrewRepository.save(memberCrew); + } + + } - //CAPTAIN일 경우 크루 삭제 - if(memberCrewService.ConfirmCaptainMemberCrew(memberCrew)) - deleteCrew(memberId,crewId); - else //크루 탈퇴 - memberCrewRepository.delete(memberCrew); + /** + * 참여중인 크루 조회하기 + */ + @Transactional + public List getJoinCrew(Long memberId) { + log.info("[CrewService.getJoinCrew]"); + + // 멤버Id로 멤버찾고 + Member member = memberRepository.findByMemberIdAndStatus(memberId, BaseStatus.ACTIVE) + .orElseThrow(()-> new MemberException(CANNOT_FOUND_MEMBER)); + + // 멤버가 가지고 있는 멤버크루를 리스트로 가져오고 + List memberCrewList = member.getMemberCrewList(); + + // 그 멤버크루로 속해있는 크루들을 가져와서 필요한 정보만 dto에 담고 + List joinCrewResponses = memberCrewList.stream() + .map(memberCrew -> { + Crew crew = memberCrew.getCrew(); + return new GetJoinCrewResponse( + crew.getCrewName(), + crew.getCrewImg(), + crew.getCommentSimple(), + crew.getActivityRegion().getActivityRegionName(), + crew.getExercise().getExerciseName(), + crew.getLevel() + ); + }) + .collect(Collectors.toList()); + // 반환하기 + return joinCrewResponses; } } diff --git a/src/main/java/com/example/likelion12/service/MemberCrewService.java b/src/main/java/com/example/likelion12/service/MemberCrewService.java index 3c7c31d..41ed6cc 100644 --- a/src/main/java/com/example/likelion12/service/MemberCrewService.java +++ b/src/main/java/com/example/likelion12/service/MemberCrewService.java @@ -45,12 +45,11 @@ public void createMemberCrew(Member member, Crew crew){ /** * 크루 수정,삭제 시 접근하는 member가 CAPTAIN 인지 확인 */ - public boolean ConfirmCaptainMemberCrew(MemberCrew memberCrew) { + public void ConfirmCaptainMemberCrew(MemberCrew memberCrew) { log.info("[MemberCrewService.ConfirmCaptainMemberCrew]"); if (!BaseRole.CAPTAIN.equals(memberCrew.getRole())) { throw new MemberCrewException(NOT_MEMBERCREW_CAPTAIN); } - return true; } } diff --git a/src/main/java/com/example/likelion12/service/SocialringService.java b/src/main/java/com/example/likelion12/service/SocialringService.java index 627d090..de8206d 100644 --- a/src/main/java/com/example/likelion12/service/SocialringService.java +++ b/src/main/java/com/example/likelion12/service/SocialringService.java @@ -4,6 +4,7 @@ import com.example.likelion12.domain.*; import com.example.likelion12.domain.base.BaseGender; import com.example.likelion12.domain.base.BaseLevel; +import com.example.likelion12.domain.base.BaseRole; import com.example.likelion12.domain.base.BaseStatus; import com.example.likelion12.dto.socialring.*; import com.example.likelion12.repository.*; @@ -228,6 +229,110 @@ public void joinSocialring(Long memberId, Long socialringId) { } } + /** + * 참가 예정인 소셜링 + */ + @Transactional + public List joinBeforeSocialring(Long memberId) { + log.info("[SocialringService.joinBeforeSocialring]"); + + Member member = memberRepository.findByMemberIdAndStatus(memberId, BaseStatus.ACTIVE) + .orElseThrow(() -> new MemberException(CANNOT_FOUND_MEMBER)); + + //현재 날짜 + LocalDate nowDate = LocalDate.now(); + + // 멤버의 멤버소셜링리스트 추출 + List memberSocialringList = memberSocialringRepository.findByMember_MemberIdAndAndStatus(memberId,BaseStatus.ACTIVE) + .orElseThrow(() -> new MemberSocialringException(CANNOT_FOUND_MEMBERSOCIALRING)); + + // 참가중인 소셜링이 없을때 예외처리 + if(memberSocialringList.isEmpty()) + throw new MemberSocialringException(N0T_EXIST_JOIN_SOCIALRING); + + // 멤버가 참여한 멤버소셜링 리스트 중에서 현재 날짜보다 더 나중인 소셜링을 추출 + List memberInjoinBeforeSocialrings = new ArrayList<>(); + for(MemberSocialring memberSocialring : memberSocialringList ){ + LocalDate socialringDate = memberSocialring.getSocialring().getSocialringDate(); + if(socialringDate.isAfter(nowDate)){ + memberInjoinBeforeSocialrings.add(memberSocialring.getSocialring()); + } + } + + //참가 예정인 소셜링이 존재하지않을떄 예외처리 + if(memberInjoinBeforeSocialrings.isEmpty()) + throw new MemberSocialringException(N0T_EXIST_JOIN_BEFORE_SOCIALRING); + + List responseList = new ArrayList<>(); + for(Socialring socialring : memberInjoinBeforeSocialrings ){ + + // 현재 참여중인 소셜링원 수 확인하기 + int currentSocialrings = memberSocialringRepository.findBySocialring_SocialringIdAndStatus(socialring.getSocialringId(),BaseStatus.ACTIVE) + .orElseThrow(()-> new MemberSocialringException(CANNOT_FOUND_MEMBERSOCIALRING_LIST)).size(); + + GetSocialringJoinStatusResponse response = new GetSocialringJoinStatusResponse(socialring.getSocialringId(), + socialring.getSocialringName(),socialring.getSocialringImg(),socialring.getActivityRegion().getActivityRegionName(), + socialring.getSocialringDate(),socialring.getSocialringCost(),socialring.getCommentSimple(),currentSocialrings, + socialring.getTotalRecruits() + ); + responseList.add(response); + } + + return responseList; + + } + + /** + * 참가 완료한 소셜링 + */ + @Transactional + public List joinCompleteSocialring(Long memberId) { + log.info("[SocialringService.joinCompleteSocialring]"); + + Member member = memberRepository.findByMemberIdAndStatus(memberId, BaseStatus.ACTIVE) + .orElseThrow(() -> new MemberException(CANNOT_FOUND_MEMBER)); + + //현재 날짜 + LocalDate nowDate = LocalDate.now(); + + // 멤버의 멤버소셜링리스트 추출 + List memberSocialringList = memberSocialringRepository.findByMember_MemberIdAndAndStatus(memberId,BaseStatus.ACTIVE) + .orElseThrow(() -> new MemberSocialringException(CANNOT_FOUND_MEMBERSOCIALRING)); + + // 참가중인 소셜링이 없을때 예외처리 + if(memberSocialringList.isEmpty()) + throw new MemberSocialringException(N0T_EXIST_JOIN_SOCIALRING); + + // 멤버가 참여한 멤버소셜링 리스트 중에서 현재 날짜보다 더 전인 소셜링을 추출 + List memberInjoinBeforeSocialrings = new ArrayList<>(); + for(MemberSocialring memberSocialring : memberSocialringList ){ + LocalDate socialringDate = memberSocialring.getSocialring().getSocialringDate(); + if(socialringDate.isBefore(nowDate)){ + memberInjoinBeforeSocialrings.add(memberSocialring.getSocialring()); + } + } + + //참가 예정인 소셜링이 존재하지않을떄 예외처리 + if(memberInjoinBeforeSocialrings.isEmpty()) + throw new MemberSocialringException(N0T_EXIST_JOIN_COMPLETE_SOCIALRING); + + List responseList = new ArrayList<>(); + for(Socialring socialring : memberInjoinBeforeSocialrings ){ + + // 현재 참여중인 소셜링원 수 확인하기 + int currentSocialrings = memberSocialringRepository.findBySocialring_SocialringIdAndStatus(socialring.getSocialringId(),BaseStatus.ACTIVE) + .orElseThrow(()-> new MemberSocialringException(CANNOT_FOUND_MEMBERSOCIALRING_LIST)).size(); + + GetSocialringJoinStatusResponse response = new GetSocialringJoinStatusResponse(socialring.getSocialringId(), + socialring.getSocialringName(),socialring.getSocialringImg(),socialring.getActivityRegion().getActivityRegionName(), + socialring.getSocialringDate(),socialring.getSocialringCost(),socialring.getCommentSimple(),currentSocialrings, + socialring.getTotalRecruits() + ); + responseList.add(response); + } + + return responseList; + } /** * 소셜링 검색결과 필터링 */ @@ -299,11 +404,17 @@ else if (matchesCriteria && getSocialringSearchFilterRequest.getTotalRecruitsMax matchesCriteria = false; } } + // 현재 참여중인 소셜링원 수 확인하기 + int currentSocialrings = memberSocialringRepository.findBySocialring_SocialringIdAndStatus(socialring.getSocialringId(),BaseStatus.ACTIVE) + .orElseThrow(()-> new MemberSocialringException(CANNOT_FOUND_MEMBERSOCIALRING_LIST)).size(); // 조건에 맞으면 응답 리스트에 추가 if (matchesCriteria) { GetSocialringSearchFilterResponse response = - new GetSocialringSearchFilterResponse(socialring.getSocialringId()); + new GetSocialringSearchFilterResponse(socialring.getSocialringId(), + socialring.getSocialringName(),socialring.getSocialringImg(), + socialring.getActivityRegion().getActivityRegionName(),socialring.getSocialringDate(), + socialring.getSocialringCost(),socialring.getCommentSimple(),currentSocialrings,socialring.getTotalRecruits()); responseList.add(response); } } @@ -315,7 +426,8 @@ else if (matchesCriteria && getSocialringSearchFilterRequest.getTotalRecruitsMax return responseList; } - /** + + /** * 소셜링 삭제하기 */ @Transactional @@ -351,4 +463,37 @@ public void deleteSocialring(Long memberId, Long socialringId) { memberSocialringRepository.save(memberSocialringEntry); } } + + /** + * 소셜링 취소 + */ + @Transactional + public void cancelSocialring(Long memberId, Long socialringId) { + log.info("[SocialringService.cancelSocialring]"); + + // 소셜링을 취소하고자 하는 멤버 찾고 + Member member = memberRepository.findByMemberIdAndStatus(memberId, BaseStatus.ACTIVE) + .orElseThrow(() -> new MemberException(CANNOT_FOUND_MEMBER)); + + // 취소하고자 하는 소셜링 찾고 + Socialring socialring = socialringRepository.findBySocialringIdAndStatus(socialringId, BaseStatus.ACTIVE) + .orElseThrow(() -> new SocialringException(CANNOT_FOUND_SOCIALRING)); + + // 해당 소셜링에 등록된 멤버 소셜링 중, 취소할 멤버의 멤버소셜링 값을 가져와서 + MemberSocialring memberSocialring = memberSocialringRepository.findByMember_MemberIdAndSocialring_SocialringIdAndStatus(memberId, + socialringId, BaseStatus.ACTIVE).orElseThrow(() -> new MemberSocialringException(CANNOT_FOUND_MEMBERSOCIALRING)); + + // 가져온 멤버 소셜링의 값으로 캡틴인지 확인하고 + memberSocialringService.ConfirmCaptainMemberSocialring(memberSocialring); + + // 캡틴인 경우 예외 발생 + if (memberSocialring.getRole() == BaseRole.CAPTAIN) { + throw new MemberSocialringException(CANNOT_CANCEL_BY_CAPTAIN); + } + + // 캡틴이 아닌경우 정상적으로 상태를 DELETE로 변경 + memberSocialring.setStatusToDelete(); + memberSocialringRepository.save(memberSocialring); + } + } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index fc45c65..0f93bb8 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -27,7 +27,6 @@ spring: kakao: client-id: ${CLIENT_ID} redirect-uri: http://43.202.94.241:8080/auth/kakao/callback - --- jwt: secret: ${JWT_SECRET}