@@ -53,7 +53,7 @@ public ChannelDto createPublicChannel(ChannelPublicRequest request) {
53
53
.name (request .name ())
54
54
.description (request .description ())
55
55
.build ();
56
- channelRepository .save (channel );
56
+ channel = channelRepository .save (channel );
57
57
58
58
log .info ("공개 채널 생성 성공: channelName={}, createdAt={}" ,
59
59
channel .getName (),
@@ -68,7 +68,8 @@ public ChannelDto createPrivateChannel(ChannelPrivateRequest request) {
68
68
Channel channel = Channel .builder ()
69
69
.type (ChannelType .PRIVATE )
70
70
.build ();
71
- channelRepository .save (channel );
71
+ Channel savedChannel = channelRepository .save (channel );
72
+ log .info ("채널 저장 성공, ID: {}" , savedChannel .getId ());
72
73
73
74
request .participantIds ().stream ()
74
75
.map (userId -> ReadStatus .builder ()
@@ -77,22 +78,25 @@ public ChannelDto createPrivateChannel(ChannelPrivateRequest request) {
77
78
log .error ("비공개 채널 생성 단계에서 유저를 찾지 못함: userId={}" , userId );
78
79
return new UserNotFoundException (Map .of ("UserId" , userId ));
79
80
}))
80
- .channel (channelRepository .findById (channel .getId ()).orElseThrow (
81
+ .channel (channelRepository .findById (savedChannel .getId ()).orElseThrow (
81
82
() -> {
82
- log .error ("비공개 채널을 찾지 못함: privateChannelId={}" , channel .getId ());
83
- return new ChannelNotFoundException (Map .of ("channelId" , channel .getId ()));
83
+ log .error ("비공개 채널을 찾지 못함: privateChannelId={}" , savedChannel .getId ());
84
+ return new ChannelNotFoundException (Map .of ("channelId" , savedChannel .getId ()));
84
85
}))
85
- .lastReadAt (channel .getCreatedAt ())
86
+ .lastReadAt (savedChannel .getCreatedAt ())
86
87
.build ()
87
88
)
88
89
.forEach (readStatusRepository ::save );
89
90
90
91
log .info ("비공개 채널 생성 성공" );
91
- return channelMapper .toDto (channel );
92
+ return channelMapper .toDto (savedChannel );
92
93
}
93
94
94
95
@ Override
95
96
public List <ChannelDto > findAllByUserId (UUID userId ) {
97
+ userRepository .findById (userId ).orElseThrow (() -> {
98
+ return new UserNotFoundException (Map .of ("userId" , userId ));
99
+ });
96
100
List <Channel > channels = readStatusService .findAllReadStatusEntitiesByUserId (userId ).stream ()
97
101
.map (ReadStatus ::getChannel )
98
102
.toList ();
@@ -127,10 +131,14 @@ public ChannelDto updateChannel(UUID id, ChannelUpdateRequest request) {
127
131
throw new ChannelModificationNotAllowedException (Map .of ("privateChannelId" , id ));
128
132
} // 전역 400
129
133
130
- channel .updateName (request .newName ());
131
- channel .updateDescription (request .newDescription ());
132
- // 수정 시간 업데이트
133
- channel .refreshUpdateAt ();
134
+ if (request .newName () != null ) {
135
+ channel .updateName (request .newName ());
136
+ channel .refreshUpdateAt ();
137
+ }
138
+ if (request .newDescription () != null ) {
139
+ channel .updateDescription (request .newDescription ());
140
+ channel .refreshUpdateAt ();
141
+ }
134
142
135
143
log .info ("채널 수정 시도 성공: channelName={}, updatedAt={}" ,
136
144
channel .getName (),
0 commit comments