211
This commit is contained in:
@@ -37,7 +37,18 @@ data class ItemOutDto(
|
||||
@Json(name = "fields") val fields: List<CustomFieldDto>,
|
||||
@Json(name = "maintenance") val maintenance: List<MaintenanceEntryDto>,
|
||||
@Json(name = "createdAt") val createdAt: String,
|
||||
@Json(name = "updatedAt") val updatedAt: String
|
||||
@Json(name = "updatedAt") val updatedAt: String,
|
||||
@Json(name = "insured") val insured: Boolean?,
|
||||
@Json(name = "lifetimeWarranty") val lifetimeWarranty: Boolean?,
|
||||
@Json(name = "manufacturer") val manufacturer: String?,
|
||||
@Json(name = "modelNumber") val modelNumber: String?,
|
||||
@Json(name = "purchaseFrom") val purchaseFrom: String?,
|
||||
@Json(name = "soldNotes") val soldNotes: String?,
|
||||
@Json(name = "soldPrice") val soldPrice: Double?,
|
||||
@Json(name = "soldTime") val soldTime: String?,
|
||||
@Json(name = "soldTo") val soldTo: String?,
|
||||
@Json(name = "syncChildItemsLocations") val syncChildItemsLocations: Boolean?,
|
||||
@Json(name = "warrantyDetails") val warrantyDetails: String?
|
||||
)
|
||||
// [END_ENTITY: DataClass('ItemOutDto')]
|
||||
|
||||
@@ -69,7 +80,18 @@ fun ItemOutDto.toDomain(): ItemOut {
|
||||
fields = this.fields.map { it.toDomain() },
|
||||
maintenance = this.maintenance.map { it.toDomain() },
|
||||
createdAt = this.createdAt,
|
||||
updatedAt = this.updatedAt
|
||||
updatedAt = this.updatedAt,
|
||||
insured = this.insured,
|
||||
lifetimeWarranty = this.lifetimeWarranty,
|
||||
manufacturer = this.manufacturer,
|
||||
modelNumber = this.modelNumber,
|
||||
purchaseFrom = this.purchaseFrom,
|
||||
soldNotes = this.soldNotes,
|
||||
soldPrice = this.soldPrice,
|
||||
soldTime = this.soldTime,
|
||||
soldTo = this.soldTo,
|
||||
syncChildItemsLocations = this.syncChildItemsLocations,
|
||||
warrantyDetails = this.warrantyDetails
|
||||
)
|
||||
}
|
||||
// [END_ENTITY: Function('toDomain')]
|
||||
@@ -27,6 +27,15 @@ interface LabelDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertLabels(labels: List<LabelEntity>)
|
||||
// [END_ENTITY: Function('insertLabels')]
|
||||
|
||||
// [ENTITY: Function('deleteLabelById')]
|
||||
/**
|
||||
* @summary Удаляет метку по её ID из локальной БД.
|
||||
* @param labelId ID метки для удаления.
|
||||
*/
|
||||
@Query("DELETE FROM labels WHERE id = :labelId")
|
||||
suspend fun deleteLabelById(labelId: String)
|
||||
// [END_ENTITY: Function('deleteLabelById')]
|
||||
}
|
||||
// [END_ENTITY: Interface('LabelDao')]
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.homebox.lens.data.api.dto.LocationUpdateDto
|
||||
import com.homebox.lens.data.api.dto.LabelUpdateDto
|
||||
import com.homebox.lens.data.api.dto.LocationOutDto
|
||||
import com.homebox.lens.data.db.dao.ItemDao
|
||||
import com.homebox.lens.data.db.dao.LabelDao
|
||||
import com.homebox.lens.data.db.entity.toDomain
|
||||
import com.homebox.lens.domain.model.*
|
||||
import com.homebox.lens.domain.repository.ItemRepository
|
||||
@@ -29,7 +30,8 @@ import javax.inject.Singleton
|
||||
@Singleton
|
||||
class ItemRepositoryImpl @Inject constructor(
|
||||
private val apiService: HomeboxApiService,
|
||||
private val itemDao: ItemDao
|
||||
private val itemDao: ItemDao,
|
||||
private val labelDao: LabelDao
|
||||
) : ItemRepository {
|
||||
|
||||
// [ENTITY: Function('createItem')]
|
||||
@@ -121,6 +123,7 @@ class ItemRepositoryImpl @Inject constructor(
|
||||
|
||||
override suspend fun deleteLabel(labelId: String) {
|
||||
apiService.deleteLabel(labelId)
|
||||
labelDao.deleteLabelById(labelId)
|
||||
}
|
||||
|
||||
override suspend fun createLocation(newLocationData: LocationCreate): LocationOut {
|
||||
|
||||
Reference in New Issue
Block a user