отчеты начаты

This commit is contained in:
Екатерина Рогашова 2023-12-27 02:58:41 +04:00
parent 1921585f6f
commit 989a86b77c
17 changed files with 126 additions and 70 deletions

View File

@ -11,7 +11,7 @@ android {
defaultConfig {
applicationId = "com.example.myapplication"
minSdk = 24
minSdk = 26
targetSdk = 33
versionCode = 1
versionName = "1.0"

View File

@ -56,6 +56,10 @@ sealed class BottomBarScreen(
route = "KPOP",
title=""
)
object Report: BottomBarScreen(
route = "REPORT",
title=""
)
object DirectionView: BottomBarScreen(
route = "DIRECTIONVIEW",
title="",

View File

@ -18,6 +18,7 @@ import com.example.myapplication.House
import com.example.myapplication.Kpop
import com.example.myapplication.Profile
import com.example.myapplication.Registration
import com.example.myapplication.Report
import com.example.myapplication.ui.About
import com.example.myapplication.ui.AppViewModelProvider
import com.example.myapplication.ui.edit.DayDropDownViewModel
@ -46,6 +47,7 @@ fun HomeNavGraph(navController: NavHostController, currentUserViewModel: Current
composable(route = BottomBarScreen.Contemp.route) { Contemp() }
composable(route = BottomBarScreen.BrDance.route) { BrDance() }
composable(route = BottomBarScreen.Kpop.route) { Kpop() }
composable(route = BottomBarScreen.Report.route) { Report() }
composable(
BottomBarScreen.LessonEdit.route,
arguments = listOf(navArgument("id") { type = NavType.IntType })

View File

@ -343,16 +343,16 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
.clickable { openDialogUser = true })
}
// Box(
// modifier = Modifier
// .align(alignment = Alignment.TopStart)
// .offset(
// x = 0.dp,
// y = 300.dp
// modifier = Modifier
// .align(alignment = Alignment.TopStart)
// .offset(
// x = 0.dp,
// y = 300.dp
// )
// .requiredWidth(width = 200.dp)
// .requiredHeight(height = 44.dp)
// )
// .requiredWidth(width = 200.dp)
// .requiredHeight(height = 44.dp)
// )
// {
// {
// Box(
// modifier = Modifier
// .fillMaxWidth()
@ -371,8 +371,8 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
// modifier = Modifier
// .requiredWidth(width = 200.dp)
// .requiredHeight(height = 44.dp)
// .wrapContentHeight(align = Alignment.CenterVertically)
// .clickable { navController.navigate(route = AuthScreen.Enter.route); getUser = null })
// .wrapContentHeight(align = Alignment.CenterVertically))
// //.clickable { navController.navigate(route = AuthScreen.Enter.route); getUser = null })
// }
}
}
@ -459,7 +459,6 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
.requiredHeight(height = 80.dp)
.clip(shape = RoundedCornerShape(5.dp))
.background(color = Color.White)
)
if (getUser?.role == RoleEnum.User) {
Text(
@ -478,8 +477,8 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
}
else{
Text(
text = "К записи",
color = Color.White,
text = "Получить отчет",
color = Color.Black,
textAlign = TextAlign.Center,
style = TextStyle(
fontSize = 17.sp,
@ -491,10 +490,8 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
.wrapContentHeight(align = Alignment.CenterVertically)
.align(Alignment.Center)
.clickable(
enabled = getUser?.lessonId != null,
onClick = {
val route = BottomBarScreen.LessonRecord.route.replace("{id}", lessonId.toString())
navController.navigate(route)
navController.navigate("report")
})
)
}
@ -520,7 +517,7 @@ fun Profile(navController: NavController, modifier: Modifier = Modifier, lessonL
)
)
Text(
text = "Получить отчет",
text = "К записи",
color = Color.White,
textAlign = TextAlign.Center,
style = TextStyle(

View File

@ -0,0 +1,55 @@
package com.example.myapplication
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@Composable
fun Report() {
var startRecord by remember { mutableStateOf("") }
var endRecord by remember { mutableStateOf("") }
Column(
modifier = Modifier.padding(16.dp)
) {
// Поле ввода для startRecord
TextField(
value = startRecord,
onValueChange = { startRecord = it },
label = { Text("Start Record") },
modifier = Modifier.fillMaxWidth()
)
// Поле ввода для endRecord
TextField(
value = endRecord,
onValueChange = { endRecord = it },
label = { Text("End Record") },
modifier = Modifier.fillMaxWidth()
)
Spacer(modifier = Modifier.height(16.dp))
// Кнопка "Сформировать"
Button(
onClick = {
},
modifier = Modifier.align(Alignment.CenterHorizontally)
) {
Text(text = "Сформировать")
}
}
}

View File

@ -3,6 +3,7 @@ package com.example.myapplication.api
import com.example.myapplication.api.model.DayOfWeekRemote
import com.example.myapplication.api.model.DirectionRemote
import com.example.myapplication.api.model.LessonRemote
import com.example.myapplication.api.model.ReportRemote
import com.example.myapplication.api.model.UserRemote
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import kotlinx.serialization.json.Json
@ -19,6 +20,11 @@ import retrofit2.http.Path
import retrofit2.http.Query
interface MyServerService {
@GET("report")
suspend fun getReport(
@Query("startDate") startRecord: Int,
@Query("endDate") endRecord: Int
): List<ReportRemote>
@GET("days")
suspend fun getDays(): List<DayOfWeekRemote>

View File

@ -9,7 +9,6 @@ data class LessonRemote(
val teacher: String = "",
val time: String = "",
val classNumber: Int = 0,
val dayOfWeekId: Int = 0,
val directionId: Int = 0,
val countRecord: Int = 0

View File

@ -0,0 +1,12 @@
package com.example.myapplication.api.model
import kotlinx.serialization.Serializable
@Serializable
data class ReportRemote(
val lessonName: String = "",
val lessonDay: String = "",
val lessonTime: String = "",
val countRecords: Int = 0,
val countFreeRecords: Int = 0
)

View File

@ -10,6 +10,7 @@ import com.example.myapplication.api.day.RestDayOfWeekRepository
import com.example.myapplication.api.direction.RestDirectionRepository
import com.example.myapplication.api.lesson.LessonRemoteMediator
import com.example.myapplication.api.lesson.RestLessonRepository
import com.example.myapplication.api.model.ReportRemote
import com.example.myapplication.api.model.toDayOfWeek
import com.example.myapplication.api.model.toLesson
import com.example.myapplication.api.model.toLessonRemote
@ -50,6 +51,10 @@ class RestUserRepository(
return existUsers.map { it.value }.sortedBy { it.uid }
}
override suspend fun getReport(startRecord: Int, endRecord: Int):List<ReportRemote>
{
return service.getReport(startRecord,endRecord)
}
override suspend fun getUserById(uid: Int?): User? =
uid?.let { service.getUserById(it).toUser() }

View File

@ -4,7 +4,6 @@ import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.sqlite.db.SupportSQLiteDatabase
import com.example.myapplication.dataBase.dao.DayDao
import com.example.myapplication.dataBase.dao.DirectionDao
import com.example.myapplication.dataBase.dao.LessonDao
@ -16,8 +15,6 @@ import com.example.myapplication.dataBase.model.RoleEnum
import com.example.myapplication.dataBase.model.User
import com.example.myapplication.dataBase.remotekeys.dao.RemoteKeysDao
import com.example.myapplication.dataBase.remotekeys.model.RemoteKeys
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@Database(entities = [Lesson::class, DayOfWeek::class, Direction::class, User::class, RemoteKeys::class], version = 1, exportSchema = false)
@ -29,7 +26,7 @@ abstract class AppDatabase : RoomDatabase() {
abstract fun remoteKeysDao(): RemoteKeysDao
companion object {
private const val DB_NAME: String = "bd8"
private const val DB_NAME: String = "bd111"
@Volatile
private var INSTANCE: AppDatabase? = null

View File

@ -10,7 +10,7 @@ import androidx.room.PrimaryKey
entity = Lesson::class,
parentColumns = ["uid"],
childColumns = ["lesson_id"],
onDelete = ForeignKey.CASCADE,
onDelete = ForeignKey.SET_NULL,
onUpdate = ForeignKey.CASCADE
)])
data class User(

View File

@ -1,5 +1,6 @@
package com.example.myapplication.dataBase.repository
import com.example.myapplication.api.model.ReportRemote
import com.example.myapplication.dataBase.dao.UserDao
import com.example.myapplication.dataBase.model.User
import kotlinx.coroutines.flow.Flow
@ -15,4 +16,7 @@ class OfflineUserRepository(private val userDao: UserDao) : UserRepository {
override suspend fun getUserById(uid: Int?): User = userDao.getUserById(uid).first()
override suspend fun getAllUsers(): List<User> = userDao.getAll()
override suspend fun getReport(startRecord: Int, endRecord: Int): List<ReportRemote> {
TODO("Not yet implemented")
}
}

View File

@ -1,5 +1,6 @@
package com.example.myapplication.dataBase.repository
import com.example.myapplication.api.model.ReportRemote
import com.example.myapplication.dataBase.model.User
import kotlinx.coroutines.flow.Flow
@ -9,4 +10,5 @@ interface UserRepository {
suspend fun deleteUser(user: User)
suspend fun getUserById(uid: Int?): User?
suspend fun getAllUsers(): List<User>
suspend fun getReport(startRecord: Int, endRecord: Int):List<ReportRemote>
}

View File

@ -126,4 +126,4 @@ fun Lesson.toDetails(): LessonDetails = LessonDetails(
fun Lesson.toUiState(isEntryValid: Boolean = false): LessonUiState = LessonUiState(
lessonDetails = this.toDetails(),
isEntryValid = isEntryValid
)
)

View File

@ -55,7 +55,11 @@ import kotlinx.coroutines.launch
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@ -69,6 +73,7 @@ import androidx.compose.ui.zIndex
import androidx.navigation.NavHostController
import androidx.paging.compose.LazyPagingItems
import androidx.paging.compose.collectAsLazyPagingItems
import androidx.paging.compose.itemContentType
import androidx.paging.compose.itemKey
import com.example.myapplication.Enter
import com.example.myapplication.Graph.BottomBarScreen
@ -189,21 +194,14 @@ private fun SwipeToDelete(
)
}
@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterialApi::class)
@Composable
private fun LessonList(
modifier: Modifier = Modifier,
lessonList: LazyPagingItems<Lesson>,
onClick: (uid: Int) -> Unit,
onClick: (id: Int) -> Unit,
onSwipe: (lesson: Lesson) -> Unit
) {
val refreshScope = rememberCoroutineScope()
var refreshing by remember { mutableStateOf(false) }
fun refresh() = refreshScope.launch {
refreshing = true
lessonList.refresh()
refreshing = false
}
Column(
modifier = modifier
) {
@ -504,6 +502,7 @@ private fun LessonList(
}
}
@Composable
private fun LessonListItem(
lesson: Lesson, modifier: Modifier = Modifier

View File

@ -14,7 +14,7 @@
<string name="lesson_record_button">Записаться</string>
<string name="lesson_cancel_button">Отменить запись</string>
<string name="student_phone">Телефон</string>
<string name="lesson_TimeDate">Время начала и конца</string>
<string name="lesson_TimeDate">Время</string>
<string name="lesson_DayOfWeek">День недели</string>
<string name="student_email">e-mail</string>
<string name="lessons_main_title">Расписание</string>

View File

@ -59,7 +59,7 @@
{
"id": 1,
"teacher": "Анна",
"time": "9.00-10.00",
"time": "9:00",
"classNumber": 2,
"dayOfWeekId": 1,
"directionId": 1,
@ -68,7 +68,7 @@
{
"id": 3,
"teacher": "Мария",
"time": "17.00-18.00",
"time": "17:00",
"classNumber": 3,
"dayOfWeekId": 2,
"directionId": 3,
@ -77,37 +77,11 @@
{
"id": 4,
"teacher": "Алла",
"time": "9.00-12.30",
"time": "9:30",
"classNumber": 6,
"dayOfWeekId": 3,
"directionId": 3,
"dayOfWeekId": 3,
"countRecord": 4
},
{
"id": 5,
"teacher": "Илона",
"time": "8.00-9.00",
"classNumber": 6,
"dayOfWeekId": 5,
"directionId": 1,
"countRecord": 5
},
{
"id": 6,
"teacher": "Софья Олеговна",
"time": "10.00",
"classNumber": 6,
"dayOfWeekId": 3,
"directionId": 6,
"countRecord": 5
},
{
"id": 7,
"teacher": "Илона",
"time": "10.00",
"classNumber": 5,
"dayOfWeekId": 5,
"directionId": 3
}
],
"users": [
@ -125,7 +99,7 @@
"password": "5678",
"fio": "Илья Петрович Мунин",
"role": "User",
"lessonId": 7
"lessonId": null
},
{
"id": 3,
@ -133,7 +107,7 @@
"password": "13579",
"fio": "Мария Денисовна Амова",
"role": "User",
"lessonId": 3
"lessonId": null
},
{
"id": 7,
@ -141,7 +115,7 @@
"password": "user7",
"fio": "user7",
"role": "User",
"lessonId": 7
"lessonId": null
},
{
"id": 8,
@ -157,7 +131,7 @@
"password": "parol",
"fio": "user7",
"role": "User",
"lessonId": 7
"lessonId": null
}
]
}