From 529af56d53418c7db488100dd594b1f296f01efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=88=D0=B8=D0=BD=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC?= Date: Tue, 26 Dec 2023 15:41:35 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D1=83=D1=85,=20=D0=BD=D1=83=20=D0=B2?= =?UTF-8?q?=D1=80=D0=BE=D0=B4=D0=B5=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B2=D1=81=D0=B5=20=D0=BF=D0=B5=D1=80=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D0=B5,=20=D1=87=D1=82=D0=BE=20=D1=85=D0=BE?= =?UTF-8?q?=D1=82=D0=B5=D0=BB.=20=D0=9E=D1=81=D1=82=D0=B0=D0=BB=D0=BE?= =?UTF-8?q?=D1=81=D1=8C=20=D0=BC=D0=B1=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20"=D0=BD=D0=B0=D0=B7=D0=BD=D0=B0=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B0=D0=B4=D0=BC=D0=B8=D0=BD=D0=B0",=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D0=B2=20?= =?UTF-8?q?=D0=BE=D1=82=D1=87=D0=B5=D1=82=20"=D1=82=D0=B5=D0=BA=D1=83?= =?UTF-8?q?=D1=89=D1=83=D1=8E=20=D0=B4=D0=B0=D1=82=D1=83"=20=20=D0=B8=20?= =?UTF-8?q?=D0=B2=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BC=D0=BE=D0=B6=D0=B5=D1=82=20=D1=8D=D1=82=D0=BE=20+=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D1=82=D1=8C=20=D0=BD?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D0=BC=D0=B8?= =?UTF-8?q?=20=D0=BE=D1=81=D1=82=D0=B0=D1=82=D0=BE=D0=BA,=20=D0=B0=20?= =?UTF-8?q?=D0=BD=D1=83=20=D0=B5=D1=89=D0=B5=20=D0=B8=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=D0=B4=D1=83=D0=BC=D0=B0=D1=82=D1=8C=20=D1=81=20bikeid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/bike/RestBikeRepository.kt | 1 + .../api/item/ItemFromBikeRemote.kt | 3 +++ .../api/item/ItemFromCartRemote.kt | 4 ++-- .../api/item/ItemFromRentRemote.kt | 3 ++- .../myapplication/api/item/ItemRemote.kt | 3 +++ .../api/item/ItemWithBikeRemote.kt | 2 ++ .../api/item/RestItemRepository.kt | 5 ++-- .../api/rent/RestRentRepository.kt | 1 + .../api/rentitem/RestRentItemRepository.kt | 1 + .../myapplication/api/report/ReportRemote.kt | 1 + .../api/user/RestUserRepository.kt | 1 + .../example/myapplication/composeui/Cart.kt | 3 +++ .../entities/composeui/CartViewModel.kt | 1 + .../database/entities/composeui/ItemList.kt | 2 +- .../entities/composeui/ItemListViewModel.kt | 1 + .../database/entities/composeui/RentView.kt | 1 + .../database/entities/composeui/ReportPage.kt | 24 ++++++++++--------- .../entities/composeui/edit/ItemEdit.kt | 15 ++++++++++++ .../composeui/edit/ItemEditViewModel.kt | 3 +++ .../database/entities/dao/BikeDao.kt | 2 +- .../database/entities/dao/RentDao.kt | 2 +- .../database/entities/model/Item.kt | 7 +++++- .../database/entities/model/ItemFromBike.kt | 4 ++++ .../database/entities/model/ItemFromCart.kt | 1 + .../database/entities/model/ItemFromRent.kt | 1 + .../entities/model/RentItemCrossRef.kt | 1 + server/data.json | 9 +++---- server/router.js | 1 + 28 files changed, 79 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/example/myapplication/api/bike/RestBikeRepository.kt b/app/src/main/java/com/example/myapplication/api/bike/RestBikeRepository.kt index 9d2be47..37f7ef8 100644 --- a/app/src/main/java/com/example/myapplication/api/bike/RestBikeRepository.kt +++ b/app/src/main/java/com/example/myapplication/api/bike/RestBikeRepository.kt @@ -55,6 +55,7 @@ class RestBikeRepository( x.dateTime, x.weight, x.radius, + x.colorbike, x.maxCount - service.getRents().flatMap { rent -> rent.items.filter { item -> item.id == x.id } }.sumOf { item -> item.count }, diff --git a/app/src/main/java/com/example/myapplication/api/item/ItemFromBikeRemote.kt b/app/src/main/java/com/example/myapplication/api/item/ItemFromBikeRemote.kt index aeecf97..981adc8 100644 --- a/app/src/main/java/com/example/myapplication/api/item/ItemFromBikeRemote.kt +++ b/app/src/main/java/com/example/myapplication/api/item/ItemFromBikeRemote.kt @@ -12,6 +12,7 @@ class ItemFromBikeRemote( val dateTime: LocalDateTime = LocalDateTime.MIN, val weight: Double = 0.0, val radius: Double = 0.0, + val colorbike: String = "", val maxCount: Int = 0, val availableCount: Int = 0, val bikeId: Int = 0, @@ -22,6 +23,7 @@ fun ItemFromBikeRemote.toItemFromBike(): ItemFromBike = ItemFromBike( dateTime, weight, radius, + colorbike, availableCount, bikeId ) @@ -31,6 +33,7 @@ fun ItemFromBike.toItemFromBikeRemote(): ItemFromBikeRemote = ItemFromBikeRemote dateTime, weight, radius, + colorbike, availableCount, bikeId ) \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/api/item/ItemFromCartRemote.kt b/app/src/main/java/com/example/myapplication/api/item/ItemFromCartRemote.kt index 3927f34..a99b503 100644 --- a/app/src/main/java/com/example/myapplication/api/item/ItemFromCartRemote.kt +++ b/app/src/main/java/com/example/myapplication/api/item/ItemFromCartRemote.kt @@ -13,7 +13,7 @@ class ItemFromCartRemote( var bikeId: Int = 0, ) -fun ItemFromCartRemote.toItemFromCart(bike: BikeRemote, dateTime: LocalDateTime, weight: Double, radius: Double, availableCount: Int): ItemFromCart = +fun ItemFromCartRemote.toItemFromCart(bike: BikeRemote, dateTime: LocalDateTime, weight: Double, radius: Double, colorbike : String, availableCount: Int): ItemFromCart = ItemFromCart( - id, dateTime, weight, radius, availableCount, count, bike.id, bike.toBike() + id, dateTime, weight, radius, colorbike, availableCount, count, bike.id, bike.toBike() ) \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/api/item/ItemFromRentRemote.kt b/app/src/main/java/com/example/myapplication/api/item/ItemFromRentRemote.kt index da0eefb..7d2b33c 100644 --- a/app/src/main/java/com/example/myapplication/api/item/ItemFromRentRemote.kt +++ b/app/src/main/java/com/example/myapplication/api/item/ItemFromRentRemote.kt @@ -13,11 +13,12 @@ class ItemFromRentRemote( @Contextual val dateTime: LocalDateTime = LocalDateTime.MIN, val frozenWeight: Double = 0.0, val radius: Double = 0.0, + val colorbike: String = "", val count: Int = 0, val bikeId: Int = 0, ) fun ItemFromRentRemote.toItemFromRent(bike: BikeRemote): ItemFromRent = ItemFromRent( - id, dateTime, frozenWeight, radius, count, bikeId, bike.toBike() + id, dateTime, frozenWeight, radius,colorbike, count, bikeId, bike.toBike() ) \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/api/item/ItemRemote.kt b/app/src/main/java/com/example/myapplication/api/item/ItemRemote.kt index c5667a1..edbce52 100644 --- a/app/src/main/java/com/example/myapplication/api/item/ItemRemote.kt +++ b/app/src/main/java/com/example/myapplication/api/item/ItemRemote.kt @@ -12,6 +12,7 @@ data class ItemRemote( val dateTime: LocalDateTime, val weight: Double, val radius: Double, + val colorbike: String, val maxCount: Int, val bikeId: Int = 0 ) @@ -21,6 +22,7 @@ fun ItemRemote.toItem(): Item = Item( dateTime, weight, radius, + colorbike, maxCount, bikeId ) @@ -30,6 +32,7 @@ fun Item.toItemRemote(): ItemRemote = ItemRemote( dateTime, weight, radius, + colorbike, maxCount, bikeId ) \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/api/item/ItemWithBikeRemote.kt b/app/src/main/java/com/example/myapplication/api/item/ItemWithBikeRemote.kt index 45450df..155d702 100644 --- a/app/src/main/java/com/example/myapplication/api/item/ItemWithBikeRemote.kt +++ b/app/src/main/java/com/example/myapplication/api/item/ItemWithBikeRemote.kt @@ -13,6 +13,7 @@ data class ItemWithBikeRemote( val dateTime: LocalDateTime, val weight: Double, val radius: Double, + val colorbike: String, val maxCount: Int, val bikeId: Int = 0, val bike: BikeRemote, @@ -23,6 +24,7 @@ fun ItemWithBikeRemote.toItem(): Item = Item( dateTime, weight, radius, + colorbike, maxCount, bikeId ) \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/api/item/RestItemRepository.kt b/app/src/main/java/com/example/myapplication/api/item/RestItemRepository.kt index 1215594..73b8075 100644 --- a/app/src/main/java/com/example/myapplication/api/item/RestItemRepository.kt +++ b/app/src/main/java/com/example/myapplication/api/item/RestItemRepository.kt @@ -114,10 +114,10 @@ class RestItemRepository( // Отображаем данные в виде таблицы val tableStartY = yTitle + 80f - val columnWidths = floatArrayOf(0.5f, 1.5f, 1f, 0.5f, 1.5f, 1f) // Увеличиваем ширину столбцов + val columnWidths = floatArrayOf(0.5f, 1f, 0.6f, 0.5f, 1f, 1f, 1f) // Увеличиваем ширину столбцов val rowHeight = 30f // Увеличиваем высоту строки - drawTableRow(canvas, arrayOf("ID", "Дата проверки", "Вес", "R", "Количество", "ID велосипеда"), columnWidths, tableStartY, paint) + drawTableRow(canvas, arrayOf("ID", "Дата", "Вес", "R", "Цвет", "Кол-во", "ID велосипеда"), columnWidths, tableStartY, paint) for ((index, report) in reportData.withIndex()) { val row = arrayOf( @@ -125,6 +125,7 @@ class RestItemRepository( report.dateTime.toString(), report.weight.toString(), report.radius.toString(), + report.colorbike.toString(), report.maxCount.toString(), report.bikeId.toString() ) diff --git a/app/src/main/java/com/example/myapplication/api/rent/RestRentRepository.kt b/app/src/main/java/com/example/myapplication/api/rent/RestRentRepository.kt index 3380de2..3511327 100644 --- a/app/src/main/java/com/example/myapplication/api/rent/RestRentRepository.kt +++ b/app/src/main/java/com/example/myapplication/api/rent/RestRentRepository.kt @@ -60,6 +60,7 @@ class RestRentRepository( it.id, it.frozenWeight, it.radius, + it.colorbike, it.count ) ) diff --git a/app/src/main/java/com/example/myapplication/api/rentitem/RestRentItemRepository.kt b/app/src/main/java/com/example/myapplication/api/rentitem/RestRentItemRepository.kt index ce501ea..7c17220 100644 --- a/app/src/main/java/com/example/myapplication/api/rentitem/RestRentItemRepository.kt +++ b/app/src/main/java/com/example/myapplication/api/rentitem/RestRentItemRepository.kt @@ -20,6 +20,7 @@ class RestRentItemRepository( item.dateTime, item.weight, item.radius, + item.colorbike, rentItemCrossRef.count, item.bikeId ) diff --git a/app/src/main/java/com/example/myapplication/api/report/ReportRemote.kt b/app/src/main/java/com/example/myapplication/api/report/ReportRemote.kt index af89bdb..a7e2abe 100644 --- a/app/src/main/java/com/example/myapplication/api/report/ReportRemote.kt +++ b/app/src/main/java/com/example/myapplication/api/report/ReportRemote.kt @@ -8,6 +8,7 @@ data class ReportRemote( val dateTime: Int = 0, val weight: Double = 0.0, val radius: Double = 0.0, + val colorbike: String = "", val maxCount: Int = 0, val bikeId: Int = 0 ) \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/api/user/RestUserRepository.kt b/app/src/main/java/com/example/myapplication/api/user/RestUserRepository.kt index f10a170..536e99a 100644 --- a/app/src/main/java/com/example/myapplication/api/user/RestUserRepository.kt +++ b/app/src/main/java/com/example/myapplication/api/user/RestUserRepository.kt @@ -54,6 +54,7 @@ class RestUserRepository( item.dateTime, item.weight, item.radius, + item.colorbike, item.maxCount - service.getRents().flatMap { rent -> rent.items.filter { item -> item.id == it.id } }.sumOf { item -> item.count }) diff --git a/app/src/main/java/com/example/myapplication/composeui/Cart.kt b/app/src/main/java/com/example/myapplication/composeui/Cart.kt index cfc2892..c3d6ed2 100644 --- a/app/src/main/java/com/example/myapplication/composeui/Cart.kt +++ b/app/src/main/java/com/example/myapplication/composeui/Cart.kt @@ -94,6 +94,7 @@ fun Cart( dateTime = item.dateTime, weight = item.weight, radius = item.radius, + colorbike = item.colorbike, maxCount = 0, bikeId = item.bikeId ), user = it @@ -110,6 +111,7 @@ fun Cart( dateTime = item.dateTime, weight = item.weight, radius = item.radius, + colorbike = item.colorbike, maxCount = 0, bikeId = item.bikeId ), userId = it, count = count, availableCount = item.availableCount @@ -266,6 +268,7 @@ private fun ItemListItem( text = "${item.bike.name}\n" + "Вес: ${item.weight}\n" + "R: ${item.radius}\n" + + "Цвет: ${item.colorbike}\n" + "${currentCount}/${item.availableCount}\n" + "Год: ${formattedDate}", color = MaterialTheme.colorScheme.onSecondary diff --git a/app/src/main/java/com/example/myapplication/database/entities/composeui/CartViewModel.kt b/app/src/main/java/com/example/myapplication/database/entities/composeui/CartViewModel.kt index c0a2591..7c4ec52 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/composeui/CartViewModel.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/composeui/CartViewModel.kt @@ -41,6 +41,7 @@ class CartViewModel( item.uid, item.weight, item.radius, + item.colorbike, item.count ) ) diff --git a/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemList.kt b/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemList.kt index dc5bc56..73ecbca 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemList.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemList.kt @@ -109,7 +109,7 @@ fun ItemList( verticalArrangement = Arrangement.spacedBy(4.dp) ) { Text( - text = "Вес: ${item.weight}\n" + "R: ${item.radius}\n" + "Количество: ${item.availableCount}\n" + "Год: ${formattedDate}", + text = "Вес: ${item.weight}\n" + "R: ${item.radius}\n" + "Цвет: ${item.colorbike}\n" + "Количество: ${item.availableCount}\n" + "Год: ${formattedDate}", color = MaterialTheme.colorScheme.onPrimary ) } diff --git a/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemListViewModel.kt b/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemListViewModel.kt index dc3ad18..0c1556f 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemListViewModel.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemListViewModel.kt @@ -18,6 +18,7 @@ class ItemListViewModel( dateTime = item.dateTime, weight = item.weight, radius = item.radius, + colorbike = item.colorbike, maxCount = 0, bikeId = 0 ) diff --git a/app/src/main/java/com/example/myapplication/database/entities/composeui/RentView.kt b/app/src/main/java/com/example/myapplication/database/entities/composeui/RentView.kt index 86f2f5b..48e2b01 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/composeui/RentView.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/composeui/RentView.kt @@ -90,6 +90,7 @@ fun RentView( text = "${item.bike.name}\n" + "Вес: ${item.frozenWeight}\n" + "R: ${item.radius}\n" + + "Цвет: ${item.colorbike}\n" + "Количество: ${count.value}\n" + "Дата: ${formattedDate}", color = MaterialTheme.colorScheme.onPrimary diff --git a/app/src/main/java/com/example/myapplication/database/entities/composeui/ReportPage.kt b/app/src/main/java/com/example/myapplication/database/entities/composeui/ReportPage.kt index 071d89d..d141136 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/composeui/ReportPage.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/composeui/ReportPage.kt @@ -300,17 +300,18 @@ fun TableScreen(reportData: List) { .fillMaxWidth(), // Занимаем максимальную ширину verticalAlignment = Alignment.CenterVertically // Выравниваем по центру вертикали ) { - Text("ID", Modifier.weight(0.5f), color = MaterialTheme.colorScheme.background) - Text("Дата", Modifier.weight(1.0f), color = MaterialTheme.colorScheme.background) - Text("Вес", Modifier.weight(1.0f), color = MaterialTheme.colorScheme.background) - Text("R", Modifier.weight(0.5f), color = MaterialTheme.colorScheme.background) + Text("ID", Modifier.weight(0.3f), color = MaterialTheme.colorScheme.background) + Text("Дата", Modifier.weight(0.8f), color = MaterialTheme.colorScheme.background) + Text("Вес", Modifier.weight(0.7f), color = MaterialTheme.colorScheme.background) + Text("R", Modifier.weight(0.6f), color = MaterialTheme.colorScheme.background) + Text("Цвет", Modifier.weight(1.0f), color = MaterialTheme.colorScheme.background) Text("Кол-во", Modifier.weight(1.0f), color = MaterialTheme.colorScheme.background) - Text("ID вел.", Modifier.weight(1.0f), color = MaterialTheme.colorScheme.background) + Text("ID вел", Modifier.weight(0.5f), color = MaterialTheme.colorScheme.background) } // Here are all the lines of your table. reportData.forEach { - val (id, dateTime, weight, radius, maxCount, bikeId) = it + val (id, dateTime, weight, radius,colorbike, maxCount, bikeId) = it Card( modifier = Modifier .fillMaxWidth() @@ -319,12 +320,13 @@ fun TableScreen(reportData: List) { Row(Modifier .fillMaxWidth() .background(MaterialTheme.colorScheme.background)) { - Text(id.toString(), Modifier.weight(0.5f)) - Text(dateTime.toString(), Modifier.weight(1.0f)) - Text(weight.toString(), Modifier.weight(1.0f)) - Text(radius.toString(), Modifier.weight(1.0f)) + Text(id.toString(), Modifier.weight(0.3f)) + Text(dateTime.toString(), Modifier.weight(0.8f)) + Text(weight.toString(), Modifier.weight(0.7f)) + Text(radius.toString(), Modifier.weight(0.6f)) + Text(colorbike.toString(), Modifier.weight(1.0f)) Text(maxCount.toString(), Modifier.weight(1.0f)) - Text(bikeId.toString(), Modifier.weight(1.0f)) + Text(bikeId.toString(), Modifier.weight(0.5f)) } } } diff --git a/app/src/main/java/com/example/myapplication/database/entities/composeui/edit/ItemEdit.kt b/app/src/main/java/com/example/myapplication/database/entities/composeui/edit/ItemEdit.kt index 0b036c8..f90e07c 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/composeui/edit/ItemEdit.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/composeui/edit/ItemEdit.kt @@ -1,5 +1,6 @@ package com.example.myapplication.database.entities.composeui.edit +import android.annotation.SuppressLint import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn @@ -53,6 +54,7 @@ fun Long.toLocalDate(): org.threeten.bp.LocalDate { return instant.atZone(ZoneId.systemDefault()).toLocalDate() } +@SuppressLint("SuspiciousIndentation") @OptIn(ExperimentalMaterial3Api::class) @Composable private fun ItemEdit( @@ -140,6 +142,19 @@ private fun ItemEdit( ) ) + OutlinedTextField( + modifier = Modifier.fillMaxWidth(), + value = itemUiState.itemDetails.colorbike, + label = { Text(text = "Цвет") }, + onValueChange = { + onUpdate(itemUiState.itemDetails.copy(colorbike = it)) + }, + keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Text), + textStyle = MaterialTheme.typography.bodyLarge.copy( + color = MaterialTheme.colorScheme.onSecondary + ) + ) + OutlinedTextField( modifier = Modifier.fillMaxWidth(), value = itemUiState.itemDetails.maxCount.toString(), diff --git a/app/src/main/java/com/example/myapplication/database/entities/composeui/edit/ItemEditViewModel.kt b/app/src/main/java/com/example/myapplication/database/entities/composeui/edit/ItemEditViewModel.kt index e6842cb..30fe2aa 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/composeui/edit/ItemEditViewModel.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/composeui/edit/ItemEditViewModel.kt @@ -81,6 +81,7 @@ data class ItemDetails( val dateTime: LocalDateTime = LocalDateTime.MIN, val weight: String = "0", val radius: String = "0", + val colorbike: String = "0", val maxCount: Int = 0, val bikeId: Int = 0 ) @@ -90,6 +91,7 @@ fun ItemDetails.toItem(uid: Int = 0, bikeUid: Int = 0): Item = Item( dateTime = dateTime, weight = weight.toDoubleOrNull() ?: 0.0, radius = radius.toDoubleOrNull() ?: 0.0, + colorbike = colorbike, maxCount = maxCount, bikeId = bikeUid ) @@ -99,6 +101,7 @@ fun Item.toDetails(): ItemDetails = ItemDetails( dateTime = dateTime, weight = weight.toString(), radius = radius.toString(), + colorbike = colorbike, maxCount = maxCount, bikeId = bikeId ) diff --git a/app/src/main/java/com/example/myapplication/database/entities/dao/BikeDao.kt b/app/src/main/java/com/example/myapplication/database/entities/dao/BikeDao.kt index d7bed2f..df73596 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/dao/BikeDao.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/dao/BikeDao.kt @@ -16,7 +16,7 @@ interface BikeDao { fun getAll(): PagingSource @Query( - "SELECT c.*, s.uid as item_uid, s.date_time, s.weight, s.radius, s.max_count-IFNULL(SUM(os.count), 0) as available_count, c.uid as bike_id " + + "SELECT c.*, s.uid as item_uid, s.date_time, s.weight, s.radius,s.colorbike, s.max_count-IFNULL(SUM(os.count), 0) as available_count, c.uid as bike_id " + "FROM bikes AS c " + "LEFT JOIN items AS s ON s.bike_id = c.uid " + "LEFT JOIN rents_items AS os ON os.item_id = s.uid " + diff --git a/app/src/main/java/com/example/myapplication/database/entities/dao/RentDao.kt b/app/src/main/java/com/example/myapplication/database/entities/dao/RentDao.kt index 499c4fd..4733abb 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/dao/RentDao.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/dao/RentDao.kt @@ -15,7 +15,7 @@ interface RentDao { fun getAll(userId: Int?): PagingSource @Query( - "SELECT o.*, s.*, os.count, os.frozen_weight, os.radius " + + "SELECT o.*, s.*, os.count, os.frozen_weight, os.radius, os.colorbike " + "FROM rents AS o " + "JOIN rents_items AS os ON os.rent_id = o.uid " + "JOIN items AS s ON s.uid = os.item_id " + diff --git a/app/src/main/java/com/example/myapplication/database/entities/model/Item.kt b/app/src/main/java/com/example/myapplication/database/entities/model/Item.kt index 37bcea9..3dab413 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/model/Item.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/model/Item.kt @@ -25,6 +25,7 @@ data class Item( val dateTime: LocalDateTime, val weight: Double, val radius: Double, + val colorbike: String, @ColumnInfo(name = "max_count") val maxCount: Int, @ColumnInfo(name = "bike_id", index = true) @@ -35,9 +36,10 @@ data class Item( dateTime: LocalDateTime, weight: Double, radius: Double, + colorbike: String, maxCount: Int, bike: Bike, - ) : this(0, dateTime, weight,radius, maxCount, bike.uid) + ) : this(0, dateTime, weight,radius,colorbike, maxCount, bike.uid) companion object { fun getItem(index: Int = 0): Item { @@ -46,6 +48,7 @@ data class Item( LocalDateTime.MIN, 0.0, 0.0, + "", 0, 0 ) @@ -60,6 +63,7 @@ data class Item( if (dateTime != other.dateTime) return false if (weight != other.weight) return false if (radius != other.radius) return false + if (colorbike != other.colorbike) return false if (maxCount != other.maxCount) return false if (bikeId != other.bikeId) return false return true @@ -70,6 +74,7 @@ data class Item( result = 31 * result + dateTime.hashCode() result = 31 * result + weight.hashCode() result = 31 * result + radius.hashCode() + result = 31 * result + colorbike.hashCode() result = 31 * result + maxCount.hashCode() result = 31 * result + bikeId.hashCode() return result diff --git a/app/src/main/java/com/example/myapplication/database/entities/model/ItemFromBike.kt b/app/src/main/java/com/example/myapplication/database/entities/model/ItemFromBike.kt index 39ed29e..5380b13 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/model/ItemFromBike.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/model/ItemFromBike.kt @@ -11,6 +11,7 @@ data class ItemFromBike( val dateTime: LocalDateTime, val weight: Double, val radius: Double, + val colorbike: String, @ColumnInfo(name = "available_count") var availableCount: Int, @ColumnInfo(name = "bike_id") @@ -25,6 +26,7 @@ data class ItemFromBike( if (dateFormatter.format(dateTime) != dateFormatter.format(other.dateTime)) return false if (weight != other.weight) return false if (radius != other.radius) return false + if (colorbike != other.colorbike) return false if (availableCount != other.availableCount) return false if (bikeId != other.bikeId) return false return true @@ -35,6 +37,7 @@ data class ItemFromBike( result = 31 * result + dateTime.hashCode() result = 31 * result + weight.hashCode() result = 31 * result + radius.hashCode() + result = 31 * result + colorbike.hashCode() result = 31 * result + availableCount.hashCode() result = 31 * result + bikeId.hashCode() return result @@ -46,6 +49,7 @@ fun ItemFromBike.toItem(): Item = Item ( dateTime, weight, radius, + colorbike, availableCount, bikeId ) \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/database/entities/model/ItemFromCart.kt b/app/src/main/java/com/example/myapplication/database/entities/model/ItemFromCart.kt index 796d1df..c27ad28 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/model/ItemFromCart.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/model/ItemFromCart.kt @@ -11,6 +11,7 @@ data class ItemFromCart( val dateTime: LocalDateTime, val weight: Double, val radius: Double, + val colorbike: String, @ColumnInfo(name = "available_count") val availableCount: Int, val count: Int, diff --git a/app/src/main/java/com/example/myapplication/database/entities/model/ItemFromRent.kt b/app/src/main/java/com/example/myapplication/database/entities/model/ItemFromRent.kt index 5e12066..f6a856b 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/model/ItemFromRent.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/model/ItemFromRent.kt @@ -12,6 +12,7 @@ data class ItemFromRent( @ColumnInfo(name = "frozen_weight") val frozenWeight: Double, val radius: Double, + val colorbike: String, val count: Int, @ColumnInfo(name = "bike_id") val bikeId: Int = 0, diff --git a/app/src/main/java/com/example/myapplication/database/entities/model/RentItemCrossRef.kt b/app/src/main/java/com/example/myapplication/database/entities/model/RentItemCrossRef.kt index bbb81bf..fe485f9 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/model/RentItemCrossRef.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/model/RentItemCrossRef.kt @@ -16,6 +16,7 @@ data class RentItemCrossRef( @ColumnInfo(name = "frozen_weight") val frozenWeight: Double, val radius: Double, + val colorbike: String, val count: Int ) { override fun equals(other: Any?): Boolean { diff --git a/server/data.json b/server/data.json index e0cbe47..f7dd29f 100644 --- a/server/data.json +++ b/server/data.json @@ -16,10 +16,11 @@ "rents": [], "items": [ { - "dateTime": 2020, - "weight": 23.6, - "radius": 14, - "maxCount": 5, + "dateTime": 2009, + "weight": 36.6, + "radius": 14.5, + "colorbike": "Красный", + "maxCount": 10, "bikeId": 3, "id": 1 } diff --git a/server/router.js b/server/router.js index 9ac80e2..cbdfe23 100644 --- a/server/router.js +++ b/server/router.js @@ -40,6 +40,7 @@ function generateReport(items) { dateTime: item.dateTime, weight: item.weight, radius: item.radius, + colorbike: item.colorbike, maxCount: item.maxCount, bikeId: item.bikeId