77import cmf .commitField .domain .chat .chatRoom .dto .ChatRoomUserDto ;
88import cmf .commitField .domain .chat .chatRoom .service .ChatRoomService ;
99import cmf .commitField .domain .user .entity .CustomOAuth2User ;
10+ import cmf .commitField .global .aws .s3 .S3Service ;
1011import cmf .commitField .global .error .ErrorCode ;
1112import cmf .commitField .global .globalDto .GlobalResponse ;
1213import cmf .commitField .global .security .LoginCheck ;
2829@ RequestMapping ("/chat" )
2930public class ChatRoomController {
3031 private final ChatRoomService chatRoomService ;
31- private final FileService fileService ;
32+ private final S3Service s3Service ; // S3 νμΌ μ μ₯μ μν μλΉμ€
33+ private final FileService fileService ; //local file μ μ₯μ μν μλΉμ€
3234
3335 // μ±ν
λ°© μμ± (νμΌ μ
λ‘λ ν¬ν¨)
3436 @ PostMapping (value = "/room" , consumes = MediaType .MULTIPART_FORM_DATA_VALUE )
3537 public GlobalResponse <Object > createRoom (
3638 @ ModelAttribute @ Valid ChatRoomRequest chatRoomRequest ) throws IOException {
3739
38-
3940 // μΈμ¦ νμΈ
4041 Authentication authentication = SecurityContextHolder .getContext ().getAuthentication ();
4142
4243 if (authentication instanceof OAuth2AuthenticationToken ) {
4344 CustomOAuth2User principal = (CustomOAuth2User ) authentication .getPrincipal ();
44- Long userId = principal .getId (); // getId()λ₯Ό ν΅ν΄ userIdλ₯Ό μΆμΆ
45+ Long userId = principal .getId (); // getId()λ₯Ό ν΅ν΄ userId μΆμΆ
4546
4647 // νμΌ μ
λ‘λ μ²λ¦¬
4748 String imageUrl = null ;
4849 if (chatRoomRequest .getFile () != null && !chatRoomRequest .getFile ().isEmpty ()) {
49- imageUrl = fileService . saveFile (chatRoomRequest .getFile ()); // νμΌ μ μ₯
50+ imageUrl = s3Service . uploadFile (chatRoomRequest .getFile (), "chat-room" ); // S3μ μ
λ‘λ
5051 }
5152
5253 // μ±ν
λ°© μμ± μλΉμ€ νΈμΆ (μ΄λ―Έμ§ URL ν¬ν¨)
@@ -58,6 +59,7 @@ public GlobalResponse<Object> createRoom(
5859 }
5960 }
6061
62+
6163 //μ±ν
λ°© μ
μ₯
6264 @ PostMapping ("/room/join/{roomId}" )
6365 public GlobalResponse <Object > joinRoom (@ PathVariable Long roomId , @ RequestBody ChatRoomRequest chatRoomRequest ) {
@@ -253,8 +255,33 @@ public GlobalResponse<Object> searchRoomName(
253255 }
254256 }
255257
256-
257-
258+ // // μ±ν
λ°© μμ± (νμΌ μ
λ‘λ ν¬ν¨)
259+ // @PostMapping(value = "/room", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
260+ // public GlobalResponse<Object> createRoom(
261+ // @ModelAttribute @Valid ChatRoomRequest chatRoomRequest) throws IOException {
262+ //
263+ //
264+ // // μΈμ¦ νμΈ
265+ // Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
266+ //
267+ // if (authentication instanceof OAuth2AuthenticationToken) {
268+ // CustomOAuth2User principal = (CustomOAuth2User) authentication.getPrincipal();
269+ // Long userId = principal.getId(); // getId()λ₯Ό ν΅ν΄ userIdλ₯Ό μΆμΆ
270+ //
271+ // // νμΌ μ
λ‘λ μ²λ¦¬
272+ // String imageUrl = null;
273+ // if (chatRoomRequest.getFile() != null && !chatRoomRequest.getFile().isEmpty()) {
274+ // imageUrl = fileService.saveFile(chatRoomRequest.getFile()); // νμΌ μ μ₯
275+ // }
276+ //
277+ // // μ±ν
λ°© μμ± μλΉμ€ νΈμΆ (μ΄λ―Έμ§ URL ν¬ν¨)
278+ // chatRoomService.createRoom(chatRoomRequest, userId, imageUrl);
279+ //
280+ // return GlobalResponse.success("μ±ν
λ°©μ μμ±νμμ΅λλ€.");
281+ // } else {
282+ // throw new IllegalArgumentException("λ‘κ·ΈμΈ νμ μ΄μ©ν΄ μ£ΌμΈμ.");
283+ // }
284+ // }
258285
259286
260287}
0 commit comments