Skip to content

Commit

Permalink
MATE-118 : [FEAT] 메이트 관련 기능 url에서 memberId 제거 (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
MisaSohee authored Dec 7, 2024
1 parent afee259 commit 707770a
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.example.mate.common.response.ApiResponse;
import com.example.mate.common.response.PageResponse;
import com.example.mate.common.security.auth.AuthMember;
import com.example.mate.common.validator.ValidPageable;
import com.example.mate.domain.constant.Gender;
import com.example.mate.domain.mate.dto.request.*;
Expand All @@ -18,6 +19,7 @@
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

Expand All @@ -33,12 +35,12 @@ public class MateController {

@PostMapping
@Operation(summary = "메이트 구인글 등록", description = "메이트 구인글 페이지에서 등록합니다.")
public ResponseEntity<ApiResponse<MatePostResponse>> createMatePost(
@Parameter(description = "구인글 등록 데이터", required = true) @Valid @RequestPart(value = "data") MatePostCreateRequest request,
@Parameter(description = "구인글 대표사진", required = true) @RequestPart(value = "file", required = false) MultipartFile file
) {
//TODO - member 정보를 request가 아니라 @AuthenticationPrincipal Long memberId로 받도록 변경
MatePostResponse response = mateService.createMatePost(request, file);
public ResponseEntity<ApiResponse<MatePostResponse>> createMatePost(@Parameter(description = "구인글 등록 데이터", required = true)
@Valid @RequestPart(value = "data") MatePostCreateRequest request,
@Parameter(description = "구인글 대표사진", required = true)
@RequestPart(value = "file", required = false) MultipartFile file,
@AuthenticationPrincipal AuthMember member) {
MatePostResponse response = mateService.createMatePost(request, file, member.getMemberId());
return ResponseEntity.ok(ApiResponse.success(response));
}

Expand All @@ -52,15 +54,21 @@ public ResponseEntity<ApiResponse<List<MatePostSummaryResponse>>> getMainPagePos

@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "메이트 구인글 페이징 조회", description = "메이트 구인글 페이지에서 팀/카테고리 기준으로 페이징 조회합니다.")
public ResponseEntity<ApiResponse<PageResponse<MatePostSummaryResponse>>> getMatePagePosts(
@Parameter(description = "팀 ID") @RequestParam(required = false) Long teamId,
@Parameter(description = "정렬 기준") @RequestParam(required = false) String sortType,
@Parameter(description = "연령대 카테고리") @RequestParam(required = false) String age,
@Parameter(description = "성별 카테고리") @RequestParam(required = false) String gender,
@Parameter(description = "모집인원 수") @RequestParam(required = false) Integer maxParticipants,
@Parameter(description = "이동수단 카테고리") @RequestParam(required = false) String transportType,
@Parameter(description = "페이징 정보") @ValidPageable Pageable pageable
) {
public ResponseEntity<ApiResponse<PageResponse<MatePostSummaryResponse>>> getMatePagePosts(@Parameter(description = "팀 ID")
@RequestParam(required = false) Long teamId,
@Parameter(description = "정렬 기준")
@RequestParam(required = false) String sortType,
@Parameter(description = "연령대 카테고리")
@RequestParam(required = false) String age,
@Parameter(description = "성별 카테고리")
@RequestParam(required = false) String gender,
@Parameter(description = "모집인원 수")
@RequestParam(required = false) Integer maxParticipants,
@Parameter(description = "이동수단 카테고리")
@RequestParam(required = false) String transportType,
@Parameter(description = "페이징 정보")
@ValidPageable Pageable pageable) {

MatePostSearchRequest request = MatePostSearchRequest.builder()
.teamId(teamId)
.sortType(sortType != null ? SortType.from(sortType) : null)
Expand All @@ -83,65 +91,66 @@ public ResponseEntity<ApiResponse<MatePostDetailResponse>> getMatePostDetail(@Pa
return ResponseEntity.ok(ApiResponse.success(response));
}

@PatchMapping("/{memberId}/{postId}")
@PutMapping("/{postId}")
@Operation(summary = "메이트 구인글 수정", description = "메이트 구인글 상세 페이지에서 수정합니다.")
public ResponseEntity<ApiResponse<MatePostResponse>> updateMatePost(
@Parameter(description = "작성자 ID (삭제 예정)", required = true) @PathVariable Long memberId,
@Parameter(description = "구인글 ID", required = true) @PathVariable Long postId,
@Parameter(description = "수정할 구인글 데이터", required = true) @Valid @RequestPart(value = "data") MatePostUpdateRequest request,
@Parameter(description = "수정할 대표사진 파일 ", required = true) @RequestPart(value = "file", required = false) MultipartFile file
) {
MatePostResponse response = mateService.updateMatePost(memberId, postId, request, file);
public ResponseEntity<ApiResponse<MatePostResponse>> updateMatePost( @AuthenticationPrincipal AuthMember member,
@Parameter(description = "구인글 ID", required = true)
@PathVariable Long postId,
@Parameter(description = "수정할 구인글 데이터", required = true)
@Valid @RequestPart(value = "data") MatePostUpdateRequest request,
@Parameter(description = "수정할 대표사진 파일 ", required = true)
@RequestPart(value = "file", required = false) MultipartFile file) {

MatePostResponse response = mateService.updateMatePost(member.getMemberId(), postId, request, file);
return ResponseEntity.ok(ApiResponse.success(response));
}


// TODO: @PathVariable Long memberId -> @AuthenticationPrincipal 로 변경
// 메이트 게시글 모집 상태 변경
@PatchMapping("/{memberId}/{postId}/status")
@PatchMapping("/{postId}/status")
@Operation(summary = "메이트 구인글 모집상태 변경", description = "메이트 구인글 채팅방에서 모집상태를 변경합니다.")
public ResponseEntity<ApiResponse<MatePostResponse>> updateMatePostStatus(
@Parameter(description = "작성자 ID (삭제 예정)", required = true) @PathVariable(value = "memberId") Long memberId,
@Parameter(description = "구인글 ID", required = true) @PathVariable(value = "postId") Long postId,
@Parameter(description = "변경할 모집상태와 현재 참여자 리스트 ID", required = true) @Valid @RequestBody MatePostStatusRequest request
) {
MatePostResponse response = mateService.updateMatePostStatus(memberId, postId, request);
public ResponseEntity<ApiResponse<MatePostResponse>> updateMatePostStatus( @AuthenticationPrincipal AuthMember member,
@Parameter(description = "구인글 ID", required = true)
@PathVariable(value = "postId") Long postId,
@Parameter(description = "변경할 모집상태와 현재 참여자 리스트 ID", required = true)
@Valid @RequestBody MatePostStatusRequest request) {

MatePostResponse response = mateService.updateMatePostStatus(member.getMemberId(), postId, request);
return ResponseEntity.ok(ApiResponse.success(response));
}

// TODO: @PathVariable Long memberId -> @AuthenticationPrincipal 로 변경
@DeleteMapping("/{memberId}/{postId}")
@DeleteMapping("/{postId}")
@Operation(summary = "메이트 구인글 삭제", description = "메이트 구인글 상세 페이지에서 삭제합니다.")
public ResponseEntity<Void> deleteMatePost(@Parameter(description = "작성자 ID (삭제 예정)", required = true)
@PathVariable Long memberId,
@Parameter(description = "삭제할 구인글 ID", required = true)
@PathVariable Long postId) {
public ResponseEntity<Void> deleteMatePost( @AuthenticationPrincipal AuthMember member,
@Parameter(description = "삭제할 구인글 ID", required = true)
@PathVariable Long postId) {

mateService.deleteMatePost(memberId, postId);
mateService.deleteMatePost(member.getMemberId(), postId);
return ResponseEntity.noContent().build();
}

// TODO: @PathVariable Long memberId -> @AuthenticationPrincipal 로 변경
@PatchMapping("/{memberId}/{postId}/complete")
@PatchMapping("/{postId}/complete")
@Operation(summary = "직관완료 처리", description = "메이트 구인글 채팅방에서 직관완료 처리를 진행합니다.")
public ResponseEntity<ApiResponse<MatePostCompleteResponse>> completeVisit(
@Parameter(description = "작성자 ID (삭제 예정)", required = true) @PathVariable Long memberId,
@Parameter(description = "구인글 ID", required = true) @PathVariable Long postId,
@Parameter(description = "실제 직관 참여자 리스트 ID", required = true) @Valid @RequestBody MatePostCompleteRequest request
) {
MatePostCompleteResponse response = mateService.completeVisit(memberId, postId, request);
public ResponseEntity<ApiResponse<MatePostCompleteResponse>> completeVisit( @AuthenticationPrincipal AuthMember member,
@Parameter(description = "구인글 ID", required = true)
@PathVariable Long postId,
@Parameter(description = "실제 직관 참여자 리스트 ID", required = true)
@Valid @RequestBody MatePostCompleteRequest request) {

MatePostCompleteResponse response = mateService.completeVisit(member.getMemberId(), postId, request);
return ResponseEntity.ok(ApiResponse.success(response));
}

// TODO: @PathVariable Long memberId -> @AuthenticationPrincipal 로 변경
@PostMapping("/{memberId}/{postId}/reviews")
@PostMapping("/{postId}/reviews")
@Operation(summary = "메이트 직관 후기 등록", description = "직관 타임라인 페이지에서 메이트에 대한 후기를 등록합니다.")
public ResponseEntity<ApiResponse<MateReviewCreateResponse>> createMateReview(
@Parameter(description = "작성자 ID (삭제 예정)", required = true) @PathVariable Long memberId,
@Parameter(description = "구인글 ID", required = true) @PathVariable Long postId,
@Parameter(description = "리뷰 대상자 ID와 평점 및 코멘트", required = true) @Valid @RequestBody MateReviewCreateRequest request
public ResponseEntity<ApiResponse<MateReviewCreateResponse>> createMateReview( @AuthenticationPrincipal AuthMember member,
@Parameter(description = "구인글 ID", required = true)
@PathVariable Long postId,
@Parameter(description = "리뷰 대상자 ID와 평점 및 코멘트", required = true)
@Valid @RequestBody MateReviewCreateRequest request
) {
MateReviewCreateResponse response = mateService.createReview(postId, memberId, request);

MateReviewCreateResponse response = mateService.createReview(postId, member.getMemberId(), request);
return ResponseEntity.ok(ApiResponse.success(response));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
@NoArgsConstructor
@AllArgsConstructor
public class MatePostCreateRequest {
private Long memberId;

@NotNull(message = "팀 ID는 필수 입력 값입니다.")
@Min(value = 0, message = "팀 ID는 0 이상이어야 합니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public class MateService {
private final MateReviewRepository mateReviewRepository;
private final FileService fileService;

public MatePostResponse createMatePost(MatePostCreateRequest request, MultipartFile file) {
Member author = findMemberById(request.getMemberId());
public MatePostResponse createMatePost(MatePostCreateRequest request, MultipartFile file, Long memberId) {
Member author = findMemberById(memberId);

Match match = findMatchById(request.getMatchId());

Expand Down
Loading

0 comments on commit 707770a

Please sign in to comment.