Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
20210815 committed Dec 7, 2024
2 parents eda5b46 + f606f99 commit f4cfacc
Show file tree
Hide file tree
Showing 7 changed files with 469 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
import com.carely.backend.controller.docs.VolunteerAPI;
import com.carely.backend.domain.ChatMessageEntity;
import com.carely.backend.domain.ChatRoomEntity;
import com.carely.backend.dto.response.ErrorResponseDTO;
import com.carely.backend.dto.response.ResponseDTO;
import com.carely.backend.dto.volunteer.CreateVolunteerDTO;
import com.carely.backend.dto.volunteer.GetVolunteerInfoDTO;
import com.carely.backend.dto.volunteer.UpdateVolunteerApprovalDTO;
import com.carely.backend.service.VolunteerService;
import com.carely.backend.service.chat.ChatService;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.messaging.simp.SimpMessagingTemplate;
Expand All @@ -32,6 +38,25 @@ public class VolunteerController implements VolunteerAPI {
private final ObjectMapper objectMapper;
private final SimpMessagingTemplate messagingTemplate;

@ApiResponses({
@ApiResponse(responseCode = "200", description = "성공적으로 자원봉사 요청을 생성한 경우",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ResponseDTO.class),
examples = @ExampleObject(value =
"{ \"status\": 200, \"code\": \"SUCCESS_CREATE_VOLUNTEER\", \"message\": \"자원봉사 요청을 성공적으로 생성했습니다.\", \"data\": { \"id\": 3, \"volunteerId\": 51, \"caregiverId\": 50, \"startTime\": \"2024-11-17T04:33:06.36\", \"endTime\": \"2024-11-17T04:33:06.36\", \"durationHours\": 4, \"salary\": 0, \"location\": \"경기도 용인시 수지구 어딘가\", \"mainTask\": \"설거지\", \"volunteerType\": \"VOLUNTEER_REQUEST\", \"roomId\": \"c0babffb-a39b-45e5-b326-a964b49e9409\" } }"))),

@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터로 자원봉사 요청 실패",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ErrorResponseDTO.class),
examples = @ExampleObject(value =
"{ \"status\": 400, \"code\": \"INVALID_REQUEST\", \"message\": \"요청 데이터가 잘못되었습니다.\", \"data\": null }"))),

@ApiResponse(responseCode = "404", description = "해당 채팅방이나 사용자를 찾을 수 없는 경우",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ErrorResponseDTO.class),
examples = @ExampleObject(value =
"{ \"status\": 404, \"code\": \"NOT_FOUND\", \"message\": \"해당 채팅방 또는 사용자를 찾을 수 없습니다.\", \"data\": null }")))
})
@PostMapping
public ResponseEntity<?> createVolunteer(@RequestBody CreateVolunteerDTO dto) {
CreateVolunteerDTO.Res res = volunteerService.createVolunteer(dto);
Expand Down
59 changes: 56 additions & 3 deletions src/main/java/com/carely/backend/controller/docs/ChatAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
import com.carely.backend.domain.ChatMessageEntity;
import com.carely.backend.dto.chat.ChatRequest;
import com.carely.backend.dto.chat.ChatRoomResponseDTO;
import com.carely.backend.dto.response.ErrorResponseDTO;
import com.carely.backend.dto.response.ResponseDTO;
import com.carely.backend.dto.user.CustomUserDetails;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -16,17 +22,49 @@
import java.util.List;

public interface ChatAPI {
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "채팅방 생성에 성공한 경우",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ResponseDTO.class),
examples = @ExampleObject(value =
"{ \"status\": 201, \"code\": \"SUCCESS_CREATE_CHATROOM\", \"message\": \"채팅방이 성공적으로 생성되었습니다.\", \"data\": { \"id\": 14, \"roomId\": \"ac035619-3602-40e8-8b5f-e7ee68c368a2\", \"user1\": 1, \"user2\": 4, \"lastMessage\": null, \"lastUpdated\": \"2024-11-10T07:10:32.2675425\", \"blocked\": false } }"))),

@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터로 채팅방 생성 실패",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ErrorResponseDTO.class),
examples = @ExampleObject(value =
"{ \"status\": 400, \"code\": \"INVALID_REQUEST\", \"message\": \"요청 데이터가 잘못되었습니다.\", \"data\": null }"))),

@ApiResponse(responseCode = "401", description = "인증되지 않은 사용자로 요청할 경우",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ErrorResponseDTO.class),
examples = @ExampleObject(value =
"{ \"status\": 401, \"code\": \"UNAUTHORIZED\", \"message\": \"사용자가 인증되지 않았습니다.\", \"data\": null }")))
})
@Operation(summary = "채팅방을 생성하기", description = "채팅방을 생성합니다.")
ResponseEntity<?> createRoom(@RequestBody ChatRequest chatRequest);
public ResponseEntity<?> createRoom(@RequestBody ChatRequest chatRequest);

@Operation(summary = "메세지 전송하기", description = "메세지를 전송합니다.")
ChatMessageEntity sendMessage(ChatMessageEntity chatMessage);

// @Operation(summary = "채팅을 진행하고 있는 모든 채팅방 조회하기", description = "채팅을 진행하고 있는 모든 채팅방을 조회합니다.")
// public ResponseEntity<ResponseDTO<List<ChatRoomResponseDTO>>> findAllChatRooms() ;

@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공적으로 채팅방 메시지를 조회한 경우",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ResponseDTO.class),
examples = @ExampleObject(value =
"{ \"status\": 200, \"code\": \"SUCCESS_FIND_CHATROOM\", \"message\": \"모든 채팅방을 조회했습니다.\", \"data\": [ { \"id\": 6, \"type\": \"TALK\", \"roomId\": \"c0babffb-a39b-45e5-b326-a964b49e9409\", \"senderId\": 51, \"message\": \"반가워요\", \"timestamp\": \"2024-11-17T18:15:39.538526\", \"fileUrl\": null, \"fileName\": null, \"isApproved\": false }, { \"id\": 7, \"type\": \"TALK\", \"roomId\": \"c0babffb-a39b-45e5-b326-a964b49e9409\", \"senderId\": 51, \"message\": \"ㅋㅎ\", \"timestamp\": \"2024-11-17T18:15:55.295389\", \"fileUrl\": null, \"fileName\": null, \"isApproved\": false }, { \"id\": 8, \"type\": \"RESERVATION\", \"roomId\": \"c0babffb-a39b-45e5-b326-a964b49e9409\", \"senderId\": 51, \"message\": \"{\\\"id\\\":3,\\\"volunteerId\\\":51,\\\"caregiverId\\\":50,\\\"startTime\\\":\\\"2024-11-17T04:33:06.36\\\",\\\"endTime\\\":\\\"2024-11-17T04:33:06.36\\\",\\\"durationHours\\\":4,\\\"salary\\\":0,\\\"location\\\":\\\"경기도 용인시 수지구 어딘가\\\",\\\"mainTask\\\":\\\"설거지\\\",\\\"volunteerType\\\":\\\"VOLUNTEER_REQUEST\\\",\\\"roomId\\\":\\\"c0babffb-a39b-45e5-b326-a964b49e9409\\\"}\", \"timestamp\": \"2024-11-17T18:30:44.223335\", \"fileUrl\": null, \"fileName\": null, \"isApproved\": true }, { \"id\": 9, \"type\": \"RESERVATION\", \"roomId\": \"c0babffb-a39b-45e5-b326-a964b49e9409\", \"senderId\": 50, \"message\": \"약속을 수락했어요!\", \"timestamp\": \"2024-11-17T18:19:04.822753\", \"fileUrl\": null, \"fileName\": null, \"isApproved\": true }, { \"id\": 23, \"type\": \"FILE\", \"roomId\": \"95c506c0-28f7-4877-80ad-6863ce2e1af9\", \"senderId\": 51, \"message\": \"사진을 보냈습니다.\", \"timestamp\": \"2024-11-17T22:03:20.713524\", \"fileUrl\": \"https://groomcaregiver.s3.ap-northeast-2.amazonaws.com/cbf9f1dc-ff59-41e9-b612-e121eddab16c-KakaoTalk_20241114_101142529.jpg\", \"fileName\": \"KakaoTalk_20241114_101142529.jpg\", \"isApproved\": null } ] }"))),

@ApiResponse(responseCode = "404", description = "해당 채팅방이 존재하지 않을 경우",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ErrorResponseDTO.class),
examples = @ExampleObject(value =
"{ \"status\": 404, \"code\": \"CHATROOM_NOT_FOUND\", \"message\": \"해당 채팅방을 찾을 수 없습니다.\", \"data\": null }")))
})
@Operation(summary = "채팅방에 해당하는 메세지 조회하기.", description = "채팅방에 해당하는 메세지들 조회합니다.")
ResponseEntity<?> getMessagesByRoomId(@PathVariable("roomId") String roomId);
public ResponseEntity<?> getMessagesByRoomId(@PathVariable("roomId") String roomId);

@Operation(summary = "채팅방 종료하기(웹소켓 close)", description = "채팅방을 종료합니다. 채팅 내역이 더 이상 조회되지 않습니다.")
ResponseEntity<String> closeRoom(@PathVariable("roomId") String roomId);
Expand All @@ -37,6 +75,21 @@ public interface ChatAPI {
@Operation(summary = "채팅방에 이미지 전송하기", description = "채팅방에 이미지를 전송합니다.")
ResponseEntity<ChatMessageEntity> uploadFile(@RequestParam("file") MultipartFile file, @PathVariable("roomId") String roomId);

@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공적으로 열린 채팅방을 조회한 경우",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ResponseDTO.class),
examples = @ExampleObject(value =
"{ \"status\": 200, \"code\": \"SUCCESS_FIND_CHATROOM\", \"message\": \"모든 채팅방을 조회했습니다.\", \"data\": [ { \"id\": 6, \"type\": \"TALK\", \"roomId\": \"c0babffb-a39b-45e5-b326-a964b49e9409\", \"senderId\": 51, \"message\": \"반가워요\", \"timestamp\": \"2024-11-17T18:15:39.538526\", \"fileUrl\": null, \"fileName\": null, \"isApproved\": false }, { \"id\": 7, \"type\": \"TALK\", \"roomId\": \"c0babffb-a39b-45e5-b326-a964b49e9409\", \"senderId\": 51, \"message\": \"ㅋㅎ\", \"timestamp\": \"2024-11-17T18:15:55.295389\", \"fileUrl\": null, \"fileName\": null, \"isApproved\": false }, { \"id\": 8, \"type\": \"RESERVATION\", \"roomId\": \"c0babffb-a39b-45e5-b326-a964b49e9409\", \"senderId\": 51, \"message\": \"{\\\"id\\\":3,\\\"volunteerId\\\":51,\\\"caregiverId\\\":50,\\\"startTime\\\":\\\"2024-11-17T04:33:06.36\\\",\\\"endTime\\\":\\\"2024-11-17T04:33:06.36\\\",\\\"durationHours\\\":4,\\\"salary\\\":0,\\\"location\\\":\\\"경기도 용인시 수지구 어딘가\\\",\\\"mainTask\\\":\\\"설거지\\\",\\\"volunteerType\\\":\\\"VOLUNTEER_REQUEST\\\",\\\"roomId\\\":\\\"c0babffb-a39b-45e5-b326-a964b49e9409\\\"}\", \"timestamp\": \"2024-11-17T18:30:44.223335\", \"fileUrl\": null, \"fileName\": null, \"isApproved\": true }, { \"id\": 9, \"type\": \"RESERVATION\", \"roomId\": \"c0babffb-a39b-45e5-b326-a964b49e9409\", \"senderId\": 50, \"message\": \"약속을 수락했어요!\", \"timestamp\": \"2024-11-17T18:19:04.822753\", \"fileUrl\": null, \"fileName\": null, \"isApproved\": true }, { \"id\": 23, \"type\": \"FILE\", \"roomId\": \"95c506c0-28f7-4877-80ad-6863ce2e1af9\", \"senderId\": 51, \"message\": \"사진을 보냈습니다.\", \"timestamp\": \"2024-11-17T22:03:20.713524\", \"fileUrl\": \"https://groomcaregiver.s3.ap-northeast-2.amazonaws.com/cbf9f1dc-ff59-41e9-b612-e121eddab16c-KakaoTalk_20241114_101142529.jpg\", \"fileName\": \"KakaoTalk_20241114_101142529.jpg\", \"isApproved\": null } ] }"))),

@ApiResponse(responseCode = "404", description = "열린 채팅방이 존재하지 않을 경우",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ErrorResponseDTO.class),
examples = @ExampleObject(value =
"{ \"status\": 404, \"code\": \"CHATROOMS_NOT_FOUND\", \"message\": \"열린 채팅방이 존재하지 않습니다.\", \"data\": null }")))
})
@Operation(summary = "열린 채팅방 조회하기", description = "열린 채팅방을 조회합니다.")
ResponseEntity<ResponseDTO<List<ChatRoomResponseDTO>>> findAllChatRooms(@AuthenticationPrincipal CustomUserDetails user);
public ResponseEntity<ResponseDTO<List<ChatRoomResponseDTO>>> findAllChatRooms(
@AuthenticationPrincipal CustomUserDetails user);

}
28 changes: 27 additions & 1 deletion src/main/java/com/carely/backend/controller/docs/MapAPI.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
package com.carely.backend.controller.docs;

import com.carely.backend.domain.enums.UserType;
import com.carely.backend.dto.response.ErrorResponseDTO;
import com.carely.backend.dto.response.ResponseDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

public interface MapAPI {
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공적으로 유저 목록을 조회한 경우",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ResponseDTO.class),
examples = @ExampleObject(value =
"{ \"status\": 200, \"code\": \"SUCCESS_RETRIEVE_USER\", \"message\": \"유저 정보 조회를 성공했습니다.\", \"data\": [ { \"userId\": 1, \"username\": \"박수정\", \"city\": \"용인시 수지구\", \"address\": \"경기도 용인시 수지구 고기동 15\", \"detailAddress\": \"202호\", \"userType\": \"CAREGIVER\", \"shareLocation\": true, \"latitude\": 37.3418, \"longitude\": 127.0951, \"talk\": \"보통\", \"eat\": \"보통\", \"toilet\": \"서투름\", \"bath\": \"수월\", \"walk\": \"수월\", \"togetherTime\": 0, \"km\": 6.354688064803219 }, { \"userId\": 2, \"username\": \"김영진\", \"city\": \"용인시 수지구\", \"address\": \"경기도 용인시 수지구 고기동 산16-2\", \"detailAddress\": \"202호\", \"userType\": \"CAREGIVER\", \"shareLocation\": true, \"latitude\": 37.342, \"longitude\": 127.0949, \"talk\": \"수월\", \"eat\": \"수월\", \"toilet\": \"보통\", \"bath\": \"서투름\", \"walk\": \"보통\", \"togetherTime\": 0, \"km\": 6.339194156654298 } ] }"))),

@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터로 조회 실패한 경우",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ErrorResponseDTO.class),
examples = @ExampleObject(value =
"{ \"status\": 400, \"code\": \"INVALID_REQUEST\", \"message\": \"요청 데이터가 잘못되었습니다.\", \"data\": null }"))),

@ApiResponse(responseCode = "404", description = "해당 조건에 맞는 유저를 찾을 수 없는 경우",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ErrorResponseDTO.class),
examples = @ExampleObject(value =
"{ \"status\": 404, \"code\": \"USER_NOT_FOUND\", \"message\": \"조건에 맞는 유저를 찾을 수 없습니다.\", \"data\": null }")))
})
@Operation(summary = "지도에서 유저 목록 조회하기", description = "지도에서 유저 목록을 조회합니다.")
ResponseEntity<ResponseDTO> findUsersByCityAndOptionalUserTypes(
public ResponseEntity<ResponseDTO> findUsersByCityAndOptionalUserTypes(
@RequestParam(value = "userType", required = false) List<UserType> userTypes);

}
Loading

0 comments on commit f4cfacc

Please sign in to comment.