@@ -19,23 +19,19 @@ class RoomExceptionServiceHandler < Bannote::Studyroomservice::Roomexception::V1
1919 def create_room_exception ( request , _call )
2020 authorize! ( "assistant" )
2121
22+ # 존재하는 Room인지 확인
2223 raise GRPC ::BadStatus . new (
2324 GRPC ::Core ::StatusCodes ::NOT_FOUND ,
2425 "Room with ID #{ request . room_id } not found."
2526 ) unless ::Room . exists? ( request . room_id )
2627
27- # ✅ Timestamp → Ruby Time 변환 (문자열인 경우도 안전하게 처리)
28- exception_time = if request . exception_date . respond_to? ( :seconds )
29- Time . at ( request . exception_date . seconds )
30- else
31- Time . parse ( request . exception_date . to_s ) rescue nil
32- end
33-
3428 new_exception = ::RoomException . create! (
3529 room_id : request . room_id ,
36- exception_date : exception_time ,
37- is_closed : request . is_closed ,
38- reason : request . reason
30+ exception_date : request . exception_date , # 문자열 (YYYY-MM-DD)
31+ reason : request . reason ,
32+ opening_time : request . opening_time . presence ,
33+ closing_time : request . closing_time . presence ,
34+ created_by : request . created_by
3935 )
4036
4137 Bannote ::Studyroomservice ::Roomexception ::V1 ::CreateRoomExceptionResponse . new (
@@ -46,7 +42,7 @@ def create_room_exception(request, _call)
4642 rescue ArgumentError
4743 raise GRPC ::BadStatus . new (
4844 GRPC ::Core ::StatusCodes ::INVALID_ARGUMENT ,
49- "Invalid date format for exception_date."
45+ "Invalid format for exception_date (expected YYYY-MM-DD) ."
5046 )
5147 end
5248
@@ -85,11 +81,13 @@ def update_room_exception(request, _call)
8581 authorize! ( "assistant" )
8682
8783 exception = ::RoomException . find ( request . id )
84+
8885 exception . update! (
8986 room_id : request . room_id ,
90- exception_date : Time . at ( request . exception_date . seconds ) ,
91- is_closed : request . is_closed ,
92- reason : request . reason
87+ exception_date : request . exception_date ,
88+ reason : request . reason ,
89+ opening_time : request . opening_time . presence ,
90+ closing_time : request . closing_time . presence
9391 )
9492
9593 Bannote ::Studyroomservice ::Roomexception ::V1 ::UpdateRoomExceptionResponse . new (
@@ -138,9 +136,11 @@ def room_exception_to_proto(exception)
138136 Bannote ::Studyroomservice ::Roomexception ::V1 ::RoomException . new (
139137 id : exception . id ,
140138 room_id : exception . room_id ,
141- exception_date : Google ::Protobuf ::Timestamp . new ( seconds : exception . exception_date . to_i ) ,
142- is_closed : exception . is_closed ,
139+ exception_date : exception . exception_date . to_s , # 문자열 그대로 반환
143140 reason : exception . reason ,
141+ opening_time : exception . opening_time &.strftime ( "%H:%M" ) ,
142+ closing_time : exception . closing_time &.strftime ( "%H:%M" ) ,
143+ created_by : exception . created_by ,
144144 created_at : Google ::Protobuf ::Timestamp . new ( seconds : exception . created_at . to_i ) ,
145145 updated_at : Google ::Protobuf ::Timestamp . new ( seconds : exception . updated_at . to_i )
146146 )
0 commit comments