Открыть боковую панель
effective-dev-opensource
Effective-Office
Коммиты
50e4db41
Коммит
50e4db41
создал
Июн 18, 2025
по автору
Radch-enko
Просмотр файлов
Feature: Booking: implement get all bookings from all workplaces
владелец
c07acb2b
Изменения
10
Скрыть пробелы
Построчно
Рядом
backend/core/domain/src/main/kotlin/band/effective/office/backend/core/domain/model/Utility.kt
Просмотр файла @
50e4db41
...
@@ -11,8 +11,8 @@ import java.util.*
...
@@ -11,8 +11,8 @@ import java.util.*
* @property count The quantity of this utility
* @property count The quantity of this utility
*/
*/
data class
Utility
(
data class
Utility
(
va
r
id
:
UUID
,
va
l
id
:
UUID
,
va
r
name
:
String
,
va
l
name
:
String
,
va
r
iconUrl
:
String
,
va
l
iconUrl
:
String
,
va
r
count
:
Int
va
l
count
:
Int
)
)
\ No newline at end of file
backend/core/domain/src/main/kotlin/band/effective/office/backend/core/domain/model/Workspace.kt
Просмотр файла @
50e4db41
...
@@ -12,9 +12,9 @@ import java.util.UUID
...
@@ -12,9 +12,9 @@ import java.util.UUID
* @property zone The zone where the workspace is located
* @property zone The zone where the workspace is located
*/
*/
data class
Workspace
(
data class
Workspace
(
va
r
id
:
UUID
,
va
l
id
:
UUID
,
va
r
name
:
String
,
va
l
name
:
String
,
va
r
tag
:
String
,
va
l
tag
:
String
,
va
r
utilities
:
List
<
Utility
>,
va
l
utilities
:
List
<
Utility
>,
va
r
zone
:
WorkspaceZone
?
=
null
va
l
zone
:
WorkspaceZone
?
=
null
)
)
\ No newline at end of file
backend/core/domain/src/main/kotlin/band/effective/office/backend/core/domain/model/WorkspaceZone.kt
Просмотр файла @
50e4db41
...
@@ -9,6 +9,6 @@ import java.util.*
...
@@ -9,6 +9,6 @@ import java.util.*
* @property name The name of the workspace zone
* @property name The name of the workspace zone
*/
*/
data class
WorkspaceZone
(
data class
WorkspaceZone
(
va
r
id
:
UUID
,
va
l
id
:
UUID
,
va
r
name
:
String
va
l
name
:
String
)
)
\ No newline at end of file
backend/feature/booking/calendar/dummy/src/main/kotlin/band/effective/office/backend/feature/booking/calendar/dummy/DummyCalendarProvider.kt
Просмотр файла @
50e4db41
...
@@ -101,4 +101,17 @@ class DummyCalendarProvider : CalendarProvider {
...
@@ -101,4 +101,17 @@ class DummyCalendarProvider : CalendarProvider {
// For simplicity in this dummy implementation, we'll just search all bookings
// For simplicity in this dummy implementation, we'll just search all bookings
return
bookings
.
values
.
find
{
it
.
id
==
id
}
return
bookings
.
values
.
find
{
it
.
id
==
id
}
}
}
override
fun
findAllEvents
(
from
:
Instant
,
to
:
Instant
?):
List
<
Booking
>
{
logger
.
debug
(
"Finding all dummy events from {} to {}"
,
from
,
to
?:
"infinity"
)
return
bookings
.
values
.
filter
{
booking
->
booking
.
beginBooking
>=
from
&&
(
to
==
null
||
booking
.
endBooking
<=
to
)
}
}
}
}
backend/feature/booking/calendar/google/src/main/kotlin/band/effective/office/backend/feature/booking/calendar/google/GoogleCalendarConfig.kt
Просмотр файла @
50e4db41
...
@@ -33,7 +33,7 @@ class GoogleCalendarConfig(
...
@@ -33,7 +33,7 @@ class GoogleCalendarConfig(
@Value
(
"\${calendar.credentials.file}"
)
@Value
(
"\${calendar.credentials.file}"
)
private
lateinit
var
credentialsFile
:
String
private
lateinit
var
credentialsFile
:
String
private
val
JSON_FACTORY
:
JsonFactory
=
GsonFactory
.
getDefaultInstance
()
private
val
jsonFactory
:
JsonFactory
=
GsonFactory
.
getDefaultInstance
()
/**
/**
* Creates a Google Calendar API client with OAuth2 credentials.
* Creates a Google Calendar API client with OAuth2 credentials.
...
@@ -58,7 +58,7 @@ class GoogleCalendarConfig(
...
@@ -58,7 +58,7 @@ class GoogleCalendarConfig(
@Bean
@Bean
fun
calendar
(
httpTransport
:
HttpTransport
,
googleCredentials
:
GoogleCredentials
):
Calendar
{
fun
calendar
(
httpTransport
:
HttpTransport
,
googleCredentials
:
GoogleCredentials
):
Calendar
{
return
Calendar
.
Builder
(
httpTransport
,
JSON_FACTORY
,
HttpCredentialsAdapter
(
googleCredentials
))
return
Calendar
.
Builder
(
httpTransport
,
jsonFactory
,
HttpCredentialsAdapter
(
googleCredentials
))
.
setApplicationName
(
applicationName
)
.
setApplicationName
(
applicationName
)
.
build
()
.
build
()
}
}
...
...
backend/feature/booking/calendar/google/src/main/kotlin/band/effective/office/backend/feature/booking/calendar/google/GoogleCalendarProvider.kt
Просмотр файла @
50e4db41
...
@@ -177,6 +177,31 @@ class GoogleCalendarProvider(
...
@@ -177,6 +177,31 @@ class GoogleCalendarProvider(
return
null
return
null
}
}
override
fun
findAllEvents
(
from
:
Instant
,
to
:
Instant
?):
List
<
Booking
>
{
logger
.
debug
(
"Finding all events from {} to {}"
,
from
,
to
?:
"infinity"
)
// Get all calendar IDs
val
calendarIds
=
calendarIdProvider
.
getAllCalendarIds
()
// Query all calendars for events within the time range
val
bookings
=
mutableListOf
<
Booking
>()
for
(
calendarId
in
calendarIds
)
{
try
{
val
events
=
listEvents
(
calendarId
,
from
,
to
)
logger
.
debug
(
"findAllEvents -> events: {}"
,
events
.
map
{
it
.
id
.
toString
()
})
bookings
.
addAll
(
events
.
map
{
convertToBooking
(
it
,
calendarId
)
})
}
catch
(
e
:
Exception
)
{
logger
.
warn
(
"Failed to search for events in calendar {}: {}"
,
calendarId
,
e
.
message
)
}
}
return
bookings
}
// Helper methods
// Helper methods
private
fun
getCalendarIdByWorkspace
(
workspaceId
:
UUID
):
String
{
private
fun
getCalendarIdByWorkspace
(
workspaceId
:
UUID
):
String
{
...
...
backend/feature/booking/calendar/google/src/main/kotlin/band/effective/office/backend/feature/booking/calendar/google/WorkspaceCalendarIdProvider.kt
Просмотр файла @
50e4db41
...
@@ -83,6 +83,6 @@ class WorkspaceCalendarIdProvider(
...
@@ -83,6 +83,6 @@ class WorkspaceCalendarIdProvider(
}
}
}
}
return
calendarIds
.
values
.
toList
()
+
defaultCalendar
return
calendarIds
.
values
.
toList
()
}
}
}
}
backend/feature/booking/core/src/main/kotlin/band/effective/office/backend/feature/booking/core/controller/BookingController.kt
Просмотр файла @
50e4db41
...
@@ -118,9 +118,7 @@ class BookingController(
...
@@ -118,9 +118,7 @@ class BookingController(
}
}
else
->
{
else
->
{
// TODO In a real implementation, we would need a method to get all bookings
bookingService
.
getAllBookings
(
from
,
to
)
// For now, we'll return an empty list
emptyList
()
}
}
}
}
...
...
backend/feature/booking/core/src/main/kotlin/band/effective/office/backend/feature/booking/core/domain/CalendarProvider.kt
Просмотр файла @
50e4db41
...
@@ -59,4 +59,13 @@ interface CalendarProvider {
...
@@ -59,4 +59,13 @@ interface CalendarProvider {
* @return The booking if found, null otherwise
* @return The booking if found, null otherwise
*/
*/
fun
findEventById
(
id
:
UUID
):
Booking
?
fun
findEventById
(
id
:
UUID
):
Booking
?
}
\ No newline at end of file
/**
* Finds all events across all workspaces within a time range.
*
* @param from The start of the time range
* @param to The end of the time range (optional)
* @return A list of all bookings within the time range
*/
fun
findAllEvents
(
from
:
Instant
,
to
:
Instant
?
=
null
):
List
<
Booking
>
}
backend/feature/booking/core/src/main/kotlin/band/effective/office/backend/feature/booking/core/service/BookingService.kt
Просмотр файла @
50e4db41
...
@@ -108,4 +108,15 @@ class BookingService(
...
@@ -108,4 +108,15 @@ class BookingService(
return
calendarProvider
.
findEventsByUser
(
userId
,
from
,
to
)
return
calendarProvider
.
findEventsByUser
(
userId
,
from
,
to
)
.
filter
{
it
.
workspace
.
id
==
workspaceId
}
.
filter
{
it
.
workspace
.
id
==
workspaceId
}
}
}
/**
* Gets all bookings within a time range.
*
* @param from The start of the time range
* @param to The end of the time range (optional)
* @return A list of all bookings within the time range
*/
fun
getAllBookings
(
from
:
Instant
,
to
:
Instant
?
=
null
):
List
<
Booking
>
{
return
calendarProvider
.
findAllEvents
(
from
,
to
)
}
}
}
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать