-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #350 from ghkdqhrbals/feature/chat-crud
Feature/chat crud
- Loading branch information
Showing
10 changed files
with
484 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
.Ds_store | ||
/redis | ||
.gradle | ||
**/build/ |
36 changes: 36 additions & 0 deletions
36
common-dto/src/main/java/com/example/commondto/dto/participant/ParticipantRequest.java
This file contains 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,36 @@ | ||
package com.example.commondto.dto.participant; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
public class ParticipantRequest { | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@Setter | ||
@ToString | ||
public static class RemoveParticipantDto { | ||
private Long roomId; | ||
|
||
@Builder | ||
public RemoveParticipantDto(Long roomId) { | ||
this.roomId = roomId; | ||
} | ||
} | ||
|
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@Setter | ||
@ToString | ||
public static class AddParticipantRequest { | ||
private Long roomId; | ||
|
||
@Builder | ||
public AddParticipantRequest(Long roomId) { | ||
this.roomId = roomId; | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
71 changes: 71 additions & 0 deletions
71
...kend-server/src/main/java/chatting/chat/domain/participant/api/ParticipantController.java
This file contains 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,71 @@ | ||
package chatting.chat.domain.participant.api; | ||
|
||
import chatting.chat.domain.participant.dto.ParticipantDto; | ||
import chatting.chat.domain.participant.service.ParticipantService; | ||
import chatting.chat.web.filter.UserContext; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import lombok.AllArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import java.util.List; | ||
|
||
@Slf4j | ||
@RestController | ||
@AllArgsConstructor | ||
public class ParticipantController { | ||
|
||
private final ParticipantService participantService; | ||
|
||
/** | ||
* 내가 참여중인 채팅방에서 나가기 | ||
* @param roomId | ||
* @implNote {@link UserContext#getUserId()} 가 필요합니다. | ||
* {@link UserContext#setUserId(String)} 를 통해 userId 를 저장해주세요. | ||
* UserConext 의 userId 는 {@link chatting.chat.web.filter.UserContextInterceptor} 에서 자동으로 설정됩니다. | ||
* @return if success return "success" else throw {@link com.example.commondto.error.CustomException} | ||
*/ | ||
@DeleteMapping("/participant") | ||
@Operation(summary = "Delete a participant") | ||
public String removeParticipant(@RequestParam Long roomId) { | ||
return participantService.remove(roomId, UserContext.getUserId()); | ||
} | ||
|
||
/** | ||
* 채팅방에 참여 | ||
* @param roomId | ||
* @implNote {@link UserContext#getUserId()} 가 필요합니다. | ||
* {@link UserContext#setUserId(String)} 를 통해 userId 를 저장해주세요. | ||
* UserConext 의 userId 는 {@link chatting.chat.web.filter.UserContextInterceptor} 에서 자동으로 설정됩니다. | ||
* @return if success return "success" else throw {@link com.example.commondto.error.CustomException} | ||
*/ | ||
@PostMapping("/participant") | ||
@Operation(summary = "Add a participant") | ||
public String addParticipant(@RequestParam Long roomId) { | ||
return participantService.addParticipant(roomId, UserContext.getUserId()); | ||
} | ||
|
||
/** | ||
* 채팅방에 참여중인 유저 목록 조회 | ||
* @return List {@link ParticipantDto} | ||
*/ | ||
@GetMapping("/participants") | ||
@Operation(summary = "Get List of participants by room id") | ||
public List<ParticipantDto> getParticipants(@RequestParam Long roomId) { | ||
return participantService.findParticipantByRoomId(roomId); | ||
} | ||
|
||
/** | ||
* 내가 참여중인 채팅방 목록 조회 | ||
* @return List {@link ParticipantDto} | ||
*/ | ||
@GetMapping("/participant") | ||
@Operation(summary = "Get List of my participants") | ||
public List<ParticipantDto> getParticipant() { | ||
return participantService.findAllByUserId(UserContext.getUserId()); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.