This commit is contained in:
2025-08-14 15:33:38 +03:00
parent a71279d450
commit ecf614e4c2
4 changed files with 46 additions and 20 deletions

View File

@@ -0,0 +1,4 @@
package com.homebox.lens.domain.model
class LabelCreate {
}

View File

@@ -0,0 +1,38 @@
// [PACKAGE] com.homebox.lens.domain.usecase
// [FILE] CreateLabelUseCase.kt
// [SEMANTICS] business_logic, use_case, label, create
package com.homebox.lens.domain.usecase
// [IMPORTS]
import com.homebox.lens.domain.model.LabelCreate
import com.homebox.lens.domain.model.LabelSummary
import com.homebox.lens.domain.repository.ItemRepository
import javax.inject.Inject
// [USE_CASE]
/**
* [CONTRACT]
* @summary Сценарий использования для создания новой метки.
* @param repository Репозиторий для доступа к данным.
*/
class CreateLabelUseCase @Inject constructor(
private val repository: ItemRepository
) {
/**
* [CONTRACT]
* @summary Выполняет создание метки.
* @param newLabelData Данные для создания новой метки.
* @return Возвращает краткую информацию о созданной метке [LabelSummary].
* @throws Exception в случае ошибки на уровне репозитория (сеть, API).
* @precondition `newLabelData.name` не должен быть пустым.
*/
// [ENTRYPOINT]
suspend operator fun invoke(newLabelData: LabelCreate): LabelSummary {
// [PRECONDITION]
require(newLabelData.name.isNotBlank()) { "[CONTRACT_VIOLATION] Label name cannot be blank." }
// [ACTION]
return repository.createLabel(newLabelData)
}
}
// [END_FILE_CreateLabelUseCase.kt]