This commit is contained in:
2025-09-26 10:30:59 +03:00
parent aa69776807
commit 394e0040de
82 changed files with 5324 additions and 1998 deletions

View File

@@ -4,7 +4,6 @@
package com.homebox.lens.domain.model
// [IMPORTS]
import java.math.BigDecimal
// [END_IMPORTS]
// [ENTITY: DataClass('Item')]
@@ -29,8 +28,27 @@ data class Item(
val image: String?,
val location: Location?,
val labels: List<Label>,
val value: BigDecimal?,
val createdAt: String?
val value: Double?,
val createdAt: String?,
val assetId: String?,
val notes: String?,
val serialNumber: String?,
val purchasePrice: Double?,
val purchaseDate: String?,
val warrantyUntil: String?,
val parentId: String?,
val isArchived: Boolean?,
val insured: Boolean?,
val lifetimeWarranty: Boolean?,
val manufacturer: String?,
val modelNumber: String?,
val purchaseFrom: String?,
val soldNotes: String?,
val soldPrice: Double?,
val soldTime: String?,
val soldTo: String?,
val syncChildItemsLocations: Boolean?,
val warrantyDetails: String?
)
// [END_ENTITY: DataClass('Item')]

View File

@@ -51,7 +51,18 @@ data class ItemOut(
val fields: List<CustomField>,
val maintenance: List<MaintenanceEntry>,
val createdAt: String,
val updatedAt: String
val updatedAt: String,
val insured: Boolean?,
val lifetimeWarranty: Boolean?,
val manufacturer: String?,
val modelNumber: String?,
val purchaseFrom: String?,
val soldNotes: String?,
val soldPrice: Double?,
val soldTime: String?,
val soldTo: String?,
val syncChildItemsLocations: Boolean?,
val warrantyDetails: String?
)
// [END_ENTITY: DataClass('ItemOut')]
// [END_FILE_ItemOut.kt]

View File

@@ -1,6 +1,7 @@
// [PACKAGE] com.homebox.lens.domain.usecase
// [FILE] DeleteLabelUseCase.kt
// [SEMANTICS] business_logic, use_case, label, delete
package com.homebox.lens.domain.usecase
// [IMPORTS]
@@ -9,19 +10,22 @@ import javax.inject.Inject
// [END_IMPORTS]
// [ENTITY: UseCase('DeleteLabelUseCase')]
// [RELATION: UseCase('DeleteLabelUseCase')] -> [DEPENDS_ON] -> [Interface('ItemRepository')]
// [RELATION: UseCase('DeleteLabelUseCase')] -> [DEPENDS_ON] -> [Repository('ItemRepository')]
/**
* @summary Сценарий использования для удаления метки.
* @param repository Репозиторий для доступа к данным.
* @description Выполняет удаление метки по её ID через репозиторий.
* @throws Exception в случае ошибки сети или API.
* @sideeffect Удаляет метку из репозитория (API и локальной БД).
*/
class DeleteLabelUseCase @Inject constructor(
private val repository: ItemRepository
) {
// [ENTITY: Function('invoke')]
// [RELATION: Function('invoke')] -> [RETURNS] -> [DataStructure('Unit')]
/**
* @summary Выполняет удаление метки.
* @summary Удаляет метку по её ID.
* @param labelId ID метки для удаления.
* @throws Exception в случае ошибки на уровне репозитория (сеть, API).
* @throws Exception в случае ошибки.
*/
suspend operator fun invoke(labelId: String) {
repository.deleteLabel(labelId)

View File

@@ -22,7 +22,6 @@ import io.kotest.matchers.shouldBe
import io.kotest.assertions.throwables.shouldThrow
import io.mockk.coEvery
import io.mockk.mockk
import java.math.BigDecimal
// [END_IMPORTS]
// [ENTITY: Class('UpdateItemUseCaseTest')]
@@ -49,8 +48,27 @@ class UpdateItemUseCaseTest : FunSpec({
image = null,
location = Location(id = "loc1", name = "Location 1"),
labels = listOf(Label(id = "lab1", name = "Label 1")),
value = BigDecimal.ZERO,
createdAt = "2025-01-01T00:00:00Z"
value = 0.0,
createdAt = "2025-01-01T00:00:00Z",
assetId = null,
notes = null,
serialNumber = null,
purchasePrice = null,
purchaseDate = null,
warrantyUntil = null,
parentId = null,
isArchived = null,
insured = null,
lifetimeWarranty = null,
manufacturer = null,
modelNumber = null,
purchaseFrom = null,
soldNotes = null,
soldPrice = null,
soldTime = null,
soldTo = null,
syncChildItemsLocations = null,
warrantyDetails = null
)
val expectedItemOut = ItemOut(
id = "1",
@@ -68,7 +86,7 @@ class UpdateItemUseCaseTest : FunSpec({
location = LocationOut(
id = "loc1",
name = "Location 1",
color = "#FFFFFF", // Default color
color = "#FFFFFF",
isArchived = false,
createdAt = "2025-01-01T00:00:00Z",
updatedAt = "2025-01-01T00:00:00Z"
@@ -78,7 +96,7 @@ class UpdateItemUseCaseTest : FunSpec({
labels = listOf(LabelOut(
id = "lab1",
name = "Label 1",
color = "#FFFFFF", // Default color
color = "#FFFFFF",
isArchived = false,
createdAt = "2025-01-01T00:00:00Z",
updatedAt = "2025-01-01T00:00:00Z"
@@ -88,7 +106,18 @@ class UpdateItemUseCaseTest : FunSpec({
fields = emptyList(),
maintenance = emptyList(),
createdAt = "2025-01-01T00:00:00Z",
updatedAt = "2025-01-01T00:00:00Z"
updatedAt = "2025-01-01T00:00:00Z",
insured = null,
lifetimeWarranty = null,
manufacturer = null,
modelNumber = null,
purchaseFrom = null,
soldNotes = null,
soldPrice = null,
soldTime = null,
soldTo = null,
syncChildItemsLocations = null,
warrantyDetails = null
)
coEvery { itemRepository.updateItem(any(), any()) } returns expectedItemOut
@@ -115,8 +144,27 @@ class UpdateItemUseCaseTest : FunSpec({
image = null,
location = Location(id = "loc1", name = "Location 1"),
labels = listOf(Label(id = "lab1", name = "Label 1")),
value = BigDecimal.ZERO,
createdAt = "2025-01-01T00:00:00Z"
value = 0.0,
createdAt = "2025-01-01T00:00:00Z",
assetId = null,
notes = null,
serialNumber = null,
purchasePrice = null,
purchaseDate = null,
warrantyUntil = null,
parentId = null,
isArchived = null,
insured = null,
lifetimeWarranty = null,
manufacturer = null,
modelNumber = null,
purchaseFrom = null,
soldNotes = null,
soldPrice = null,
soldTime = null,
soldTo = null,
syncChildItemsLocations = null,
warrantyDetails = null
)
// When & Then