Skip to content

Commit

Permalink
Merge branch 'develop' into 8-be-소셜링-검색-구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jsilver01 authored Aug 5, 2024
2 parents 88e610f + d848a6b commit 19bf571
Show file tree
Hide file tree
Showing 18 changed files with 625 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public enum BaseExceptionResponseStatus implements ResponseStatus{
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(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 @@ -67,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 관련
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/com/example/likelion12/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;
Expand All @@ -24,26 +25,27 @@ public class SecurityConfig {
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.csrf(CsrfConfigurer<HttpSecurity>::disable)
.cors(cors -> cors.configurationSource(corsConfigurationSource())) // CORS 설정 추가
.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://example.com")); // 허용할 도메인 설정
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE")); // 허용할 HTTP 메서드 설정
configuration.setAllowedHeaders(Arrays.asList("*")); // 허용할 헤더 설정
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package com.example.likelion12.controller;

import com.example.likelion12.common.response.BaseResponse;
import com.example.likelion12.dto.crew.GetCrewDetailResponse;
import com.example.likelion12.dto.crew.PostCrewRequest;
import com.example.likelion12.dto.crew.PostCrewResponse;
import com.example.likelion12.common.response.status.BaseExceptionResponseStatus;
import com.example.likelion12.dto.crew.*;
import com.example.likelion12.service.CrewService;
import com.example.likelion12.util.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequiredArgsConstructor
Expand All @@ -29,6 +31,17 @@ public BaseResponse<PostCrewResponse> createCrew(@RequestHeader("Authorization")
Long memberId = jwtProvider.extractIdFromHeader(authorization);
return new BaseResponse<>(crewService.createCrew(memberId, postCrewRequest));
}
/**
* 크루 조회
*/
@GetMapping("/inquiry")
public BaseResponse<List<GetCrewInquiryResponse>> getCrewInquiries(@RequestHeader("Authorization") String authorization,
@RequestParam int page){
log.info("[CrewController.getCrewInquiries]");
Long memberId = jwtProvider.extractIdFromHeader(authorization);
return new BaseResponse<>(crewService.getCrewInquiries(memberId,page));
}


/**
* 크루 상세 조회
Expand All @@ -53,6 +66,17 @@ public BaseResponse<Void> joinCrew(@RequestHeader("Authorization") String author
return new BaseResponse<>(null);
}

/**
* 크루 검색결과 필터링
*/
@GetMapping("/search/filter")
public BaseResponse<List<GetCrewSearchFilterResponse>> searchFilterCrew(@RequestHeader("Authorization") String authorization,
@RequestBody GetCrewSearchFilterRequest getCrewSearchFilterRequest) {
log.info("[CrewController.searchFilterCrew]");
Long memberId = jwtProvider.extractIdFromHeader(authorization);
return new BaseResponse<>(crewService.searchFilterCrew(memberId, getCrewSearchFilterRequest));
}

/**
* 크루 삭제하기
*/
Expand All @@ -77,4 +101,27 @@ public BaseResponse<Void> cancelCrew(@RequestHeader("Authorization") String auth
return new BaseResponse<>(null);
}

/**
* 크루 검색
*/
@GetMapping("/search")
public BaseResponse<Page<GetCrewSearchResponse>> searchCrews(
@RequestParam(required = false) String keyWord,
@RequestParam(required = false) String activityRegionName,
@RequestParam(required = false) String exerciseName,
@RequestParam(defaultValue = "0") int page
) {
Page<GetCrewSearchResponse> responses = crewService.searchCrews(keyWord, activityRegionName, exerciseName,page, 9);
return new BaseResponse<>(BaseExceptionResponseStatus.SUCCESS, responses);
}
/**
* 참여중인 크루 조회
*/
@GetMapping("/join")
public BaseResponse<List<GetJoinCrewResponse>> getJoinCrew(@RequestHeader("Authorization") String authorization) {
log.info("[CrewController.getJoinCrew]");
Long memberId = jwtProvider.extractIdFromHeader(authorization);
List<GetJoinCrewResponse> joinCrewResponses = crewService.getJoinCrew(memberId);
return new BaseResponse<>(joinCrewResponses);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.example.likelion12.common.response.BaseResponse;
import com.example.likelion12.common.response.status.BaseExceptionResponseStatus;
import com.example.likelion12.dto.crew.GetCrewInquiryResponse;
import com.example.likelion12.dto.socialring.*;
import com.example.likelion12.service.SocialringService;
import com.example.likelion12.util.*;
Expand Down Expand Up @@ -68,6 +69,17 @@ public BaseResponse<Void> joinSocialring(@RequestHeader("Authorization") String
return new BaseResponse<>(BaseExceptionResponseStatus.SUCCESS, null);
}

/**
* 소셜링 검색결과 필터링
*/
@GetMapping("/search/filter")
public BaseResponse<List<GetSocialringSearchFilterResponse>> searchFilterSocialring(@RequestHeader("Authorization") String authorization,
@RequestBody GetSocialringSearchFilterRequest getSocialringSearchFilterRequest){
log.info("[SocialringController.searchFilterSocialring]");
Long memberId = jwtProvider.extractIdFromHeader(authorization);
return new BaseResponse<>(socialringService.searchFilterSocialring(memberId, getSocialringSearchFilterRequest));
}

/**
* 참가 예정인 소셜링
*/
Expand Down Expand Up @@ -114,4 +126,17 @@ public BaseResponse<Page<GetSocialringSearchResponse>> searchSocialrings(
Page<GetSocialringSearchResponse> responses = socialringService.searchSocialrings(keyWord, socialringDate, activityRegionName, page, 9);
return new BaseResponse<>(BaseExceptionResponseStatus.SUCCESS, responses);
}

/**
* 소셜링 취소하기
*/
@PatchMapping("/cancel")
public BaseResponse<Void> 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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.likelion12.dto.crew;

import com.example.likelion12.domain.base.BaseLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class GetCrewInquiryResponse {
/**
* 크루 조회 response dto
*/
private String crewName;
private String crewImg;
private String activityRegionName;
private String exerciseName;
private BaseLevel level;
private String commentSimple;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.likelion12.dto.crew;

import com.example.likelion12.domain.base.BaseGender;
import com.example.likelion12.domain.base.BaseLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class GetCrewSearchFilterRequest {

/**
* 크루 검색결과 필터링 request dto
*/
private BaseGender gender;
private BaseLevel level;
private Integer crewCostMin;
private Integer crewCostMax;
private Integer totalRecruitsMin;
private Integer totalRecruitsMax;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.likelion12.dto.crew;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class GetCrewSearchFilterResponse {
/**
* 크루 검색결과 필터링 response dto
*/
private Long crewId;
private String crewName;
private String crewImg;
private int crewCost;
private String activityRegionName;
private String exerciseName;
private int currentRecruits;
private int totalRecruits;
private String commentSimple;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.likelion12.dto.crew;

import com.example.likelion12.domain.base.BaseLevel;
import lombok.AllArgsConstructor;
import lombok.Data;

@AllArgsConstructor
@Data
public class GetCrewSearchResponse {

private long crewId;
private String crewName;
private String crewImg;
private String activeAreaName;
private String commentSimple;
private BaseLevel level;
private String exerciseName;
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.likelion12.dto.socialring;

import com.example.likelion12.domain.base.BaseGender;
import com.example.likelion12.domain.base.BaseLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;


@Getter
@AllArgsConstructor
public class GetSocialringSearchFilterRequest {

/**
* 소셜링 검색결과 필터링 request dto
*/

private String exerciseName;
private BaseGender gender;
private BaseLevel level;
private Integer socialringCostMin;
private Integer socialringCostMax;
private Integer totalRecruitsMin;
private Integer totalRecruitsMax;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.example.likelion12.dto.socialring;

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
public class GetSocialringSearchFilterResponse {

/**
* 소셜링 검색결과필터링 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;

}
Loading

0 comments on commit 19bf571

Please sign in to comment.