-
Notifications
You must be signed in to change notification settings - Fork 2
feat: 콜벤 기능 구현 #2151
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
Merged
feat: 콜벤 기능 구현 #2151
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
60bd4cf
feat: 콜벤 등록 POST API
DHkimgit 532326c
feat: 콜벤 등록 POST API 커스텀 장소 검증 로직 추가
DHkimgit e288039
feat: 콜벤 게시글 조회 GET API
DHkimgit 9586a0b
feat: 콜벤 참여 POST API
DHkimgit 7fc572c
feat: 콜벤 게시글 조회 API is_author, is_joined 필드 추가
DHkimgit dd808ce
feat: 콜벤 게시글 상태 변경 PUT API 3개
DHkimgit 8cbba16
feat: 콜벤 게시글 상태 변경 PUT API 3개
DHkimgit c2907f8
feat: 콜벤 게시글 상세 정보 조회 GET API
DHkimgit 01f5e4e
feat: 콜벤 채팅 전송 및 조회 API
DHkimgit a01d3ef
feat: 콜벤 알림 API
DHkimgit 4239b61
fix: 리뷰 반영
DHkimgit bb16afa
feat: 콜벤 게시글 조회 GET API 정렬 필터 추가
DHkimgit 6f01f6c
feat: 콜벤 게시글 조회 GET API 상태 필터 List 기반으로 변경
DHkimgit 1c817d7
fix: 닉네임 로직 리뷰 반영
DHkimgit b9ce83f
fix: 문서 수정
DHkimgit f238778
fix: CI 실패 문제 대응 (testcontainers 버전 수정)
DHkimgit b1bacfc
feat: 콜벤 사용자 신고 POST API
DHkimgit 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
397 changes: 397 additions & 0 deletions
397
src/main/java/in/koreatech/koin/domain/callvan/controller/CallvanApi.java
Large diffs are not rendered by default.
Oops, something went wrong.
183 changes: 183 additions & 0 deletions
183
src/main/java/in/koreatech/koin/domain/callvan/controller/CallvanController.java
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,183 @@ | ||
| package in.koreatech.koin.domain.callvan.controller; | ||
|
|
||
| import static in.koreatech.koin.domain.user.model.UserType.STUDENT; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| 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 in.koreatech.koin.domain.callvan.dto.CallvanPostCreateRequest; | ||
| import in.koreatech.koin.domain.callvan.dto.CallvanPostCreateResponse; | ||
| import in.koreatech.koin.domain.callvan.dto.CallvanPostDetailResponse; | ||
| import in.koreatech.koin.domain.callvan.dto.CallvanPostSearchResponse; | ||
| import in.koreatech.koin.domain.callvan.dto.CallvanUserReportCreateRequest; | ||
| import in.koreatech.koin.domain.callvan.model.enums.CallvanLocation; | ||
| import in.koreatech.koin.domain.callvan.model.filter.CallvanAuthorFilter; | ||
| import in.koreatech.koin.domain.callvan.model.filter.CallvanPostSortCriteria; | ||
| import in.koreatech.koin.domain.callvan.model.filter.CallvanPostStatusFilter; | ||
| import in.koreatech.koin.domain.callvan.service.CallvanPostQueryService; | ||
| import in.koreatech.koin.domain.callvan.service.CallvanPostCreateService; | ||
| import in.koreatech.koin.domain.callvan.service.CallvanPostJoinService; | ||
| import in.koreatech.koin.domain.callvan.service.CallvanPostStatusService; | ||
| import in.koreatech.koin.domain.callvan.service.CallvanChatService; | ||
| import in.koreatech.koin.domain.callvan.service.CallvanNotificationService; | ||
| import in.koreatech.koin.domain.callvan.service.CallvanUserReportService; | ||
| import in.koreatech.koin.domain.callvan.dto.CallvanChatMessageRequest; | ||
| import in.koreatech.koin.domain.callvan.dto.CallvanNotificationResponse; | ||
| import in.koreatech.koin.domain.callvan.dto.CallvanChatMessageResponse; | ||
| import in.koreatech.koin.global.auth.Auth; | ||
| import in.koreatech.koin.global.auth.UserId; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PutMapping; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/callvan") | ||
| @RequiredArgsConstructor | ||
| public class CallvanController implements CallvanApi { | ||
|
|
||
| private final CallvanPostCreateService callvanPostCreateService; | ||
| private final CallvanPostQueryService callvanPostQueryService; | ||
| private final CallvanPostJoinService callvanPostJoinService; | ||
| private final CallvanPostStatusService callvanPostStatusService; | ||
| private final CallvanChatService callvanChatService; | ||
| private final CallvanNotificationService callvanNotificationService; | ||
| private final CallvanUserReportService callvanUserReportService; | ||
|
|
||
| @PostMapping | ||
| public ResponseEntity<CallvanPostCreateResponse> createCallvanPost( | ||
| @RequestBody CallvanPostCreateRequest request, | ||
| Integer userId | ||
| ) { | ||
| CallvanPostCreateResponse response = callvanPostCreateService.createCallvanPost(request, userId); | ||
| return ResponseEntity.status(HttpStatus.CREATED).body(response); | ||
| } | ||
|
|
||
| @GetMapping | ||
| public ResponseEntity<CallvanPostSearchResponse> getCallvanPosts( | ||
| CallvanAuthorFilter author, | ||
| List<CallvanLocation> departures, | ||
| String departureKeyword, | ||
| List<CallvanLocation> arrivals, | ||
| String arrivalKeyword, | ||
| List<CallvanPostStatusFilter> statuses, | ||
| String title, | ||
| CallvanPostSortCriteria sort, | ||
| Integer page, | ||
| Integer limit, | ||
| @UserId Integer userId | ||
| ) { | ||
| CallvanPostSearchResponse response = callvanPostQueryService.getCallvanPosts( | ||
| author, departures, departureKeyword, arrivals, arrivalKeyword, statuses, title, sort, page, limit, | ||
| userId); | ||
| return ResponseEntity.ok().body(response); | ||
| } | ||
|
|
||
| @GetMapping("/posts/{postId}") | ||
| public ResponseEntity<CallvanPostDetailResponse> getCallvanPostDetail( | ||
| @PathVariable Integer postId, | ||
| @UserId Integer userId | ||
| ) { | ||
| CallvanPostDetailResponse response = callvanPostQueryService.getCallvanPostDetail(postId, userId); | ||
| return ResponseEntity.ok(response); | ||
| } | ||
|
|
||
| @PostMapping("/posts/{postId}/participants") | ||
| public ResponseEntity<Void> joinCallvanPost( | ||
| @PathVariable Integer postId, | ||
| @UserId Integer userId | ||
| ) { | ||
| callvanPostJoinService.join(postId, userId); | ||
| return ResponseEntity.status(HttpStatus.CREATED).build(); | ||
| } | ||
|
|
||
| @DeleteMapping("/posts/{postId}/participants") | ||
| public ResponseEntity<Void> leaveCallvanPost( | ||
| @PathVariable Integer postId, | ||
| @UserId Integer userId | ||
| ) { | ||
| callvanPostJoinService.leave(postId, userId); | ||
| return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); | ||
| } | ||
|
|
||
| @PostMapping("/posts/{postId}/reports") | ||
| public ResponseEntity<Void> reportCallvanUser( | ||
| @PathVariable Integer postId, | ||
| @RequestBody @Valid CallvanUserReportCreateRequest request, | ||
| @Auth(permit = {STUDENT}) Integer userId | ||
| ) { | ||
| callvanUserReportService.reportUser(postId, userId, request); | ||
| return ResponseEntity.status(HttpStatus.CREATED).build(); | ||
| } | ||
|
|
||
| @GetMapping("/posts/{postId}/chat") | ||
| public ResponseEntity<CallvanChatMessageResponse> getCallvanChatMessages( | ||
| @PathVariable Integer postId, | ||
| @UserId Integer userId | ||
| ) { | ||
| CallvanChatMessageResponse response = callvanChatService.getMessages(postId, userId); | ||
| return ResponseEntity.ok(response); | ||
| } | ||
|
|
||
| @PostMapping("/posts/{postId}/chat") | ||
| public ResponseEntity<Void> sendMessage( | ||
| @PathVariable Integer postId, | ||
| @RequestBody CallvanChatMessageRequest request, | ||
| @UserId Integer userId | ||
| ) { | ||
| callvanChatService.sendMessage(postId, userId, request); | ||
| return ResponseEntity.status(HttpStatus.CREATED).build(); | ||
| } | ||
|
|
||
| @PutMapping("/posts/{postId}/close") | ||
| public ResponseEntity<Void> closeCallvanPost( | ||
| @PathVariable Integer postId, | ||
| @UserId Integer userId | ||
| ) { | ||
| callvanPostStatusService.close(postId, userId); | ||
| return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); | ||
| } | ||
|
|
||
| @PutMapping("/posts/{postId}/reopen") | ||
| public ResponseEntity<Void> reopenCallvanPost( | ||
| @PathVariable Integer postId, | ||
| @UserId Integer userId | ||
| ) { | ||
| callvanPostStatusService.reopen(postId, userId); | ||
| return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); | ||
| } | ||
|
|
||
| @PutMapping("/posts/{postId}/complete") | ||
| public ResponseEntity<Void> completeCallvanPost( | ||
| @PathVariable Integer postId, | ||
| @UserId Integer userId | ||
| ) { | ||
| callvanPostStatusService.complete(postId, userId); | ||
| return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); | ||
| } | ||
|
|
||
| @GetMapping("/notifications") | ||
| public ResponseEntity<List<CallvanNotificationResponse>> getNotifications( | ||
| @Auth(permit = {STUDENT}) Integer userId | ||
| ) { | ||
| List<CallvanNotificationResponse> responses = callvanNotificationService.getNotifications(userId); | ||
| return ResponseEntity.ok(responses); | ||
| } | ||
|
|
||
| @PostMapping("/notifications/mark-all-read") | ||
| public ResponseEntity<Void> markAllNotificationsAsRead( | ||
| @Auth(permit = {STUDENT}) Integer userId | ||
| ) { | ||
| callvanNotificationService.markAllRead(userId); | ||
| return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
src/main/java/in/koreatech/koin/domain/callvan/dto/CallvanChatMessageRequest.java
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,23 @@ | ||
| package in.koreatech.koin.domain.callvan.dto; | ||
|
|
||
| import static com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| @JsonNaming(SnakeCaseStrategy.class) | ||
| public record CallvanChatMessageRequest( | ||
| @Schema(description = "메시지 내용 (텍스트 또는 이미지 URL)", example = "안녕하세요!") | ||
| @NotNull(message = "메시지 내용은 필수입니다.") | ||
| String content, | ||
|
|
||
| @Schema(description = "이미지 여부", example = "false") | ||
| @JsonProperty("is_image") | ||
| @NotNull(message = "이미지 여부는 필수입니다.") | ||
| Boolean isImage | ||
| ) { | ||
|
|
||
| } |
88 changes: 88 additions & 0 deletions
88
src/main/java/in/koreatech/koin/domain/callvan/dto/CallvanChatMessageResponse.java
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,88 @@ | ||
| package in.koreatech.koin.domain.callvan.dto; | ||
|
|
||
| import static com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
|
|
||
| import java.time.format.DateTimeFormatter; | ||
| import java.util.List; | ||
| import java.util.Locale; | ||
|
|
||
| import org.springframework.util.StringUtils; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
|
||
| import in.koreatech.koin.domain.callvan.model.CallvanChatMessage; | ||
| import in.koreatech.koin.domain.callvan.model.CallvanPost; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| @JsonNaming(SnakeCaseStrategy.class) | ||
| public record CallvanChatMessageResponse( | ||
| @Schema(description = "채팅방 이름", example = "별관동 -> 천안역 (14:00) (4명)") | ||
| String roomName, | ||
|
|
||
| @Schema(description = "메시지 목록") | ||
| List<CallvanMessageDto> messages | ||
| ) { | ||
|
|
||
| public static CallvanChatMessageResponse of(CallvanPost post, List<CallvanChatMessage> messages, Integer userId) { | ||
| String departure = post.getDepartureType().getName(); | ||
| if (StringUtils.hasText(post.getDepartureCustomName())) { | ||
| departure = post.getDepartureCustomName(); | ||
| } | ||
|
|
||
| String arrival = post.getArrivalType().getName(); | ||
| if (StringUtils.hasText(post.getArrivalCustomName())) { | ||
| arrival = post.getArrivalCustomName(); | ||
| } | ||
|
|
||
| String time = post.getDepartureTime().format(DateTimeFormatter.ofPattern("HH:mm")); | ||
| String roomName = String.format("%s -> %s (%s) (%d명)", | ||
| departure, arrival, time, post.getMaxParticipants()); | ||
|
|
||
| List<CallvanMessageDto> messageDtos = messages.stream() | ||
| .map(msg -> CallvanMessageDto.from(msg, userId)) | ||
| .toList(); | ||
|
|
||
| return new CallvanChatMessageResponse(roomName, messageDtos); | ||
| } | ||
|
|
||
| @JsonNaming(SnakeCaseStrategy.class) | ||
| public record CallvanMessageDto( | ||
| @Schema(description = "작성자 ID", example = "1") | ||
| Integer userId, | ||
|
|
||
| @Schema(description = "작성자 닉네임", example = "익명_12345") | ||
| String senderNickname, | ||
|
|
||
| @Schema(description = "메시지 내용", example = "안녕하세요!") | ||
| String content, | ||
|
|
||
| @Schema(description = "작성 날짜", example = "2024. 03. 24") | ||
| String date, | ||
|
|
||
| @Schema(description = "작성 시간", example = "오후 2:00") | ||
| String time, | ||
|
|
||
| @Schema(description = "이미지 여부", example = "false") | ||
| Boolean isImage, | ||
|
|
||
| @Schema(description = "퇴장 유저 여부", example = "false") | ||
| Boolean isLeftUser, | ||
|
|
||
| @Schema(description = "내 메시지 여부", example = "true") | ||
| Boolean isMine | ||
| ) { | ||
|
|
||
| public static CallvanMessageDto from(CallvanChatMessage message, Integer currentUserId) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 줄넘김 이슈 |
||
| return new CallvanMessageDto( | ||
| message.getSender().getId(), | ||
| message.getSenderNickname(), | ||
| message.getContent(), | ||
| message.getCreatedAt().format(DateTimeFormatter.ofPattern("yyyy. MM. dd")), | ||
| message.getCreatedAt().format(DateTimeFormatter.ofPattern("a h:mm").withLocale(Locale.KOREAN)), | ||
| message.getIsImage(), | ||
| message.getIsLeftUser(), | ||
| message.getSender().getId().equals(currentUserId)); | ||
| } | ||
| } | ||
| } | ||
90 changes: 90 additions & 0 deletions
90
src/main/java/in/koreatech/koin/domain/callvan/dto/CallvanNotificationResponse.java
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,90 @@ | ||
| package in.koreatech.koin.domain.callvan.dto; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import java.time.LocalTime; | ||
|
|
||
| import org.springframework.util.StringUtils; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonFormat; | ||
| import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
|
||
| import in.koreatech.koin.domain.callvan.model.CallvanNotification; | ||
| import in.koreatech.koin.domain.callvan.model.enums.CallvanNotificationType; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| @JsonNaming(SnakeCaseStrategy.class) | ||
| public record CallvanNotificationResponse( | ||
| @Schema(description = "알림 ID", example = "1") | ||
| Integer id, | ||
|
|
||
| @Schema(description = "알림 타입", example = "RECRUITMENT_COMPLETE") | ||
| CallvanNotificationType type, | ||
|
|
||
| @Schema(description = "메시지 미리보기", example = "해당 콜벤팟 인원이 모두 모집되었습니다.") | ||
| String messagePreview, | ||
|
|
||
| @Schema(description = "읽음 여부", example = "false") | ||
| Boolean isRead, | ||
|
|
||
| @Schema(description = "생성 일시", example = "2024-03-24 14:00:00") | ||
| LocalDateTime createdAt, | ||
|
|
||
| @Schema(description = "콜벤 게시글 ID", example = "1") | ||
| Integer postId, | ||
|
|
||
| @Schema(description = "출발지", example = "복지관") | ||
| String departure, | ||
|
|
||
| @Schema(description = "도착지", example = "천안역") | ||
| String arrival, | ||
|
|
||
| @Schema(description = "출발 날짜", example = "2024-03-24") | ||
| LocalDate departureDate, | ||
|
|
||
| @Schema(description = "출발 시간", example = "14:00") | ||
| LocalTime departureTime, | ||
|
|
||
| @Schema(description = "현재 모집 인원", example = "2") | ||
| Integer currentParticipants, | ||
|
|
||
| @Schema(description = "최대 모집 인원", example = "4") | ||
| Integer maxParticipants, | ||
|
|
||
| @Schema(description = "발신자 닉네임", example = "익명_123") | ||
| String senderNickname, | ||
|
|
||
| @Schema(description = "참여자 닉네임", example = "익명_456") | ||
| String joinedMemberNickname | ||
| ) { | ||
|
|
||
| public static CallvanNotificationResponse from(CallvanNotification notification) { | ||
| String departureName = notification.getDepartureType().getName(); | ||
| if (StringUtils.hasText(notification.getDepartureCustomName())) { | ||
| departureName = notification.getDepartureCustomName(); | ||
| } | ||
|
|
||
| String arrivalName = notification.getArrivalType().getName(); | ||
| if (StringUtils.hasText(notification.getArrivalCustomName())) { | ||
| arrivalName = notification.getArrivalCustomName(); | ||
| } | ||
|
|
||
| return new CallvanNotificationResponse( | ||
| notification.getId(), | ||
| notification.getNotificationType(), | ||
| notification.getMessagePreview(), | ||
| notification.getIsRead(), | ||
| notification.getCreatedAt(), | ||
| notification.getPost() != null ? notification.getPost().getId() : null, | ||
| departureName, | ||
| arrivalName, | ||
| notification.getDepartureDate(), | ||
| notification.getDepartureTime(), | ||
| notification.getCurrentParticipants(), | ||
| notification.getMaxParticipants(), | ||
| notification.getSenderNickname(), | ||
| notification.getJoinedMemberNickname() | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
줄넘김 이슈