@@ -218,6 +218,47 @@ func UpdateAccommodationById(c *gin.Context) {
218218 pkg .Log .SuccessCtx (c )
219219}
220220
221+ func DeleteAccommodationById (c * gin.Context ) {
222+ accIdStr := c .Param ("accId" )
223+ accId , ok := pkg .GrabUuid (c , accIdStr , "DELETE-ACCOMMODATION" , "Accommodation" )
224+ if ! ok {
225+ return
226+ }
227+
228+ ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
229+ defer cancel ()
230+
231+ conn , err := cmd .DBPool .Acquire (ctx )
232+ if pkg .HandleDbAcquireErr (c , err , "DELETE-ACCOMMODATION" ) {
233+ return
234+ }
235+ defer conn .Release ()
236+
237+ q := db .New ()
238+
239+ row , err := q .DeleteAccommodationByIdQuery (ctx , conn , accId )
240+ if err != nil {
241+ c .JSON (http .StatusInternalServerError , gin.H {
242+ "message" : "Oops! Something happened. Please try again later." ,
243+ })
244+ pkg .Log .ErrorCtx (c , "[DELETE-ACCOMMODATION-ERROR]: Failed to delete accommodation request" , err )
245+ return
246+ }
247+ if row == 0 {
248+ c .JSON (http .StatusNotFound , gin.H {
249+ "message" : "Accommodation request not found" ,
250+ })
251+ pkg .Log .WarnCtx (c , "[DELETE-ACCOMMODATION-WARN]: Accommodation ID does not exist" )
252+ return
253+ }
254+
255+ c .JSON (http .StatusOK , gin.H {
256+ "message" : "Accommodation request deleted successfully" ,
257+ })
258+ pkg .Log .SuccessCtx (c )
259+
260+ }
261+
221262func GateCheckIn (c * gin.Context ) {
222263 personellIdStr , ok := pkg .GrabUserId (c , "GATE" )
223264 if ! ok {
0 commit comments