Не подтверждена Коммит 960d50d8 создал по автору Stanislav Radchenko's avatar Stanislav Radchenko Зафиксировано автором GitHub
Просмотр файлов

Feature/workspace utility count (#341)



* feat: Add utility count support for workspaces

* docs: Update Workspace Module README

* `feat: add support for .env in dev Docker Compose and update database migration for workspace utilities`

---------

Co-authored-by: default avatarKrugarValdes <sm.vit2003@gmail.com>
Co-authored-by: default avatarRadch-enko <stanislav.radchenko@effective.band>
владелец d347e4bb
-- Add count column to workspace_utilities table
ALTER TABLE workspace_utilities
ADD COLUMN count INTEGER NOT NULL DEFAULT 1;
-- Add comment to count column
COMMENT ON COLUMN workspace_utilities.count IS 'Number of this utility in the workspace';
\ Нет новой строки в конце файла
......@@ -45,7 +45,7 @@ The module exposes the following REST endpoints:
Represents a physical workspace in the office:
- ID
- Name
- Utilities (equipment and amenities)
- Utilities (equipment and amenities, with count from `workspace_utilities`)
- Zone (location within the office)
- Tag (type of workspace, e.g., "meeting", "desk")
......@@ -61,6 +61,12 @@ Represents equipment or amenities available in a workspace:
- Icon URL
- Count
### WorkspaceUtility
Links workspaces to utilities with quantity:
- Workspace ID
- Utility ID
- Count (number of utility items)
## Integration
The Workspace module integrates with:
- Booking module for checking workspace availability
......
package band.effective.office.backend.feature.workspace.core.repository.entity
import jakarta.persistence.Column
import jakarta.persistence.OneToMany
import jakarta.persistence.Entity
import jakarta.persistence.Id
import jakarta.persistence.Table
......@@ -15,4 +16,7 @@ data class UtilityEntity(
val name: String,
@Column(name = "icon_url", nullable = false, unique = true, length = 255)
val iconUrl: String,
@OneToMany(mappedBy = "utility")
val workspaceUtilities: List<WorkspaceUtilityEntity> = emptyList()
)
......@@ -4,8 +4,7 @@ import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Id
import jakarta.persistence.JoinColumn
import jakarta.persistence.JoinTable
import jakarta.persistence.ManyToMany
import jakarta.persistence.OneToMany
import jakarta.persistence.ManyToOne
import jakarta.persistence.Table
import java.util.UUID
......@@ -19,13 +18,8 @@ data class WorkspaceEntity(
val name: String,
@Column(name = "tag", nullable = false, unique = false, length = 255)
val tag: String,
@ManyToMany
@JoinTable(
name = "workspace_utilities",
joinColumns = [JoinColumn(name = "workspace_id")],
inverseJoinColumns = [JoinColumn(name = "utility_id")]
)
val utilities: List<UtilityEntity> = emptyList(),
@OneToMany(mappedBy = "workspace")
val workspaceUtilities: List<WorkspaceUtilityEntity> = emptyList(),
@ManyToOne
@JoinColumn(name = "zone_id")
......
package band.effective.office.backend.feature.workspace.core.repository.entity
import jakarta.persistence.*
@Entity
@Table(name = "workspace_utilities")
data class WorkspaceUtilityEntity(
@Id
@ManyToOne
@JoinColumn(name = "workspace_id")
val workspace: WorkspaceEntity,
@Id
@ManyToOne
@JoinColumn(name = "utility_id")
val utility: UtilityEntity,
@Column(name = "count", nullable = false)
val count: Int
)
\ Нет новой строки в конце файла
......@@ -3,25 +3,25 @@ package band.effective.office.backend.feature.workspace.core.repository.mapper
import band.effective.office.backend.core.domain.model.Utility
import band.effective.office.backend.core.domain.model.Workspace
import band.effective.office.backend.core.domain.model.WorkspaceZone
import band.effective.office.backend.feature.workspace.core.repository.entity.UtilityEntity
import band.effective.office.backend.feature.workspace.core.repository.entity.WorkspaceEntity
import band.effective.office.backend.feature.workspace.core.repository.entity.WorkspaceUtilityEntity
import org.springframework.stereotype.Component
@Component
object WokplaceMapper {
object WorkspaceMapper {
fun toDomain(entity: WorkspaceEntity): Workspace = Workspace(
id = entity.id,
name = entity.name,
tag = entity.tag,
utilities = entity.utilities.map(WokplaceMapper::toDomain),
utilities = entity.workspaceUtilities.map { toDomain(it) },
zone = entity.zone?.let { WorkspaceZone(it.id, it.name) },
)
private fun toDomain(entity: UtilityEntity): Utility = Utility(
id = entity.id,
name = entity.name,
iconUrl = entity.iconUrl,
count = 0, // TODO
private fun toDomain(entity: WorkspaceUtilityEntity): Utility = Utility(
id = entity.utility.id,
name = entity.utility.name,
iconUrl = entity.utility.iconUrl,
count = entity.count
)
}
\ Нет новой строки в конце файла
......@@ -7,7 +7,7 @@ import band.effective.office.backend.core.domain.service.WorkspaceDomainService
import band.effective.office.backend.feature.workspace.core.repository.CalendarIdRepository
import band.effective.office.backend.feature.workspace.core.repository.WorkspaceRepository
import band.effective.office.backend.feature.workspace.core.repository.mapper.CalendarIdMapper
import band.effective.office.backend.feature.workspace.core.repository.mapper.WokplaceMapper
import band.effective.office.backend.feature.workspace.core.repository.mapper.WorkspaceMapper
import java.util.UUID
import kotlin.jvm.optionals.getOrNull
import org.springframework.stereotype.Service
......@@ -27,7 +27,7 @@ class WorkspaceService(
*/
@Transactional(readOnly = true)
override fun findById(id: UUID): Workspace? {
return repository.findById(id).getOrNull()?.let { WokplaceMapper.toDomain(it) }
return repository.findById(id).getOrNull()?.let { WorkspaceMapper.toDomain(it) }
}
/**
......@@ -38,7 +38,7 @@ class WorkspaceService(
*/
@Transactional(readOnly = true)
override fun findAllByTag(tag: String): List<Workspace> {
return repository.findAllByTag(tag).map { WokplaceMapper.toDomain(it) }
return repository.findAllByTag(tag).map { WorkspaceMapper.toDomain(it) }
}
/**
......
......@@ -3,7 +3,13 @@ POSTGRES_USER=youruser
POSTGRES_PASSWORD=youruser
SPRING_DATASOURCE_URL=yourpathtodatabase
# Application Configuration
MIGRATIONS_ENABLE=true
LOG_LEVEL=DEBUG
CALENDAR_APPLICATION_NAME=yourcalendarapplicationname
DEFAULT_CALENDAR=yourdefaultcalendar
TEST_CALENDARS=your calendars
TEST_APPLICATION_URL=your test application url
LABEL=your domain label
\ Нет новой строки в конце файла
LABEL=yourdevdomain
\ Нет новой строки в конце файла
......@@ -7,6 +7,8 @@ services:
build:
context: .
dockerfile: Dockerfile
env_file:
- .env
container_name: effective-office-app-dev
expose:
- "8080"
......
......@@ -3,7 +3,13 @@ POSTGRES_USER=youruser
POSTGRES_PASSWORD=youruser
SPRING_DATASOURCE_URL=yourpathtodatabase
CALENDARS=your calendars
APPLICATION_URL=your application url
# Application Configuration
MIGRATIONS_ENABLE=true
LOG_LEVEL=DEBUG
LABEL=your domain label
\ Нет новой строки в конце файла
CALENDAR_APPLICATION_NAME=yourcalendarapplicationname
DEFAULT_CALENDAR=yourdefaultcalendar
TEST_CALENDARS=your calendars
TEST_APPLICATION_URL=your test application url
LABEL=yourdevdomain
\ Нет новой строки в конце файла
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать