Skip to content

Commit

Permalink
#15 feat : 채팅 참여자 목록 보기
Browse files Browse the repository at this point in the history
  • Loading branch information
Suanna01 committed Apr 23, 2023
1 parent 3aaa42b commit 6e66ec5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/main/java/com/zatch/zatchserver/controller/ChatController.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,15 @@ public ResponseEntity postStarReview(HttpServletRequest req) {
return new ResponseEntity(DefaultRes.res(StatusCode.INTERNAL_SERVER_ERROR, ResponseMessage.INTERNAL_SERVER_ERROR, "Error After Chat(Review&Star)"), HttpStatus.INTERNAL_SERVER_ERROR);
}
}

// 채팅 참여자 목록 보기
@GetMapping("/{userId}/{roomId}/profile")
@ApiOperation(value = "채팅 참여자 목록 보기", notes = "채팅 참여자 목록 보기 API")
public List<Map<String, Object>> profileChatRoom(@PathVariable("userId") String userId, @PathVariable("roomId") String roomId) {
return chatService.profileChatRoom(userId, roomId);
}

// 차단 & 신고하기


}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.springframework.http.HttpStatus;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.server.ResponseStatusException;

import java.util.List;
Expand Down Expand Up @@ -87,4 +86,20 @@ public String deleteChatRoom(String userId, String roomId) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Delete Chat Room Not Found");
}
}

@Override
public List<Map<String, Object>> getProfileChatRoom(String userId, String roomId) {
try {
String sql = "SELECT chat_id, chat_room_id, chat_sender, chat_receiver, " +
"(SELECT user.nickname FROM user WHERE user.user_id = chat.chat_sender) AS chat_sender_nickname, " +
"(SELECT user.nickname FROM user WHERE user.user_id = chat.chat_receiver) AS chat_receiver_nickname " +
"FROM chat LEFT JOIN user on user.user_id = chat.chat_receiver " +
"WHERE (chat_sender = ? OR chat_receiver = ?) AND chat_room_id = ?";
Object[] params = {userId, userId, roomId};
System.out.println("User's Chat Profile SQL select");
return jdbcTemplate.queryForList(sql, params);
} catch (Exception e){
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "User's Chat List Not Found");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.zatch.zatchserver.repository;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

Expand All @@ -11,4 +9,5 @@ public interface ChatRepositoryImpl {
String sendImage(String type, String roomId, String sender, String receiver, String imgUrl);
String after_deal(Long send_user_id, Long receive_user_id, String review_context, int star_rating);
String deleteChatRoom(String userId, String roomId);
List<Map<String, Object>> getProfileChatRoom(String userId, String roomId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public interface ChatService {
String updateDB(String type, String roomId, String sender, String receiver, String message);
String sendImage(String type, String roomId, String sender, String receiver, String imgUrl);
String outChatRoom(String userId, String roomId);
List<Map<String, Object>> profileChatRoom(String userId, String roomId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,9 @@ public String sendImage(String type, String roomId, String sender, String receiv
public String outChatRoom(String userId, String roomId) {
return chatRepository.deleteChatRoom(userId, roomId);
}

@Override
public List<Map<String, Object>> profileChatRoom(String userId, String roomId) {
return chatRepository.getProfileChatRoom(userId, roomId);
}
}

0 comments on commit 6e66ec5

Please sign in to comment.