-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
12 changed files
with
273 additions
and
12 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
package shop.geeksasang.controller.chat; | ||
|
||
import io.swagger.annotations.ApiOperation; | ||
import io.swagger.annotations.ApiResponse; | ||
import io.swagger.annotations.ApiResponses; | ||
import io.swagger.annotations.*; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.multipart.MultipartFile; | ||
import shop.geeksasang.config.response.BaseResponse; | ||
import shop.geeksasang.domain.chat.Chat; | ||
import shop.geeksasang.domain.chat.ChatRoom; | ||
import shop.geeksasang.dto.chat.PostChatImageReq; | ||
import shop.geeksasang.dto.chat.chatchief.PostRemoveMemberByChiefReq; | ||
import shop.geeksasang.dto.chat.partychatroom.GetPartyChatRoomsRes; | ||
import shop.geeksasang.dto.chat.PostChatReq; | ||
|
@@ -46,11 +46,39 @@ public BaseResponse<PartyChatRoomRes> createPartyChatRoom(HttpServletRequest req | |
@PostMapping("/chat") | ||
public BaseResponse<String> createChat(HttpServletRequest request, @RequestBody PostChatReq dto){ | ||
JwtInfo jwtInfo = (JwtInfo) request.getAttribute("jwtInfo"); | ||
deliveryPartyChatService.createChat(jwtInfo.getUserId(), dto.getEmail(), dto.getChatRoomId(), dto.getContent(), dto.getIsSystemMessage(), dto.getProfileImgUrl(), dto.getChatType(), dto.getChatId()); | ||
deliveryPartyChatService.createChat(jwtInfo.getUserId(), dto.getEmail(), dto.getChatRoomId(), dto.getContent(), dto.getIsSystemMessage(), dto.getProfileImgUrl(), dto.getChatType(), dto.getChatId(), dto.getIsImageMessage()); | ||
return new BaseResponse("채팅송신을 성공했습니다."); | ||
} | ||
|
||
|
||
@ApiOperation(value = "채팅 이미지 전송", notes = "채팅방에서 이미지 전송 API. swagger 에서 이미지(multipartfile)처리가 잘 되지 않으므로, postman으로 테스트 바랍니다.") | ||
@ApiImplicitParams({ | ||
@ApiImplicitParam(name = "content", required = true, dataTypeClass = String.class, example = "이미지 채팅입니다."), | ||
@ApiImplicitParam(name = "chatRoomId", required = true, dataTypeClass = String.class, example = "638ef5c109c1212827135cf3"), | ||
@ApiImplicitParam(name = "isSystemMessage", dataTypeClass = Boolean.class, example = "false"), | ||
@ApiImplicitParam(name = "email", required = true, dataTypeClass = String.class, example = "[email protected]"), | ||
@ApiImplicitParam(name = "profileImgUrl", required = true, dataTypeClass = String.class, example = "https://yogit.s3.ap-northeast-2.amazonaws.com/boardimguuid2"), | ||
@ApiImplicitParam(name = "chatType", required = true, dataTypeClass = String.class, example = "publish 또는 read"), | ||
@ApiImplicitParam(name = "chatId", required = true, dataTypeClass = String.class, example = "publish일 때는 none / read일 때는 chatId(인덱스)"), | ||
@ApiImplicitParam(name = "images", required = true, dataTypeClass = MultipartFile.class, example = "MultiPartFile 클래스 스웨거에서 에러나면 포스트맨에서 실행 바람"), | ||
@ApiImplicitParam(name = "isImageMessage", dataTypeClass = Boolean.class, example = "false"), | ||
}) | ||
@ApiResponses({ | ||
@ApiResponse(code = 1000 ,message ="요청에 성공하셨습니다."), | ||
@ApiResponse(code = 2009, message ="존재하지 않는 멤버입니다"), | ||
@ApiResponse(code = 2207, message ="채팅방이 존재하지 않습니다."), | ||
@ApiResponse(code = 2208, message ="채팅방 멤버가 존재하지 않습니다."), | ||
@ApiResponse(code = 2211, message ="이미지 갯수를 초과했습니다."), | ||
@ApiResponse(code = 4000 ,message ="서버 오류입니다.") | ||
}) | ||
@PostMapping("/chatimage") | ||
public BaseResponse<String> createChatImage(HttpServletRequest request, @ModelAttribute @Validated PostChatImageReq dto){ | ||
JwtInfo jwtInfo = (JwtInfo) request.getAttribute("jwtInfo"); | ||
deliveryPartyChatService.createChatImage(jwtInfo.getUserId(), dto.getEmail(), dto.getChatRoomId(), dto.getContent(), dto.getIsSystemMessage(), dto.getProfileImgUrl(), dto.getChatType(), dto.getChatId(), dto.getImages(), dto.getIsImageMessage()); | ||
return new BaseResponse("채팅 이미지 전송을 성공했습니다."); | ||
} | ||
|
||
|
||
@ApiOperation(value = "채팅방 멤버 추가 및 rabbitmq 큐 생성", notes = "(jwt 토큰 필요)멤버의 정보만 추가") | ||
@ApiResponses({ | ||
@ApiResponse(code = 1000 ,message ="요청에 성공하셨습니다."), | ||
|
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
34 changes: 34 additions & 0 deletions
34
src/main/java/shop/geeksasang/dto/chat/PostChatImageReq.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,34 @@ | ||
package shop.geeksasang.dto.chat; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import java.util.List; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Data | ||
public class PostChatImageReq { | ||
|
||
private String content; | ||
|
||
private String chatRoomId; | ||
|
||
private Boolean isSystemMessage; | ||
|
||
private String email; | ||
|
||
private String profileImgUrl; | ||
|
||
private String chatType; | ||
|
||
private String chatId; | ||
|
||
private List<MultipartFile> images; // 최대 5개 | ||
|
||
private Boolean isImageMessage; | ||
} |
77 changes: 77 additions & 0 deletions
77
src/main/java/shop/geeksasang/dto/chat/PostChatImageRes.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,77 @@ | ||
package shop.geeksasang.dto.chat; | ||
|
||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import shop.geeksasang.domain.chat.Chat; | ||
|
||
import javax.validation.constraints.NotEmpty; | ||
import java.time.LocalDateTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@NoArgsConstructor | ||
@Getter | ||
public class PostChatImageRes { | ||
|
||
private String chatId; | ||
|
||
private String content; | ||
|
||
@NotEmpty | ||
private String chatRoomId; | ||
|
||
private Boolean isSystemMessage; | ||
|
||
private int memberId; | ||
|
||
private String email; | ||
|
||
private String profileImgUrl; | ||
|
||
private List<Integer> readMembers = new ArrayList<>(); // 읽은 멤버 ID 리스트 | ||
|
||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul") | ||
private LocalDateTime createdAt; | ||
|
||
private String chatType; | ||
|
||
private int unreadMemberCnt; | ||
|
||
private Boolean isImageMessage; | ||
|
||
@Builder | ||
public PostChatImageRes(String chatId, String content, String chatRoomId, Boolean isSystemMessage, int memberId, String email, String profileImgUrl, List<Integer> readMembers, LocalDateTime createdAt, String chatType, int unreadMemberCnt, Boolean isImageMessage) { | ||
this.chatId = chatId; | ||
this.content = content; | ||
this.chatRoomId = chatRoomId; | ||
this.isSystemMessage = isSystemMessage; | ||
this.memberId = memberId; | ||
this.email = email; | ||
this.profileImgUrl = profileImgUrl; | ||
this.readMembers = readMembers; | ||
this.createdAt = createdAt; | ||
this.chatType = chatType; | ||
this.unreadMemberCnt = unreadMemberCnt; | ||
this.isImageMessage = isImageMessage; | ||
} | ||
|
||
public static PostChatImageRes toDto(Chat chat, String email, String chatType, int unreadMemberCnt){ | ||
return PostChatImageRes.builder() | ||
.chatId(chat.getId()) | ||
.content(chat.getContent()) | ||
.chatRoomId(chat.getPartyChatRoom().getId()) | ||
.isSystemMessage(chat.getIsSystemMessage()) | ||
.memberId(chat.getPartyChatRoomMember().getMemberId()) | ||
.email(email) | ||
.profileImgUrl(chat.getProfileImgUrl()) | ||
.readMembers(chat.getReadMembers()) | ||
.createdAt(chat.getBaseEntityMongo().getCreatedAt()) | ||
.chatType(chatType) | ||
.unreadMemberCnt(unreadMemberCnt) | ||
.isImageMessage(chat.getIsImageMessage()) | ||
.build(); | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
src/main/java/shop/geeksasang/rabbitmq/RabbitMQTut5Receiver.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,39 @@ | ||
package shop.geeksasang.rabbitmq; | ||
|
||
import org.springframework.amqp.rabbit.annotation.RabbitListener; | ||
import org.springframework.util.StopWatch; | ||
|
||
//TODO: rabbitmq 5번 튜토리얼 Consumer 코드임, 구독 및 수신 로컬 스프링에서는 테스트 성공. | ||
public class RabbitMQTut5Receiver { | ||
|
||
@RabbitListener(queues = "87") | ||
public void receive1(String in) throws InterruptedException { | ||
receive(in, 1); | ||
} | ||
|
||
@RabbitListener(queues = "neo") | ||
public void receive2(String in) throws InterruptedException { | ||
receive(in, 2); | ||
} | ||
|
||
public void receive(String in, int receiver) throws | ||
InterruptedException { | ||
System.out.println("===============Received 5번 튜토리얼 소비자<" + in + ">"); | ||
StopWatch watch = new StopWatch(); | ||
watch.start(); | ||
System.out.println("instance " + receiver + " [x] Received '" | ||
+ in + "'"); | ||
doWork(in); | ||
watch.stop(); | ||
System.out.println("instance " + receiver + " [x] Done in " | ||
+ watch.getTotalTimeSeconds() + "s"); | ||
} | ||
|
||
private void doWork(String in) throws InterruptedException { | ||
for (char ch : in.toCharArray()) { | ||
if (ch == '.') { | ||
Thread.sleep(1000); | ||
} | ||
} | ||
} | ||
} |
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.