-
Notifications
You must be signed in to change notification settings - Fork 0
차단·신고 API와 미디어 정리 스케줄러 추가 및 Swagger 전체 문서화 #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cfcromn
merged 6 commits into
develop
from
feature/30-block-report-api-and-media-cleanup
Aug 30, 2026
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
34ad95a
feat: #30 :: add block and report apis
cfcromn 0b97393
feat: #30 :: reclaim unattached media with a scheduled cleanup
cfcromn 0211dd7
docs: #30 :: document every endpoint and dto in swagger
cfcromn bbacbf0
test: #30 :: cover block, report, media cleanup, and the openapi docu…
cfcromn 1bd0daf
test: #30 :: hide the security test controller from the openapi document
cfcromn 09934db
fix: #30 :: close concurrency races in block, report, and media cleanup
cfcromn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/main/kotlin/team/cklob/mudda/domain/auth/presentation/request/LoginAuthRequest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,15 @@ | ||
| package team.cklob.mudda.domain.auth.presentation.request | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema | ||
| import jakarta.validation.constraints.NotBlank | ||
|
|
||
| @Schema(description = "OAuth 로그인 요청") | ||
| data class LoginAuthRequest( | ||
| @field:NotBlank | ||
| @Schema(description = "OAuth 제공자로부터 받은 인가 코드", example = "abc123") | ||
| val code: String, | ||
|
|
||
| @field:NotBlank | ||
| @Schema(description = "인가 코드를 발급받을 때 사용한 리다이렉트 URI", example = "https://mudda.app/oauth/callback") | ||
| val redirectUri: String, | ||
| ) |
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/team/cklob/mudda/domain/auth/presentation/request/SignupAuthRequest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,29 @@ | ||
| package team.cklob.mudda.domain.auth.presentation.request | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema | ||
| import jakarta.validation.constraints.Max | ||
| import jakarta.validation.constraints.Min | ||
| import jakarta.validation.constraints.NotBlank | ||
| import jakarta.validation.constraints.Size | ||
| import team.cklob.mudda.domain.member.domain.type.Gender | ||
|
|
||
| @Schema(description = "회원가입 요청") | ||
| data class SignupAuthRequest( | ||
| @field:NotBlank | ||
| @field:Size(max = 30) | ||
| @Schema(description = "실명", example = "박하민") | ||
| val name: String, | ||
|
|
||
| @field:NotBlank | ||
| @field:Size(max = 30) | ||
| @Schema(description = "닉네임. 전체에서 유일해야 합니다.", example = "hamin") | ||
| val nickname: String, | ||
|
|
||
| @Schema(description = "성별", example = "MALE") | ||
| val gender: Gender, | ||
|
|
||
| @field:Min(1900) | ||
| @field:Max(2100) | ||
| @Schema(description = "출생 연도", example = "2008") | ||
| val birthYear: Int, | ||
| ) |
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/team/cklob/mudda/domain/auth/presentation/response/LoginAuthResponse.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,12 @@ | ||
| package team.cklob.mudda.domain.auth.presentation.response | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema | ||
| @Schema(description = "OAuth 로그인 응답") | ||
| data class LoginAuthResponse( | ||
| @Schema(description = "액세스 토큰", example = "ey...") | ||
| val accessToken: String, | ||
| @Schema(description = "리프레시 토큰", example = "ey...") | ||
| val refreshToken: String, | ||
| @Schema(description = "true면 아직 회원가입이 완료되지 않은 상태이므로 이어서 /api/v1/auth/signup 을 호출해야 합니다.", example = "true") | ||
| val isNewMember: Boolean, | ||
| ) |
4 changes: 4 additions & 0 deletions
4
src/main/kotlin/team/cklob/mudda/domain/auth/presentation/response/ReissueAuthResponse.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,10 @@ | ||
| package team.cklob.mudda.domain.auth.presentation.response | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema | ||
| @Schema(description = "토큰 재발급 응답") | ||
| data class ReissueAuthResponse( | ||
| @Schema(description = "새 액세스 토큰", example = "ey...") | ||
| val accessToken: String, | ||
| @Schema(description = "새 리프레시 토큰", example = "ey...") | ||
| val refreshToken: String, | ||
| ) |
67 changes: 67 additions & 0 deletions
67
src/main/kotlin/team/cklob/mudda/domain/block/application/impl/BlockServices.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package team.cklob.mudda.domain.block.application.impl | ||
|
|
||
| import org.springframework.data.domain.Pageable | ||
| import org.springframework.stereotype.Service | ||
| import org.springframework.transaction.annotation.Transactional | ||
| import team.cklob.mudda.domain.block.domain.entity.Block | ||
| import team.cklob.mudda.domain.block.domain.repository.BlockRepository | ||
| import team.cklob.mudda.domain.block.presentation.request.CreateBlockRequest | ||
| import team.cklob.mudda.domain.block.presentation.response.BlockResponse | ||
| import team.cklob.mudda.domain.block.presentation.response.CreateBlockResponse | ||
| import team.cklob.mudda.domain.friend.presentation.response.FriendPageResponse | ||
| import team.cklob.mudda.domain.member.domain.repository.MemberRepository | ||
| import team.cklob.mudda.global.exception.BusinessException | ||
| import team.cklob.mudda.global.exception.ErrorCode | ||
|
|
||
| // Blocking is purely additive: it writes one tbl_block row and nothing else. Every read path already | ||
| // excludes blocked members in SQL (friend list, friend requests, member search, capsule access), so there | ||
| // is no friendship or pending-request cascade to keep in sync -- and unblocking restores the prior state | ||
| // for free. | ||
| @Service | ||
| class CreateBlockService( | ||
| private val blockRepository: BlockRepository, | ||
| private val memberRepository: MemberRepository, | ||
| ) { | ||
| @Transactional | ||
| fun execute(memberId: Long, request: CreateBlockRequest): CreateBlockResponse { | ||
| val targetId = requireNotNull(request.memberId) | ||
| if (targetId == memberId) throw BusinessException(ErrorCode.CANNOT_BLOCK_SELF) | ||
|
|
||
| val target = memberRepository.findById(targetId).orElseThrow { BusinessException(ErrorCode.MEMBER_NOT_FOUND) } | ||
| if (target.withdrawnAt != null) throw BusinessException(ErrorCode.MEMBER_NOT_FOUND) | ||
|
|
||
| // Blocking twice is the same end state as blocking once, so the existing row is returned rather | ||
| // than raising a conflict the client would have to special-case. | ||
| val existing = blockRepository.findByBlockerIdAndBlockedId(memberId, targetId).orElse(null) | ||
| if (existing != null) { | ||
| return CreateBlockResponse(requireNotNull(existing.id), targetId, existing.createdAt) | ||
| } | ||
|
|
||
| val blocker = memberRepository.findById(memberId).orElseThrow { BusinessException(ErrorCode.MEMBER_NOT_FOUND) } | ||
| val saved = blockRepository.save(Block(blocker = blocker, blocked = target)) | ||
| return CreateBlockResponse(requireNotNull(saved.id), targetId, saved.createdAt) | ||
| } | ||
| } | ||
|
|
||
| @Service | ||
| class DeleteBlockService( | ||
| private val blockRepository: BlockRepository, | ||
| ) { | ||
| @Transactional | ||
| fun execute(memberId: Long, targetMemberId: Long) { | ||
| val block = blockRepository.findByBlockerIdAndBlockedId(memberId, targetMemberId) | ||
| .orElseThrow { BusinessException(ErrorCode.BLOCK_NOT_FOUND) } | ||
| blockRepository.delete(block) | ||
| } | ||
| } | ||
|
|
||
| @Service | ||
| class GetBlockListService( | ||
| private val blockRepository: BlockRepository, | ||
| ) { | ||
| @Transactional(readOnly = true) | ||
| fun execute(memberId: Long, pageable: Pageable): FriendPageResponse<BlockResponse> { | ||
| val page = blockRepository.findByBlockerIdOrderByCreatedAtDesc(memberId, pageable) | ||
| return FriendPageResponse.of(page, page.content.map(BlockResponse::from)) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/main/kotlin/team/cklob/mudda/domain/block/presentation/controller/BlockController.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| package team.cklob.mudda.domain.block.presentation.controller | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation | ||
| import io.swagger.v3.oas.annotations.Parameter | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse as SwaggerApiResponse | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponses as SwaggerApiResponses | ||
| import io.swagger.v3.oas.annotations.security.SecurityRequirement | ||
| import io.swagger.v3.oas.annotations.tags.Tag | ||
| import jakarta.validation.Valid | ||
| import org.springframework.data.domain.Pageable | ||
| import org.springframework.data.web.PageableDefault | ||
| import org.springframework.http.HttpStatus | ||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.web.bind.annotation.DeleteMapping | ||
| import org.springframework.web.bind.annotation.GetMapping | ||
| import org.springframework.web.bind.annotation.PathVariable | ||
| 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.ResponseStatus | ||
| import org.springframework.web.bind.annotation.RestController | ||
| import team.cklob.mudda.domain.block.application.impl.CreateBlockService | ||
| import team.cklob.mudda.domain.block.application.impl.DeleteBlockService | ||
| import team.cklob.mudda.domain.block.application.impl.GetBlockListService | ||
| import team.cklob.mudda.domain.block.presentation.request.CreateBlockRequest | ||
| import team.cklob.mudda.domain.block.presentation.response.BlockResponse | ||
| import team.cklob.mudda.domain.block.presentation.response.CreateBlockResponse | ||
| import team.cklob.mudda.domain.friend.presentation.response.FriendPageResponse | ||
| import team.cklob.mudda.global.response.ApiResponse | ||
| import team.cklob.mudda.global.security.LoginUser | ||
|
|
||
| @Tag(name = "Block", description = "회원 차단 API") | ||
| @SecurityRequirement(name = "bearerAuth") | ||
| @RestController | ||
| @RequestMapping("/api/v1/blocks") | ||
| class BlockController( | ||
| private val createBlockService: CreateBlockService, | ||
| private val deleteBlockService: DeleteBlockService, | ||
| private val getBlockListService: GetBlockListService, | ||
| ) { | ||
| @Operation( | ||
| summary = "회원 차단", | ||
| description = "대상 회원을 차단합니다. 차단 후에는 친구 목록·친구 요청·사용자 검색·캡슐 접근에서 서로가 보이지 않습니다. " + | ||
| "친구 관계나 대기 중인 요청을 삭제하지는 않으므로, 차단을 해제하면 이전 상태가 그대로 복원됩니다.", | ||
| ) | ||
| @SwaggerApiResponses( | ||
| SwaggerApiResponse(responseCode = "201", description = "차단 성공. 이미 차단한 회원이면 기존 차단 정보를 그대로 반환합니다."), | ||
| SwaggerApiResponse(responseCode = "400", description = "자기 자신을 차단(CANNOT_BLOCK_SELF)"), | ||
| SwaggerApiResponse(responseCode = "404", description = "대상 회원 없음(MEMBER_NOT_FOUND)"), | ||
| ) | ||
| @PostMapping | ||
| @ResponseStatus(HttpStatus.CREATED) | ||
| fun createBlock( | ||
| @LoginUser memberId: Long, | ||
| @Valid @RequestBody request: CreateBlockRequest, | ||
| ): ApiResponse<CreateBlockResponse> = ApiResponse.success(createBlockService.execute(memberId, request)) | ||
|
|
||
| @Operation(summary = "차단 목록 조회", description = "로그인 사용자가 차단한 회원 목록을 최근 차단순으로 조회합니다.") | ||
| @GetMapping | ||
| fun getBlocks( | ||
| @LoginUser memberId: Long, | ||
| @PageableDefault(size = 20) pageable: Pageable, | ||
| ): ResponseEntity<ApiResponse<FriendPageResponse<BlockResponse>>> = | ||
| ResponseEntity.ok(ApiResponse.success(getBlockListService.execute(memberId, pageable))) | ||
|
|
||
| @Operation(summary = "차단 해제", description = "차단을 해제합니다. 차단 이전의 친구 관계와 대기 중인 요청이 다시 보이게 됩니다.") | ||
| @SwaggerApiResponses( | ||
| SwaggerApiResponse(responseCode = "204", description = "해제 성공"), | ||
| SwaggerApiResponse(responseCode = "404", description = "차단 기록 없음(BLOCK_NOT_FOUND)"), | ||
| ) | ||
| @DeleteMapping("/{memberId}") | ||
| @ResponseStatus(HttpStatus.NO_CONTENT) | ||
| fun deleteBlock( | ||
| @LoginUser loginMemberId: Long, | ||
| @Parameter(description = "차단을 해제할 회원 ID") @PathVariable("memberId") targetMemberId: Long, | ||
| ) { | ||
| deleteBlockService.execute(loginMemberId, targetMemberId) | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/team/cklob/mudda/domain/block/presentation/request/BlockRequests.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package team.cklob.mudda.domain.block.presentation.request | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema | ||
| import jakarta.validation.constraints.NotNull | ||
|
|
||
| @Schema(description = "회원 차단 요청") | ||
| data class CreateBlockRequest( | ||
| @field:NotNull | ||
| @Schema(description = "차단할 회원 ID", example = "2") | ||
| val memberId: Long?, | ||
| ) |
45 changes: 45 additions & 0 deletions
45
src/main/kotlin/team/cklob/mudda/domain/block/presentation/response/BlockResponses.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package team.cklob.mudda.domain.block.presentation.response | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema | ||
| import team.cklob.mudda.domain.block.domain.entity.Block | ||
| import java.time.LocalDateTime | ||
|
|
||
| @Schema(description = "차단한 회원") | ||
| data class BlockResponse( | ||
| @Schema(description = "차단 ID", example = "1") | ||
| val blockId: Long, | ||
|
|
||
| @Schema(description = "차단된 회원 ID", example = "2") | ||
| val memberId: Long, | ||
|
|
||
| @Schema(description = "차단된 회원 닉네임", example = "nick", nullable = true) | ||
| val nickname: String?, | ||
|
|
||
| @Schema(description = "프로필 이미지 URL", nullable = true) | ||
| val profileImageUrl: String?, | ||
|
|
||
| @Schema(description = "차단 시각") | ||
| val createdAt: LocalDateTime, | ||
| ) { | ||
| companion object { | ||
| fun from(block: Block) = BlockResponse( | ||
| blockId = requireNotNull(block.id), | ||
| memberId = requireNotNull(block.blocked.id), | ||
| nickname = block.blocked.nickname, | ||
| profileImageUrl = block.blocked.profileImageUrl, | ||
| createdAt = block.createdAt, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Schema(description = "회원 차단 응답") | ||
| data class CreateBlockResponse( | ||
| @Schema(description = "차단 ID", example = "1") | ||
| val blockId: Long, | ||
|
|
||
| @Schema(description = "차단된 회원 ID", example = "2") | ||
| val memberId: Long, | ||
|
|
||
| @Schema(description = "차단 시각") | ||
| val createdAt: LocalDateTime, | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.