11import { ChatroomRepository } from "../repository/chatroom.repository.js" ;
22import { ChatRepository } from "../repository/chat.repository.js" ;
33import { UserRepository } from "../../user/repository/user.repository.js" ;
4- import { RequestRepository } from "../../request /repository/request .repository.js" ;
4+ import { CommissionRepository } from "../../commission /repository/commission .repository.js" ;
55import { UserNotFoundError } from "../../common/errors/user.errors.js" ;
66import { ArtistNotFoundError } from "../../common/errors/artist.errors.js" ;
7- import { RequestNotFoundError } from "../../common/errors/request .errors.js" ;
7+ import { CommissionNotFoundError } from "../../common/errors/commission .errors.js" ;
88import { ChatroomNotFoundError } from "../../common/errors/chat.errors.js" ;
99import { ChatroomListResponseDto } from "../dto/chatroom.dto.js" ;
1010
1111export const ChatroomService = {
1212 async createChatroom ( dto ) {
13- const user = await UserRepository . findUserById ( dto . consumerId ) ;
13+ const user = await UserRepository . findUserById ( dto . userId ) ;
1414 if ( ! user ) {
15- throw new UserNotFoundError ( { consumerId : dto . consumerId } ) ;
15+ throw new UserNotFoundError ( { userId : dto . userId } ) ;
1616 }
1717
1818 const artist = await UserRepository . findArtistById ( dto . artistId ) ;
1919 if ( ! artist ) {
2020 throw new ArtistNotFoundError ( { artistId : dto . artistId } ) ;
2121 }
2222
23- const request = await RequestRepository . findRequestById ( dto . requestId ) ;
24- if ( ! request ) {
25- throw new RequestNotFoundError ( { requestId : dto . requestId } ) ;
23+ const commission = await CommissionRepository . findCommissionById ( dto . commissionId ) ;
24+ if ( ! commission ) {
25+ throw new CommissionNotFoundError ( { commissionId : dto . commissionId } ) ;
2626 }
2727
2828 // 채팅방 중복 확인
2929 const existing = await ChatroomRepository . findChatroomByUsersAndCommission (
30- dto . consumerId ,
30+ dto . userId ,
3131 dto . artistId ,
32- dto . requestId
32+ dto . commissionId
3333 ) ;
3434
3535 // 기존 채팅방 반환
@@ -39,21 +39,21 @@ export const ChatroomService = {
3939
4040 // 채팅방이 없을 시 생성
4141 const chatroom = await ChatroomRepository . createChatroom ( {
42- consumerId : dto . consumerId ,
42+ userId : dto . userId ,
4343 artistId : dto . artistId ,
44- requestId : dto . requestId ,
44+ commissionId : dto . commissionId ,
4545 } ) ;
4646
4747 return chatroom ;
4848 } ,
4949
5050 async getChatroomsByUserId ( dto ) {
51- const user = await UserRepository . findUserById ( dto . consumerId ) ;
51+ const user = await UserRepository . findUserById ( dto . userId ) ;
5252 if ( ! user ) {
53- throw new UserNotFoundError ( { consumerId : dto . consumerId } ) ;
53+ throw new UserNotFoundError ( { userId : dto . userId } ) ;
5454 }
5555
56- const chatrooms = await ChatroomRepository . findChatroomsByUser ( dto . consumerId ) ;
56+ const chatrooms = await ChatroomRepository . findChatroomsByUser ( dto . userId ) ;
5757 console . log ( dto . accountId )
5858
5959 const result = [ ] ;
@@ -76,7 +76,7 @@ export const ChatroomService = {
7676 const chatrooms = await ChatroomRepository . findChatroomsByIds ( dto . chatroomIds ) ;
7777
7878 const chatroomIdsToDelete = chatrooms
79- . filter ( cr => cr . hiddenConsumer && cr . hiddenArtist )
79+ . filter ( cr => cr . hiddenUser && cr . hiddenArtist )
8080 . map ( cr => cr . id ) ;
8181
8282 if ( chatroomIdsToDelete . length > 0 ) {
0 commit comments