Начало бэкенда и сырой фронтенд на моках
This commit is contained in:
commit
fa3003407c
|
|
@ -0,0 +1,6 @@
|
|||
DB_HOST=localhost:55432
|
||||
DB_NAME=fleet_ble_monitor
|
||||
DB_USER=fleet_user
|
||||
DB_PASSWORD=fleet_password
|
||||
SERVER_PORT=8080
|
||||
SEED_ENABLED=true
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,2 @@
|
|||
#Tue Jul 14 15:10:51 NOVT 2026
|
||||
gradle.version=9.6.1
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,10 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Ignored default folder with query files
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
|
|
@ -0,0 +1 @@
|
|||
fleet-ble-monitor-backend
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="17" />
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_STRING" value="-parameters" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="17" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinNotebookOptionsProvider">
|
||||
<option name="jdkName" value="17" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="externalSystemId" value="Gradle" />
|
||||
<option name="version" value="2.4.0" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="KubernetesApiPersistence">{}</component>
|
||||
<component name="KubernetesApiProvider"><![CDATA[{
|
||||
"isMigrated": true
|
||||
}]]></component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK" />
|
||||
</project>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
kotlin version: 2.4.0
|
||||
error message: Daemon compilation failed
|
||||
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
# Fleet BLE Monitor Backend
|
||||
|
||||
Backend starter для системы Fleet BLE Monitor.
|
||||
|
||||
Стек:
|
||||
|
||||
- Kotlin
|
||||
- Spring Boot
|
||||
- Spring GraphQL
|
||||
- Spring Data JPA
|
||||
- PostgreSQL
|
||||
- Docker Compose для локальной базы
|
||||
|
||||
## Быстрый локальный запуск
|
||||
|
||||
Из папки `backend`:
|
||||
|
||||
```powershell
|
||||
cd docker
|
||||
docker compose up -d
|
||||
cd ..
|
||||
.\gradlew.bat clean bootRun
|
||||
```
|
||||
|
||||
После запуска приложение доступно по адресу:
|
||||
|
||||
```text
|
||||
http://localhost:8080/api
|
||||
```
|
||||
|
||||
GraphiQL:
|
||||
|
||||
```text
|
||||
http://localhost:8080/api/graphiql
|
||||
```
|
||||
|
||||
GraphQL endpoint:
|
||||
|
||||
```text
|
||||
http://localhost:8080/api/graphql
|
||||
```
|
||||
|
||||
## Локальная PostgreSQL
|
||||
|
||||
Docker Compose поднимает контейнер:
|
||||
|
||||
```text
|
||||
fleet-ble-monitor-postgres
|
||||
```
|
||||
|
||||
Внутри контейнера PostgreSQL слушает порт `5432`, но на хост проброшен порт `55432`.
|
||||
|
||||
Это сделано специально, чтобы локальный запуск не конфликтовал с установленным на машине PostgreSQL, который часто уже занимает `localhost:5432`.
|
||||
|
||||
Параметры подключения по умолчанию:
|
||||
|
||||
```text
|
||||
DB_HOST=localhost:55432
|
||||
DB_NAME=fleet_ble_monitor
|
||||
DB_USER=fleet_user
|
||||
DB_PASSWORD=fleet_password
|
||||
SERVER_PORT=8080
|
||||
SEED_ENABLED=true
|
||||
```
|
||||
|
||||
Эти же значения указаны в `.env.example`.
|
||||
|
||||
Spring использует переменные:
|
||||
|
||||
- `DB_HOST`
|
||||
- `DB_NAME`
|
||||
- `DB_USER`
|
||||
- `DB_PASSWORD`
|
||||
|
||||
Если переменные не заданы, используются дефолты из `src/main/resources/application.yml`.
|
||||
|
||||
## Полный сброс локальной базы
|
||||
|
||||
Если контейнер уже создавался раньше с другими `POSTGRES_USER` / `POSTGRES_PASSWORD`, PostgreSQL сохранит старые учетные данные в Docker volume. В таком случае изменение `docker-compose.yml` уже не поменяет пароль существующей базы.
|
||||
|
||||
Для полного сброса локальной базы:
|
||||
|
||||
```powershell
|
||||
cd docker
|
||||
docker compose down -v
|
||||
docker compose up -d
|
||||
cd ..
|
||||
.\gradlew.bat clean bootRun
|
||||
```
|
||||
|
||||
Команда `docker compose down -v` удаляет локальный volume PostgreSQL. Все локальные данные будут потеряны.
|
||||
|
||||
## Тестовые пользователи
|
||||
|
||||
Seed-данные создаются при первом запуске, если база пустая и `SEED_ENABLED=true`.
|
||||
|
||||
```text
|
||||
admin / 123456
|
||||
admin@fleet.local / 123456
|
||||
|
||||
user / 123456
|
||||
user@fleet.local / 123456
|
||||
```
|
||||
|
||||
## Пример login mutation
|
||||
|
||||
```graphql
|
||||
mutation {
|
||||
login(payload: { loginOrEmail: "admin", password: "123456" }) {
|
||||
token
|
||||
user {
|
||||
id
|
||||
login
|
||||
email
|
||||
role
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Для запросов, требующих авторизации, передавай токен в HTTP header:
|
||||
|
||||
```text
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
## Пример списка АТТ
|
||||
|
||||
```graphql
|
||||
query {
|
||||
getMachines(
|
||||
page: 0
|
||||
pageSize: 20
|
||||
sortDirection: ASC
|
||||
sortField: NAME
|
||||
) {
|
||||
totalElements
|
||||
page {
|
||||
id
|
||||
name
|
||||
licensePlate
|
||||
lastKnownState
|
||||
beacon {
|
||||
identifier
|
||||
macAddress
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Что доделывать дальше
|
||||
|
||||
- нормальную авторизацию через JWT/AD/LDAP;
|
||||
- миграции Flyway/Liquibase вместо `ddl-auto: update`;
|
||||
- полноценный алгоритм распознавания состояний из телеметрии;
|
||||
- генерацию XLSX/PDF на backend;
|
||||
- scheduler рассылки отчетов;
|
||||
- права доступа на уровне GraphQL resolver/use-case.
|
||||
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
|
||||
plugins {
|
||||
id("org.springframework.boot") version "4.1.0"
|
||||
id("io.spring.dependency-management") version "1.1.7"
|
||||
|
||||
kotlin("jvm") version "2.4.0"
|
||||
kotlin("plugin.spring") version "2.4.0"
|
||||
kotlin("plugin.jpa") version "2.4.0"
|
||||
}
|
||||
|
||||
group = "llc.arma"
|
||||
version = "0.1.0"
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
freeCompilerArgs.addAll("-Xjsr305=strict")
|
||||
jvmTarget.set(JvmTarget.JVM_17)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||
implementation("org.springframework.boot:spring-boot-starter-graphql")
|
||||
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
|
||||
implementation("org.springframework.boot:spring-boot-starter-security")
|
||||
implementation("org.springframework.boot:spring-boot-starter-validation")
|
||||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||
implementation("com.graphql-java:graphql-java-extended-scalars:24.0")
|
||||
|
||||
runtimeOnly("org.postgresql:postgresql")
|
||||
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("org.springframework.graphql:spring-graphql-test")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue