Skip to content

Commit

Permalink
develop 브랜치와 머지 충돌 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
손명진 authored and 손명진 committed Aug 5, 2024
2 parents 7c54e5a + 28386c0 commit d0e7634
Show file tree
Hide file tree
Showing 26 changed files with 634 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.likelion12.common.exception;

import com.example.likelion12.common.response.status.ResponseStatus;
import lombok.Getter;

@Getter
public class ReviewException extends RuntimeException{
private final ResponseStatus exceptionStatus;

public ReviewException(ResponseStatus exceptionStatus) {
super(exceptionStatus.getMessage());
this.exceptionStatus = exceptionStatus;
}

public ReviewException(ResponseStatus exceptionStatus, String message) {
super(message);
this.exceptionStatus = exceptionStatus;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.likelion12.common.exception_handler;

import com.example.likelion12.common.exception.MemberCrewException;
import com.example.likelion12.common.exception.ReviewException;
import com.example.likelion12.common.response.BaseErrorResponse;
import jakarta.annotation.Priority;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@Priority(0)
@RestControllerAdvice
public class ReviewExceptionControllerAdvice {
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(ReviewException.class)
public BaseErrorResponse handle_ReviewException(ReviewException e) {
log.error("[handle_ReviewException]", e);
return new BaseErrorResponse(e.getExceptionStatus(), e.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ public enum BaseExceptionResponseStatus implements ResponseStatus{
* 8000: member socialring 관련
*/
CANNOT_FOUND_MEMBERSOCIALRING(8000, HttpStatus.BAD_REQUEST.value(), "해당하는 멤버소셜링을 찾을 수 없습니다."),
CANNOT_MEMBERSOCIALRING_CAPTAIN(8001, HttpStatus.BAD_REQUEST.value(), "소셜링 수정,삭제에 접근할수없는 권한입니다."),
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(), "해당 소셜링에 이미 등록된 멤버입니다."),
CANNOT_CANCEL_BY_CAPTAIN(8004, 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 관련
Expand All @@ -62,8 +65,16 @@ public enum BaseExceptionResponseStatus implements ResponseStatus{
*/
CANNOT_FOUND_MEMBERCREW(10000, HttpStatus.BAD_REQUEST.value(), "멤버_크루를 찾을 수 없습니다."),
CANNOT_FOUND_MEMBERCREW_LIST(10001, HttpStatus.BAD_REQUEST.value(), "멤버_크루 리스트를 찾을 수 없습니다."),
ALREADY_EXIST_IN_CREW(10002, HttpStatus.BAD_REQUEST.value(), "해당 크루에 이미 등록된 멤버입니다.");
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(), "해당 크루에 참여 상태가 아닙니다."),

/**
* 11000 : Review 관련
*/
CANNOT_FOUND_REVIEW(11000, HttpStatus.BAD_REQUEST.value(), "리뷰를 찾을 수 없습니다."),
ALREADY_EXIST_REVIEW(11001, HttpStatus.BAD_REQUEST.value(), "이미 등록한 리뷰가 있습니다. 수정으로 작성해주세요."),
CANNOT_SET_SCORE(11002, HttpStatus.BAD_REQUEST.value(), "점수가 너무 높거나 낮습니다. 1~5점으로 평가해주세요"); // 추가된 상수


private final int code;
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/example/likelion12/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
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
Expand All @@ -19,6 +24,7 @@ public class SecurityConfig {
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.csrf(CsrfConfigurer<HttpSecurity>::disable)
.cors(cors -> cors.configurationSource(corsConfigurationSource())) // CORS 설정 추가
.authorizeHttpRequests(requests ->
requests
.requestMatchers("/test", "/auth/kakao/callback", "/user/signup","/main").permitAll() // 이 URL은 모두에게 허용
Expand All @@ -31,4 +37,16 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {

return http.build();
}

@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Arrays.asList("http://example.com")); // 허용할 도메인 설정
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE")); // 허용할 HTTP 메서드 설정
configuration.setAllowedHeaders(Arrays.asList("*")); // 허용할 헤더 설정
configuration.setAllowCredentials(true); // 자격 증명 허용 설정
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,28 @@ public BaseResponse<Void> joinCrew(@RequestHeader("Authorization") String author
return new BaseResponse<>(null);
}

/**
* 크루 삭제하기
*/
@PatchMapping("/delete")
public BaseResponse<Void> deleteCrew(@RequestHeader("Authorization") String authorization,
@RequestParam Long crewId){
log.info("[CrewController.deleteCrew]");
Long memberId = jwtProvider.extractIdFromHeader(authorization);
crewService.deleteCrew(memberId,crewId);
return new BaseResponse<>(null);
}

/**
* 크루 탈퇴하기
*/
@PatchMapping("/cancel")
public BaseResponse<Void> cancelCrew(@RequestHeader("Authorization") String authorization,
@RequestParam Long crewId){
log.info("[CrewController.deleteCrew]");
Long memberId = jwtProvider.extractIdFromHeader(authorization);
crewService.cancelCrew(memberId,crewId);
return new BaseResponse<>(null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
import com.example.likelion12.dto.member.PostSignupRequest;
import com.example.likelion12.dto.member.PostSignupResponse;
import com.example.likelion12.service.MemberService;
import com.example.likelion12.util.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
Expand All @@ -18,10 +16,33 @@
public class MemberController {

private final MemberService memberService;
private final JwtProvider jwtProvider;

/**
* 회원가입
*/
@PostMapping("/signup")
public BaseResponse<PostSignupResponse> signUp(@RequestBody PostSignupRequest postSignupRequest){
log.info("[MemberController.signUp]");
return new BaseResponse<>(memberService.signUp(postSignupRequest));
}

@PatchMapping("/signout")
public BaseResponse<String> signOut(@RequestHeader("Authorization") String authorization){
Long memberId = jwtProvider.extractIdFromHeader(authorization);
memberService.signOut(memberId);
return new BaseResponse<>("회원탈퇴 되었습니다");
}

/**
* 로그아웃
*/
@PostMapping("/logout")
public BaseResponse<Void> logout(@RequestHeader("Authorization") String authorization){
log.info("[MemberController.logout]");
Long memberId = jwtProvider.extractIdFromHeader(authorization);
memberService.logout(memberId);
return new BaseResponse<>(null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,38 @@ public BaseResponse<PostReviewResponse> createReview(@RequestHeader("Authorizati
memberId);
PostReviewResponse response = new PostReviewResponse(reviewId);
return new BaseResponse<>(response);

}

@PatchMapping("/delete")
public BaseResponse<String> deleteReview(@RequestHeader("Authorization") String authorization,
@RequestParam("review-id") Long reviewId) {
Long memberId = jwtProvider.extractIdFromHeader(authorization);


boolean isDeleted = reviewService.deleteReview(reviewId, memberId);
if (isDeleted) {
// 삭제 성공 시 응답 생성
return new BaseResponse<>("리뷰를 성공적으로 삭제했습니다");
}
else {
// 삭제 실패 시 응답 생성
return new BaseResponse<>("리뷰가 삭제되지 않았습니다");
}
}

@PatchMapping
public BaseResponse<String> updateReview(@RequestHeader("Authorization") String authorization,
@RequestParam("review-id") Long reviewId,
@RequestBody PostReviewRequest postReviewRequest) {
Long memberId = jwtProvider.extractIdFromHeader(authorization);

reviewService.updateReview(reviewId,
postReviewRequest.getFacilityId(),
postReviewRequest.getRanking(),
postReviewRequest.getComment(),
memberId);

return new BaseResponse<>("리뷰가 성공적으로 업데이트되었습니다");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

import com.example.likelion12.common.response.BaseResponse;
import com.example.likelion12.common.response.status.BaseExceptionResponseStatus;
import com.example.likelion12.dto.socialring.GetSocialringDetailResponse;
import com.example.likelion12.dto.socialring.PatchSocialringModifyRequest;
import com.example.likelion12.dto.socialring.PostSocialringRequest;
import com.example.likelion12.dto.socialring.PostSocialringResponse;
import com.example.likelion12.dto.socialring.*;
import com.example.likelion12.service.SocialringService;
import com.example.likelion12.util.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequiredArgsConstructor
Expand Down Expand Up @@ -67,6 +66,38 @@ public BaseResponse<Void> joinSocialring(@RequestHeader("Authorization") String
return new BaseResponse<>(BaseExceptionResponseStatus.SUCCESS, null);
}

/**
* 참가 예정인 소셜링
*/
@GetMapping("/join/before")
public BaseResponse<List<GetSocialringJoinStatusResponse>> 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<List<GetSocialringJoinStatusResponse>> joinCompleteSocialring(@RequestHeader("Authorization") String authorization){
log.info("[SocialringController.joinCompleteSocialring]");
Long memberId = jwtProvider.extractIdFromHeader(authorization);
return new BaseResponse<>(socialringService.joinCompleteSocialring(memberId));
}

/**
* 소셜링 삭제하기
*/
@PatchMapping("/delete")
public BaseResponse<Void> deleteSocialring(@RequestHeader("Authorization") String authorization,
@RequestParam("socialringId") Long socialringId) {
log.info("[SocialringController.deleteSocialring]");
Long memberId = jwtProvider.extractIdFromHeader(authorization);
socialringService.deleteSocialring(memberId, socialringId);
return new BaseResponse<>(BaseExceptionResponseStatus.SUCCESS, null);
}

/**
* 소셜링 취소하기
*/
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/example/likelion12/domain/Crew.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,8 @@ public Crew(String crewName, String crewImg, int totalRecruits, int crewCost,
this.exercise = exercise;
this.status = status;
}

public void DeleteCrewInfo(BaseStatus status) {
this.status= status;
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/example/likelion12/domain/Facility.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Facility extends BaseTime {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "facility_id", nullable = false)
private long facilityId;
private Long facilityId;

@Column(nullable = false)
private String facilityName;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/example/likelion12/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@ public Member(String memberName, String email, String memberImg, BaseGender gend
this.status = status;
this.exercise = exercise;
}

public void setStatus(BaseStatus status) {
this.status = status;
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/example/likelion12/domain/MemberCrew.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ public MemberCrew (BaseRole role, Crew crew, Member member, BaseStatus status){
this.member = member;
this.status = status;
}

public void DeleteMemberCrewInfo(BaseStatus status) {
this.status= status;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ public MemberSocialring(BaseRole baseRole, Socialring socialring, Member member,
public void setStatusToDelete() {
this.status = BaseStatus.DELETE;
}

public void setStatus(BaseStatus status) {
this.status = status;
}
}
Loading

0 comments on commit d0e7634

Please sign in to comment.