Skip to content

Commit

Permalink
MATE-115 : [FEAT] 굿즈거래 채팅 도메인 Swagger 문서 작성 (#104)
Browse files Browse the repository at this point in the history
* MATE-115 : [FEAT] GoodsChatRoomController 클래스 Swagger 문서 작성

* MATE-115 : [REFACTOR] Jwt 필터에 Swagger 경로 인증 제외
  • Loading branch information
hongjeZZ authored Dec 7, 2024
1 parent ba2fdcb commit 53af026
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.example.mate.common.config;

//import com.example.mate.common.security.filter.JwtCheckFilter;

import com.example.mate.common.security.filter.JwtCheckFilter;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Configuration
public class SwaggerConfig {
@Bean
Expand All @@ -22,7 +19,6 @@ public OpenAPI openAPI() {

return new OpenAPI()
.info(info)
.servers(List.of(new Server().url("http://localhost:8080")))
.addSecurityItem(new SecurityRequirement().addList("Bearer Authentication"))
.components(new Components().addSecuritySchemes("Bearer Authentication", createAPIKeyScheme()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private boolean isExcludedPath(String requestURI) {
requestURI.startsWith("/api/auth") ||
requestURI.startsWith("/api/members/join") ||
requestURI.startsWith("/swagger-ui") ||
requestURI.startsWith("/v3/api-docs") ||
requestURI.startsWith("/api/members/login");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import com.example.mate.domain.goodsChat.dto.response.GoodsChatRoomSummaryResponse;
import com.example.mate.domain.goodsChat.service.GoodsChatService;
import com.example.mate.domain.member.dto.response.MemberSummaryResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
Expand All @@ -25,51 +28,68 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/goods/chat")
@Tag(name = "GoodsChatRoomController", description = "굿즈거래 채팅방 관련 API")
public class GoodsChatRoomController {

private final GoodsChatService goodsChatService;

@PostMapping
public ResponseEntity<ApiResponse<GoodsChatRoomResponse>> createGoodsChatRoom(@AuthenticationPrincipal AuthMember member,
@RequestParam Long goodsPostId) {
@Operation(summary = "굿즈거래 채팅방 입장 및 생성", description = "굿즈 거래 게시글에 대한 채팅방을 생성하거나 기존 채팅방 정보를 조회합니다.")
public ResponseEntity<ApiResponse<GoodsChatRoomResponse>> createGoodsChatRoom(
@AuthenticationPrincipal AuthMember member,
@Parameter(description = "판매글 ID", required = true) @RequestParam Long goodsPostId
) {
GoodsChatRoomResponse response = goodsChatService.getOrCreateGoodsChatRoom(member.getMemberId(), goodsPostId);
return ResponseEntity.ok(ApiResponse.success(response));
}

@GetMapping("/{chatRoomId}/message")
@Operation(summary = "굿즈거래 채팅방 메시지 조회", description = "지정된 채팅방의 메시지를 페이징 처리하여 조회합니다.")
public ResponseEntity<ApiResponse<PageResponse<GoodsChatMessageResponse>>> getGoodsChatRoomMessages(
@AuthenticationPrincipal AuthMember member,
@PathVariable Long chatRoomId,
@ValidPageable Pageable pageable
@Parameter(description = "채팅방 ID", required = true) @PathVariable Long chatRoomId,
@Parameter(description = "페이징 정보") @ValidPageable Pageable pageable
) {
PageResponse<GoodsChatMessageResponse> response = goodsChatService.getMessagesForChatRoom(chatRoomId, member.getMemberId(), pageable);
return ResponseEntity.ok(ApiResponse.success(response));
}

@GetMapping
public ResponseEntity<ApiResponse<PageResponse<GoodsChatRoomSummaryResponse>>> getGoodsChatRooms(@AuthenticationPrincipal AuthMember member,
@ValidPageable Pageable pageable) {
@Operation(summary = "사용자의 굿즈거래 채팅방 목록 조회", description = "사용자가 참여 중인 굿즈거래 채팅방 목록을 조회합니다.")
public ResponseEntity<ApiResponse<PageResponse<GoodsChatRoomSummaryResponse>>> getGoodsChatRooms(
@AuthenticationPrincipal AuthMember member,
@Parameter(description = "페이징 정보") @ValidPageable Pageable pageable
) {
PageResponse<GoodsChatRoomSummaryResponse> response = goodsChatService.getGoodsChatRooms(member.getMemberId(), pageable);
return ResponseEntity.ok(ApiResponse.success(response));
}

@DeleteMapping("/{chatRoomId}")
public ResponseEntity<Void> leaveGoodsChatRoom(@AuthenticationPrincipal AuthMember member, @PathVariable Long chatRoomId) {
@Operation(summary = "굿즈거래 채팅방 나가기", description = "사용자가 지정된 굿즈거래 채팅방을 나갑니다. 만약 모든 사용자가 나가면 채팅방이 삭제됩니다.")
public ResponseEntity<Void> leaveGoodsChatRoom(
@AuthenticationPrincipal AuthMember member,
@Parameter(description = "채팅방 ID", required = true) @PathVariable Long chatRoomId
) {
goodsChatService.deactivateGoodsChatPart(member.getMemberId(), chatRoomId);

return ResponseEntity.noContent().build();
}

@GetMapping("/{chatRoomId}")
public ResponseEntity<ApiResponse<GoodsChatRoomResponse>> getGoodsChatRoomInfo(@AuthenticationPrincipal AuthMember member,
@PathVariable Long chatRoomId) {
@Operation(summary = "굿즈거래 채팅방 입장", description = "굿즈 거래 채팅방의 정보를 조회합니다.")
public ResponseEntity<ApiResponse<GoodsChatRoomResponse>> getGoodsChatRoomInfo(
@AuthenticationPrincipal AuthMember member,
@Parameter(description = "채팅방 ID", required = true) @PathVariable Long chatRoomId
) {
GoodsChatRoomResponse response = goodsChatService.getGoodsChatRoomInfo(member.getMemberId(), chatRoomId);
return ResponseEntity.ok(ApiResponse.success(response));
}

@GetMapping("/{chatRoomId}/members")
public ResponseEntity<ApiResponse<List<MemberSummaryResponse>>> getGoodsChatRoomMembers(@AuthenticationPrincipal AuthMember member,
@PathVariable Long chatRoomId) {
@Operation(summary = "굿즈거래 채팅방 인원 조회", description = "지정된 채팅방에 참여 중인 사용자 목록을 조회합니다.")
public ResponseEntity<ApiResponse<List<MemberSummaryResponse>>> getGoodsChatRoomMembers(
@AuthenticationPrincipal AuthMember member,
@Parameter(description = "채팅방 ID", required = true) @PathVariable Long chatRoomId
) {
List<MemberSummaryResponse> responses = goodsChatService.getChatRoomMembers(member.getMemberId(), chatRoomId);
return ResponseEntity.ok(ApiResponse.success(responses));
}
Expand Down

0 comments on commit 53af026

Please sign in to comment.