Skip to content

Commit

Permalink
hotfix(BE): 채팅방 생성시 생기는 오류 체크
Browse files Browse the repository at this point in the history
  • Loading branch information
namhyo01 committed Nov 21, 2023
1 parent a443853 commit cd5646f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ public class ChatRoomController {
@Operation(summary = "Create chatroom", description = "새로운 채팅방을 생성한다.")
@PostMapping("/chatroom")
public UUID createChatroom(@RequestBody @Valid CreateChatRoomDto createChatRoomDto) {

SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication();
if (securityUser == null) {
log.error("ChatRoomController::createChatroom: Login is needed");
throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE);
}

createChatRoomDto.setMasterId(securityUser.getUserId());
ChatRoom chatRoom = createChatRoomUsecase.createRoom(createChatRoomDto);
return chatRoom.getChatroomId();
}
Expand All @@ -64,12 +67,7 @@ public List<ChatRoom> chatRoomList(@PageableDefault(sort = "createdAt", directio

@Operation(summary = "Delete chatroom", description = "채팅방을 삭제한다.")
@DeleteMapping("/chatroom/{chatRoomId}")
public void outChatRoom(@PathVariable UUID chatRoomId) {
SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication();
if (securityUser == null) {
log.error("ChatRoomController::outChatroom: Login is needed");
throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE);
}
public void outChatRoom(@PathVariable UUID chatRoomId){
log.info("chatroom = {}", chatRoomId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
import com.example.api.chatroom.type.ChatRoomEnum;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.UUID;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CreateChatRoomDto {
@NotNull
private UUID masterId; // TODO 추후 jwt에서 얻을 수 있어 삭제 가능
// @NotNull
private UUID masterId;

@NotBlank
private String chatroomName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.UUID;

@RestController
@RequiredArgsConstructor
Expand Down Expand Up @@ -71,4 +73,17 @@ public void deleteFriend(FriendDto friendDto) {
}
deleteFriendUsecase.deleteFriend(friendDto);
}

@Operation(summary = "check friend", description = "친구 여부 확인")
@GetMapping("/friend/{friendId}")
public ResponseEntity<String> findFriend(@PathVariable UUID friendId){
SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication();
if (securityUser == null) {
log.error("FriendController::findFriend: Login is needed");
throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE);
}

return ResponseEntity.ok("yes");

}
}
2 changes: 1 addition & 1 deletion src/main/java/com/example/api/friend/dto/FriendDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@NoArgsConstructor
@AllArgsConstructor
public class FriendDto {
@NotNull
// @NotNull
private UUID userId;

@NotNull
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/example/api/member/dto/AddMemberDto.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package com.example.api.member.dto;

import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.UUID;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AddMemberDto {
@NotNull
private UUID chatroomId;
Expand Down

0 comments on commit cd5646f

Please sign in to comment.