Compare commits
70 Commits
Author | SHA1 | Date | |
---|---|---|---|
df4b320756 | |||
3fe9a0dc90 | |||
bfef99b5f2 | |||
34bc393330 | |||
8ac47b0fdf | |||
f1de853000 | |||
0cf8d17cca | |||
463296c358 | |||
a53c4fff2d | |||
1fe72328a0 | |||
ae0b310be9 | |||
d20e7b620b | |||
f1101c99d0 | |||
ae35a740cc | |||
82c65a4fb2 | |||
8ce978e9cb | |||
b04eacffd1 | |||
23789c477e | |||
534db18d1f | |||
63fa78d2b7 | |||
b6fabeec1b | |||
b487f2d7f4 | |||
c633283fc0 | |||
793f596fa4 | |||
61f0899395 | |||
88cb673966 | |||
8bdbd72802 | |||
223a89a4c0 | |||
6f5fe27b71 | |||
2173e08c60 | |||
f62b651f74 | |||
449e228d9c | |||
78ed63c5c7 | |||
8eeb3fb9bd | |||
5da550f2ea | |||
2b3e8e4001 | |||
a10af3ab43 | |||
d080ad3803 | |||
|
19481483e6 | ||
|
1713a0be9a | ||
|
e865488ab5 | ||
|
e83cce2315 | ||
|
fd09f7b780 | ||
|
d08574bc53 | ||
|
957c902e21 | ||
|
b40fbf0146 | ||
|
c627adae2c | ||
|
94c977fc81 | ||
|
0fba5a7053 | ||
|
29472d699d | ||
|
29da561847 | ||
|
b50a31d9f2 | ||
|
e41cdadd7a | ||
|
fe92621f14 | ||
|
fa6fbd2323 | ||
|
58581e731b | ||
|
902ba9515a | ||
|
5308c48d8a | ||
|
8fed6a12ef | ||
|
980a89897f | ||
|
7cbeccfd24 | ||
|
17e221a416 | ||
|
45d6848f98 | ||
|
25d1af7399 | ||
|
ef0baec61b | ||
|
6e33c25912 | ||
|
776271e081 | ||
|
23a5a3f8c0 | ||
|
89778a0f59 | ||
|
db166df53b |
14
.vscode/launch.json
vendored
Normal file
14
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"type": "java",
|
||||
"name": "Spring Boot-BackendApplication<backend>",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"mainClass": "com.example.backend.BackendApplication",
|
||||
"projectName": "backend",
|
||||
"args": "",
|
||||
"envFile": "${workspaceFolder}/.env"
|
||||
}
|
||||
]
|
||||
}
|
4
.vscode/settings.json
vendored
Normal file
4
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"java.configuration.updateBuildConfiguration": "automatic",
|
||||
"java.debug.settings.onBuildFailureProceed": true
|
||||
}
|
37
backend/.gitignore
vendored
Normal file
37
backend/.gitignore
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
HELP.md
|
||||
.gradle
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
41
backend/build.gradle
Normal file
41
backend/build.gradle
Normal file
@ -0,0 +1,41 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '3.2.5'
|
||||
id 'io.spring.dependency-management' version '1.1.4'
|
||||
}
|
||||
|
||||
group = 'com.example'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
|
||||
java {
|
||||
sourceCompatibility = '17'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0'
|
||||
implementation 'org.modelmapper:modelmapper:3.2.0'
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
implementation 'com.h2database:h2:2.2.224'
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-devtools'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:3.3.0'
|
||||
runtimeOnly 'org.webjars.npm:bootstrap:5.3.3'
|
||||
runtimeOnly 'org.webjars.npm:bootstrap-icons:1.11.3'
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
|
||||
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.0'
|
||||
}
|
||||
|
||||
tasks.named('test') {
|
||||
useJUnitPlatform()
|
||||
}
|
BIN
backend/data.mv.db
Normal file
BIN
backend/data.mv.db
Normal file
Binary file not shown.
92237
backend/data.trace.db
Normal file
92237
backend/data.trace.db
Normal file
File diff suppressed because it is too large
Load Diff
BIN
backend/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
backend/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
backend/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
backend/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
249
backend/gradlew
vendored
Normal file
249
backend/gradlew
vendored
Normal file
@ -0,0 +1,249 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
92
backend/gradlew.bat
vendored
Normal file
92
backend/gradlew.bat
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
1
backend/settings.gradle
Normal file
1
backend/settings.gradle
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name = 'backend'
|
@ -0,0 +1,108 @@
|
||||
package com.example.backend;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
import com.example.backend.categories.model.CategorieEntity;
|
||||
import com.example.backend.categories.service.CategorieService;
|
||||
import com.example.backend.favorites.model.FavoriteEntity;
|
||||
import com.example.backend.favorites.service.FavoriteService;
|
||||
import com.example.backend.movies.model.MovieEntity;
|
||||
import com.example.backend.movies.service.MovieService;
|
||||
import com.example.backend.users.service.UserService;
|
||||
|
||||
// create lab 2
|
||||
|
||||
@SpringBootApplication
|
||||
public class BackendApplication implements CommandLineRunner {
|
||||
|
||||
private final Logger _logger = LoggerFactory.getLogger(BackendApplication.class);
|
||||
private final UserService userService;
|
||||
private final CategorieService categorieService;
|
||||
private final MovieService movieService;
|
||||
private final FavoriteService favoriyService;
|
||||
|
||||
public BackendApplication(UserService userService,
|
||||
CategorieService categorieService,
|
||||
MovieService movieService,
|
||||
FavoriteService favoriyService) {
|
||||
this.userService = userService;
|
||||
this.categorieService = categorieService;
|
||||
this.favoriyService = favoriyService;
|
||||
this.movieService = movieService;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BackendApplication.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
|
||||
// final var admin = new UserEntity(null, "elena", "1234");
|
||||
// final var vasya = new UserEntity(null, "vasya", "1234");
|
||||
|
||||
// final var u1 = new UserEntity(null, "1", "1234");
|
||||
// final var u2 = new UserEntity(null, "2", "1234");
|
||||
// final var u3 = new UserEntity(null, "3", "1234");
|
||||
// final var u4 = new UserEntity(null, "4", "1234");
|
||||
// final var u5 = new UserEntity(null, "5", "1234");
|
||||
// final var u6 = new UserEntity(null, "6", "1234");
|
||||
// final var u7 = new UserEntity(null, "7", "1234");
|
||||
|
||||
// final var cat1 = new CategorieEntity(null, "Драма", null);
|
||||
// final var cat2 = new CategorieEntity(null, "Комедия", null);
|
||||
// final var cat3 = new CategorieEntity(null, "Хоррор", null);
|
||||
// final var cat4 = new CategorieEntity(null, "Мультитк", null);
|
||||
|
||||
// final var cat5 = new CategorieEntity(null, "Опера", null);
|
||||
|
||||
// final var mov1 = new MovieEntity(null, cat5, "певчая птичка", "null", "null",
|
||||
// null);
|
||||
|
||||
// admin.setRole(UserRole.ADMIN);
|
||||
// vasya.setRole(UserRole.USER);
|
||||
|
||||
// u1.setRole(UserRole.USER);
|
||||
// u2.setRole(UserRole.USER);
|
||||
// u3.setRole(UserRole.USER);
|
||||
// u4.setRole(UserRole.USER);
|
||||
// u5.setRole(UserRole.USER);
|
||||
// u6.setRole(UserRole.USER);
|
||||
// u7.setRole(UserRole.USER);
|
||||
|
||||
// userService.create(admin);
|
||||
// userService.create(vasya);
|
||||
// userService.create(u1);
|
||||
// userService.create(u2);
|
||||
// userService.create(u3);
|
||||
// userService.create(u4);
|
||||
// userService.create(u5);
|
||||
// userService.create(u6);
|
||||
// userService.create(u7);
|
||||
|
||||
// categorieService.create(cat1);
|
||||
// categorieService.create(cat2);
|
||||
// categorieService.create(cat3);
|
||||
// categorieService.create(cat4);
|
||||
// categorieService.create(cat5);
|
||||
// movieService.create(mov1);
|
||||
|
||||
// movieService.get(98));
|
||||
// for (var fav : favoriyService.getAll(2)) {
|
||||
// favoriyService.delete(fav.getId());
|
||||
// }
|
||||
// favoriyService.create(new FavoriteEntity(null, userService.get(2),
|
||||
// movieService.get(98)));
|
||||
|
||||
_logger.info("The program is started, coun users is " + userService.getAll().size());
|
||||
_logger.info("The program is started, coun films is " + movieService.getAll(0).size());
|
||||
// _logger.info("The program is started, coun categories is " +
|
||||
// categorieService.getAll().size());
|
||||
|
||||
}
|
||||
|
||||
}
|
53
backend/src/main/java/com/example/backend/TestDTO.java
Normal file
53
backend/src/main/java/com/example/backend/TestDTO.java
Normal file
@ -0,0 +1,53 @@
|
||||
package com.example.backend;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class TestDTO {
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String img;
|
||||
|
||||
public TestDTO() {
|
||||
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public TestDTO(
|
||||
@JsonProperty(value = "id") Integer id,
|
||||
@JsonProperty(value = "name") String name,
|
||||
@JsonProperty(value = "img") String img) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.img = img;
|
||||
}
|
||||
|
||||
// GET
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getImg() {
|
||||
return img;
|
||||
}
|
||||
|
||||
// SET
|
||||
|
||||
public void setId(Integer Id) {
|
||||
id = Id;
|
||||
}
|
||||
|
||||
public void setName(String Name) {
|
||||
name = Name;
|
||||
}
|
||||
|
||||
public void setImg(String Img) {
|
||||
img = Img;
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package com.example.backend.categories.api;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.example.backend.categories.model.CategorieEntity;
|
||||
import com.example.backend.categories.service.CategorieService;
|
||||
import com.example.backend.core.configurations.Constants;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(CategorieController.URL)
|
||||
public class CategorieController {
|
||||
|
||||
public static final String URL = Constants.ADMIN_PREFIX + "/categories";
|
||||
private static final String CATEGORIE_VIEW = "categories";
|
||||
private static final String CATEGORIE_ATTRIBUTE = "categorie";
|
||||
private static final String CATEGORIE_EDIT_VIEW = "categorie-edit";
|
||||
|
||||
private final CategorieService categorieService;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
public CategorieController(CategorieService categorieService, ModelMapper modelMapper) {
|
||||
this.categorieService = categorieService;
|
||||
this.modelMapper = modelMapper;
|
||||
}
|
||||
|
||||
private CategorieDTO toDto(CategorieEntity entity) {
|
||||
return modelMapper.map(entity, CategorieDTO.class);
|
||||
}
|
||||
|
||||
private CategorieEntity toEntity(CategorieDTO categorieDTO) {
|
||||
return modelMapper.map(categorieDTO, CategorieEntity.class);
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
public String getAll(Model model) {
|
||||
model.addAttribute(
|
||||
"categories",
|
||||
categorieService.getAll().stream()
|
||||
.map(this::toDto)
|
||||
.toList());
|
||||
return CATEGORIE_VIEW;
|
||||
}
|
||||
|
||||
@GetMapping("/edit/")
|
||||
public String create(Model model) {
|
||||
model.addAttribute(CATEGORIE_ATTRIBUTE, new CategorieDTO());
|
||||
return CATEGORIE_EDIT_VIEW;
|
||||
}
|
||||
|
||||
@PostMapping("/edit/")
|
||||
public String create(@ModelAttribute(name = CATEGORIE_ATTRIBUTE) @Valid CategorieDTO categorieDTO,
|
||||
BindingResult bindingResult, RedirectAttributes redirectAttributes) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return CATEGORIE_EDIT_VIEW;
|
||||
}
|
||||
CategorieEntity category = toEntity(categorieDTO);
|
||||
categorieService.create(category);
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
|
||||
@GetMapping("/edit/{id}")
|
||||
public String update(@PathVariable(name = "id") Integer id, Model model) {
|
||||
if (id <= 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
model.addAttribute(CATEGORIE_ATTRIBUTE, toDto(categorieService.get(id)));
|
||||
return CATEGORIE_EDIT_VIEW;
|
||||
}
|
||||
|
||||
@PostMapping("/edit/{id}")
|
||||
public String update(@PathVariable(name = "id") Integer id,
|
||||
@ModelAttribute(name = CATEGORIE_ATTRIBUTE) @Valid CategorieDTO categorieDTO,
|
||||
BindingResult bindingResult, RedirectAttributes redirectAttributes) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return CATEGORIE_EDIT_VIEW;
|
||||
}
|
||||
|
||||
CategorieEntity category = toEntity(categorieDTO);
|
||||
|
||||
categorieService.update(id, category);
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
|
||||
@PostMapping("delete/{id}")
|
||||
public String delete(@PathVariable(name = "id") Integer id) {
|
||||
categorieService.delete(id);
|
||||
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.example.backend.categories.api;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public class CategorieDTO {
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Integer id;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 5, max = 50)
|
||||
private String name;
|
||||
|
||||
private String image;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.example.backend.categories.api;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.example.backend.categories.model.CategorieEntity;
|
||||
import com.example.backend.categories.service.CategorieService;
|
||||
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(CategorieUserController.URL)
|
||||
public class CategorieUserController {
|
||||
|
||||
public static final String URL = "/categories";
|
||||
private static final String CATEGORIE_VIEW = "categories";
|
||||
|
||||
private final CategorieService categorieService;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
public CategorieUserController(CategorieService categorieService, ModelMapper modelMapper) {
|
||||
this.categorieService = categorieService;
|
||||
this.modelMapper = modelMapper;
|
||||
}
|
||||
|
||||
private CategorieDTO toDto(CategorieEntity entity) {
|
||||
return modelMapper.map(entity, CategorieDTO.class);
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
public String getAll(Model model) {
|
||||
model.addAttribute(
|
||||
"categories",
|
||||
categorieService.getAll().stream()
|
||||
.map(this::toDto)
|
||||
.toList());
|
||||
return CATEGORIE_VIEW;
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.example.backend.categories.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.example.backend.core.model.BaseEntity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "categories")
|
||||
public class CategorieEntity extends BaseEntity {
|
||||
|
||||
@Column(nullable = false, unique = true, length = 50)
|
||||
private String name;
|
||||
|
||||
@Column(nullable = true)
|
||||
private String image;
|
||||
|
||||
public CategorieEntity() {
|
||||
|
||||
}
|
||||
|
||||
public CategorieEntity(Integer id, String name, String image) {
|
||||
this.name = name;
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name, image);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
final CategorieEntity other = (CategorieEntity) obj;
|
||||
return Objects.equals(other.getId(), id) &&
|
||||
Objects.equals(other.getName(), name) &&
|
||||
Objects.equals(other.getImage(), image);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.example.backend.categories.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import com.example.backend.categories.model.CategorieEntity;
|
||||
|
||||
public interface CategorieRepository extends CrudRepository<CategorieEntity, Integer> {
|
||||
Optional<CategorieEntity> findByNameIgnoreCase(String name);
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.example.backend.categories.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.backend.core.errors.NotFoundException;
|
||||
import com.example.backend.movies.repository.MovieRepository;
|
||||
import com.example.backend.categories.model.CategorieEntity;
|
||||
import com.example.backend.categories.repository.CategorieRepository;
|
||||
|
||||
@Service
|
||||
public class CategorieService {
|
||||
|
||||
private final CategorieRepository repository;
|
||||
private final MovieRepository movieRepository;
|
||||
|
||||
public CategorieService(CategorieRepository repository, MovieRepository movieRepository) {
|
||||
this.repository = repository;
|
||||
this.movieRepository = movieRepository;
|
||||
}
|
||||
|
||||
private void checkName(String name) {
|
||||
if (repository.findByNameIgnoreCase(name).isPresent()) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Type with name %s is already exists", name));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<CategorieEntity> getAll() {
|
||||
return StreamSupport.stream(repository.findAll().spliterator(), false).toList();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public CategorieEntity get(Integer id) {
|
||||
return repository.findById(id).orElseThrow(() -> new NotFoundException(CategorieEntity.class, id));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public CategorieEntity create(CategorieEntity entity) {
|
||||
if (entity == null) {
|
||||
throw new IllegalArgumentException("Сущность не найдена");
|
||||
}
|
||||
checkName(entity.getName());
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public CategorieEntity update(Integer id, CategorieEntity entity) {
|
||||
final CategorieEntity existsentity = get(id);
|
||||
existsentity.setName(entity.getName());
|
||||
existsentity.setImage(entity.getImage());
|
||||
return repository.save(existsentity);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public CategorieEntity delete(Integer id) {
|
||||
final CategorieEntity existsentity = get(id);
|
||||
movieRepository.deleteByCategorieId(existsentity.getId());
|
||||
repository.delete(existsentity);
|
||||
return existsentity;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.example.backend.core.api;
|
||||
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
@ControllerAdvice
|
||||
public class GlobalController {
|
||||
|
||||
@ModelAttribute("servletPath")
|
||||
String getRequestServletPath(HttpServletRequest request) {
|
||||
return request.getServletPath();
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.example.backend.core.api;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public class PageAttributesMapper {
|
||||
private PageAttributesMapper() {
|
||||
}
|
||||
|
||||
public static <E, D> Map<String, Object> toAttributes(Page<E> page, Function<E, D> mapper) {
|
||||
return Map.of(
|
||||
"items", page.getContent().stream().map(mapper::apply).toList(),
|
||||
"currentPage", page.getNumber(),
|
||||
"totalPages", page.getTotalPages());
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.example.backend.core.configurations;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final String API_URL = "/api";
|
||||
|
||||
public static final String SEQUENCE_NAME = "hibernate_sequence";
|
||||
|
||||
public static final int DEFUALT_PAGE_SIZE = 6;
|
||||
|
||||
public static final String REDIRECT_VIEW = "redirect:";
|
||||
|
||||
public static final String ADMIN_PREFIX = "/admin";
|
||||
|
||||
public static final String LOGIN_URL = "/login";
|
||||
|
||||
public static final String LOGOUT_URL = "/logout";
|
||||
|
||||
public static final String DEFAULT_PASSWORD = "123456";
|
||||
|
||||
private Constants() {
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.example.backend.core.configurations;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.modelmapper.PropertyMap;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.example.backend.core.model.BaseEntity;
|
||||
|
||||
@Configuration
|
||||
public class MapperConfiguration {
|
||||
@Bean
|
||||
ModelMapper modelMapper() {
|
||||
final ModelMapper mapper = new ModelMapper();
|
||||
mapper.addMappings(new PropertyMap<Object, BaseEntity>() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
skip(destination.getId());
|
||||
}
|
||||
});
|
||||
return mapper;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.example.backend.core.configurations;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfiguration implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
registry.addViewController("/login").setViewName("login");
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.example.backend.core.errors;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
@ControllerAdvice
|
||||
public class AdviceController {
|
||||
private final Logger log = LoggerFactory.getLogger(AdviceController.class);
|
||||
|
||||
private static Throwable getRootCause(Throwable throwable) {
|
||||
Throwable rootCause = throwable;
|
||||
while (rootCause.getCause() != null && rootCause.getCause() != rootCause) {
|
||||
rootCause = rootCause.getCause();
|
||||
}
|
||||
return rootCause;
|
||||
}
|
||||
|
||||
private static Map<String, Object> getAttributes(HttpServletRequest request, Throwable throwable) {
|
||||
final Throwable rootCause = getRootCause(throwable);
|
||||
final StackTraceElement firstError = rootCause.getStackTrace()[0];
|
||||
return Map.of(
|
||||
"message", rootCause.getMessage(),
|
||||
"url", request.getRequestURL(),
|
||||
"exception", rootCause.getClass().getName(),
|
||||
"file", firstError.getFileName(),
|
||||
"method", firstError.getMethodName(),
|
||||
"line", firstError.getLineNumber());
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
public ModelAndView defaultErrorHandler(HttpServletRequest request, Throwable throwable) throws Throwable {
|
||||
if (AnnotationUtils.findAnnotation(throwable.getClass(),
|
||||
ResponseStatus.class) != null) {
|
||||
throw throwable;
|
||||
}
|
||||
|
||||
log.error("{}", throwable.getMessage());
|
||||
throwable.printStackTrace();
|
||||
final ModelAndView model = new ModelAndView();
|
||||
model.addAllObjects(getAttributes(request, throwable));
|
||||
model.setViewName("error");
|
||||
return model;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.example.backend.core.errors;
|
||||
|
||||
public class NotFoundException extends RuntimeException {
|
||||
public <T> NotFoundException(Class<T> clazz, Integer id) {
|
||||
super(String.format("%s with id [%s] is not found or not exists", clazz.getSimpleName(), id));
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.example.backend.core.errors;
|
||||
|
||||
public class NullArgumentException extends RuntimeException {
|
||||
public NullArgumentException(Integer id) {
|
||||
super(String.format("В данной сущности нет объектов в айдишником <[%s]>", id));
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.example.backend.core.model;
|
||||
|
||||
import com.example.backend.core.configurations.Constants;
|
||||
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import jakarta.persistence.SequenceGenerator;
|
||||
|
||||
@MappedSuperclass
|
||||
public abstract class BaseEntity {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = Constants.SEQUENCE_NAME)
|
||||
@SequenceGenerator(name = Constants.SEQUENCE_NAME, sequenceName = Constants.SEQUENCE_NAME, allocationSize = 1)
|
||||
protected Integer id;
|
||||
|
||||
protected BaseEntity() {
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.example.backend.core.security;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
||||
import org.springframework.security.config.Customizer;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer.FrameOptionsConfig;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
import com.example.backend.core.configurations.Constants;
|
||||
import com.example.backend.users.api.UserSignupController;
|
||||
import com.example.backend.users.model.UserRole;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class SecurityConfiguration {
|
||||
@Bean
|
||||
SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {
|
||||
httpSecurity.headers(headers -> headers.frameOptions(FrameOptionsConfig::sameOrigin));
|
||||
httpSecurity.csrf(AbstractHttpConfigurer::disable);
|
||||
httpSecurity.cors(Customizer.withDefaults());
|
||||
|
||||
httpSecurity.authorizeHttpRequests(requests -> requests
|
||||
.requestMatchers("/css/**", "/webjars/**", "/*.svg", "/images/**", "/fonts/**")
|
||||
.permitAll());
|
||||
|
||||
httpSecurity.authorizeHttpRequests(requests -> requests
|
||||
.requestMatchers(Constants.ADMIN_PREFIX + "/**").hasRole(UserRole.ADMIN.name())
|
||||
.requestMatchers("/h2-console/**").hasRole(UserRole.ADMIN.name())
|
||||
.requestMatchers(UserSignupController.URL).anonymous()
|
||||
.requestMatchers(Constants.LOGIN_URL).anonymous()
|
||||
.anyRequest().authenticated());
|
||||
|
||||
httpSecurity.formLogin(formLogin -> formLogin
|
||||
.loginPage(Constants.LOGIN_URL));
|
||||
|
||||
httpSecurity.rememberMe(rememberMe -> rememberMe.key("uniqueAndSecret"));
|
||||
|
||||
httpSecurity.logout(logout -> logout
|
||||
.deleteCookies("JSESSIONID"));
|
||||
|
||||
return httpSecurity.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
DaoAuthenticationProvider authenticationProvider(UserDetailsService userDetailsService) {
|
||||
final DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
|
||||
authProvider.setUserDetailsService(userDetailsService);
|
||||
authProvider.setPasswordEncoder(passwordEncoder());
|
||||
return authProvider;
|
||||
}
|
||||
|
||||
@Bean
|
||||
PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.example.backend.core.security;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import com.example.backend.users.model.UserEntity;
|
||||
|
||||
public class UserPrincipal implements UserDetails {
|
||||
private final long id;
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final Set<? extends GrantedAuthority> roles;
|
||||
private final boolean active;
|
||||
|
||||
public UserPrincipal(UserEntity user) {
|
||||
this.id = user.getId();
|
||||
this.username = user.getLogin();
|
||||
this.password = user.getPassword();
|
||||
this.roles = Set.of(user.getRole());
|
||||
this.active = true;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
return isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonLocked() {
|
||||
return isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return isEnabled();
|
||||
}
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
package com.example.backend.favorites.api;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.springframework.ui.Model;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.example.backend.core.configurations.Constants;
|
||||
import com.example.backend.favorites.model.FavoriteEntity;
|
||||
import com.example.backend.favorites.service.FavoriteService;
|
||||
import com.example.backend.movies.api.MovieDTO;
|
||||
import com.example.backend.movies.api.MovieUserDTO;
|
||||
import com.example.backend.movies.model.MovieEntity;
|
||||
import com.example.backend.movies.service.MovieService;
|
||||
import com.example.backend.users.model.UserEntity;
|
||||
import com.example.backend.users.service.UserService;
|
||||
import com.example.backend.viewed.model.ViewedEntity;
|
||||
import com.example.backend.viewed.service.ViewedService;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(FavoriteController.URL)
|
||||
public class FavoriteController {
|
||||
|
||||
public static final String URL = "/favs";
|
||||
private static final String FAVORITE_VIEW = "favs";
|
||||
private static final String PAGE_ATTRIBUTE = "page";
|
||||
|
||||
private final FavoriteService favoriteService;
|
||||
private final UserService userService;
|
||||
private final MovieService movieService;
|
||||
private final ModelMapper modelMapper;
|
||||
private final ViewedService viewedServise;
|
||||
|
||||
public FavoriteController(FavoriteService favoriteService, UserService userService,
|
||||
MovieService movieService, ModelMapper modelMapper, ViewedService viewedServise) {
|
||||
this.modelMapper = modelMapper;
|
||||
this.userService = userService;
|
||||
this.favoriteService = favoriteService;
|
||||
this.viewedServise = viewedServise;
|
||||
this.movieService = movieService;
|
||||
}
|
||||
|
||||
private MovieDTO toDtoMovie(MovieEntity entity) {
|
||||
return modelMapper.map(entity, MovieDTO.class);
|
||||
}
|
||||
|
||||
private List<MovieUserDTO> getListMovieUserDTOs(Integer categorieId, int page) {
|
||||
List<MovieDTO> movies = movieService.getAll(categorieId, page, Constants.DEFUALT_PAGE_SIZE)
|
||||
.stream()
|
||||
.map(this::toDtoMovie)
|
||||
.toList();
|
||||
List<MovieUserDTO> muDTO = new ArrayList<MovieUserDTO>();
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
Integer currentUserId = userService.getCurrentUserId(authentication.getName());
|
||||
|
||||
List<FavoriteEntity> favs = favoriteService.getAll(currentUserId);
|
||||
List<ViewedEntity> viewes = viewedServise.getAll(currentUserId);
|
||||
|
||||
for (MovieDTO movieDTO : movies) {
|
||||
MovieUserDTO newMovDto = new MovieUserDTO();
|
||||
newMovDto.setMovieDTO(movieDTO);
|
||||
newMovDto.setCountViewes(movieService.countView(movieDTO.getId()));
|
||||
|
||||
for (FavoriteEntity favoriteEntity : favs) {
|
||||
if ((int) favoriteEntity.getMovie().getId() == (int) movieDTO.getId()) {
|
||||
newMovDto.setFavorite(true);
|
||||
break;
|
||||
}
|
||||
newMovDto.setFavorite(false);
|
||||
}
|
||||
|
||||
for (ViewedEntity viewedEntity : viewes) {
|
||||
if ((int) viewedEntity.getMovie().getId() == (int) movieDTO.getId()) {
|
||||
newMovDto.setViewed(true);
|
||||
break;
|
||||
}
|
||||
newMovDto.setViewed(false);
|
||||
}
|
||||
|
||||
muDTO.add(newMovDto);
|
||||
}
|
||||
return muDTO;
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
public String getAll(Model model, @RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page) {
|
||||
List<MovieUserDTO> muDTO = getListMovieUserDTOs(0, page);
|
||||
model.addAttribute("movies", muDTO);
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
return FAVORITE_VIEW;
|
||||
}
|
||||
|
||||
@PostMapping("/changeFavStatus/{id}")
|
||||
public String changeFavStatus(@PathVariable(name = "id") Integer movieId,
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
Model model) {
|
||||
|
||||
boolean isFavorite = false;
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
Integer currentUserId = userService.getCurrentUserId(authentication.getName());
|
||||
|
||||
FavoriteEntity fav = favoriteService.findByUserIdAndMovieId(currentUserId, movieId);
|
||||
|
||||
if (fav == null) {
|
||||
isFavorite = false;
|
||||
} else {
|
||||
isFavorite = true;
|
||||
}
|
||||
|
||||
if (isFavorite == false) {
|
||||
|
||||
UserEntity user = userService.get(currentUserId);
|
||||
MovieEntity movie = movieService.get(movieId);
|
||||
|
||||
FavoriteEntity newFav = new FavoriteEntity(null, user, movie);
|
||||
|
||||
favoriteService.create(newFav);
|
||||
|
||||
} else {
|
||||
|
||||
FavoriteEntity delFav = favoriteService.findByUserIdAndMovieId(currentUserId, movieId);
|
||||
|
||||
favoriteService.delete(delFav.getId());
|
||||
}
|
||||
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
|
||||
@PostMapping("/changeViewStatus/{id}")
|
||||
public String changeViewStatus(@PathVariable(name = "id") Integer movieId,
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
Model model) {
|
||||
|
||||
boolean isViewed = false;
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
Integer currentUserId = userService.getCurrentUserId(authentication.getName());
|
||||
|
||||
ViewedEntity view = viewedServise.findByUserIdAndMovieId(currentUserId, movieId);
|
||||
|
||||
if (view == null) {
|
||||
isViewed = false;
|
||||
} else {
|
||||
isViewed = true;
|
||||
}
|
||||
|
||||
if (isViewed == false) {
|
||||
|
||||
UserEntity user = userService.get(currentUserId);
|
||||
MovieEntity movie = movieService.get(movieId);
|
||||
|
||||
ViewedEntity newView = new ViewedEntity(null, user, movie);
|
||||
|
||||
viewedServise.create(newView);
|
||||
|
||||
} else {
|
||||
|
||||
ViewedEntity delView = viewedServise.findByUserIdAndMovieId(currentUserId, movieId);
|
||||
|
||||
viewedServise.delete(delView.getId());
|
||||
}
|
||||
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.example.backend.favorites.api;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public class FavoriteDto {
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Integer id;
|
||||
|
||||
@NotNull
|
||||
@Min(1)
|
||||
private Integer userId;
|
||||
|
||||
@NotNull
|
||||
@Min(1)
|
||||
private Integer movieId;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Integer getMovieId() {
|
||||
return movieId;
|
||||
}
|
||||
|
||||
public void setMovieId(Integer movieId) {
|
||||
this.movieId = movieId;
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.example.backend.favorites.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.example.backend.core.model.BaseEntity;
|
||||
import com.example.backend.movies.model.MovieEntity;
|
||||
import com.example.backend.users.model.UserEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "favorites")
|
||||
public class FavoriteEntity extends BaseEntity {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "userId", nullable = false)
|
||||
private UserEntity user;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "movieId", nullable = false)
|
||||
private MovieEntity movie;
|
||||
|
||||
public FavoriteEntity() {
|
||||
super();
|
||||
}
|
||||
|
||||
public FavoriteEntity(Integer id, UserEntity user, MovieEntity movie) {
|
||||
this.user = user;
|
||||
this.movie = movie;
|
||||
}
|
||||
|
||||
public UserEntity getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(UserEntity user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public MovieEntity getMovie() {
|
||||
return movie;
|
||||
}
|
||||
|
||||
public void setMovie(MovieEntity movie) {
|
||||
this.movie = movie;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, user, movie);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
final FavoriteEntity other = (FavoriteEntity) obj;
|
||||
return Objects.equals(other.getId(), id)
|
||||
&& Objects.equals(other.getUser(), user)
|
||||
&& Objects.equals(other.getMovie(), movie);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.example.backend.favorites.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.List;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
|
||||
import com.example.backend.favorites.model.FavoriteEntity;
|
||||
|
||||
public interface FavoriteRepository
|
||||
extends CrudRepository<FavoriteEntity, Integer>, PagingAndSortingRepository<FavoriteEntity, Integer> {
|
||||
|
||||
List<FavoriteEntity> findByUserId(Integer userId);
|
||||
|
||||
FavoriteEntity findByUserIdAndMovieId(Integer userId, Integer movieId);
|
||||
|
||||
Optional<FavoriteEntity> findOneByUserIdAndId(Integer userId, Integer id);
|
||||
|
||||
Optional<FavoriteEntity> deleteByMovieId(Integer movieId);
|
||||
|
||||
Optional<FavoriteEntity> deleteByUserId(Integer user);
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.example.backend.favorites.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.backend.core.errors.NotFoundException;
|
||||
import com.example.backend.favorites.model.FavoriteEntity;
|
||||
import com.example.backend.favorites.repository.FavoriteRepository;
|
||||
|
||||
@Service
|
||||
public class FavoriteService {
|
||||
private final FavoriteRepository repository;
|
||||
|
||||
public FavoriteService(FavoriteRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<FavoriteEntity> getAll(Integer userId) {
|
||||
if (userId == 0) {
|
||||
return StreamSupport.stream(repository.findAll().spliterator(), false).toList();
|
||||
}
|
||||
return repository.findByUserId(userId);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Page<FavoriteEntity> getAll(int page, int size) {
|
||||
return repository.findAll(PageRequest.of(page, size, Sort.by("id")));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public FavoriteEntity get(Integer id) {
|
||||
return repository.findById(id).orElseThrow(() -> new NotFoundException(FavoriteEntity.class, id));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public FavoriteEntity findByUserIdAndMovieId(Integer uId, Integer mId) {
|
||||
return repository.findByUserIdAndMovieId(uId, mId);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public FavoriteEntity create(FavoriteEntity entity) {
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public FavoriteEntity update(Integer id, FavoriteEntity entity) {
|
||||
final FavoriteEntity exisEntity = get(id);
|
||||
exisEntity.setUser(entity.getUser());
|
||||
exisEntity.setMovie(entity.getMovie());
|
||||
return repository.save(exisEntity);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public FavoriteEntity delete(Integer id) {
|
||||
final FavoriteEntity exisEntity = get(id);
|
||||
repository.delete(exisEntity);
|
||||
return exisEntity;
|
||||
}
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
package com.example.backend.movies.api;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.example.backend.categories.service.CategorieService;
|
||||
import com.example.backend.core.api.PageAttributesMapper;
|
||||
import com.example.backend.core.configurations.Constants;
|
||||
import com.example.backend.movies.model.MovieEntity;
|
||||
import com.example.backend.movies.service.MovieService;
|
||||
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(MovieController.URL)
|
||||
public class MovieController {
|
||||
|
||||
public static final String URL = Constants.ADMIN_PREFIX + "/movies";
|
||||
private static final String MOVIE_VIEW = "movies";
|
||||
private static final String MOVIE_EDIT_VIEW = "movie-edit";
|
||||
private static final String PAGE_ATTRIBUTE = "page";
|
||||
private static final String MOVIE_ATTRIBUTE = "movie";
|
||||
private static final String CATEGORIEID_ATTRIBUTE = "categorieId";
|
||||
|
||||
private final MovieService movieService;
|
||||
private final CategorieService categorieService;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
public MovieController(MovieService movieService, CategorieService categorieService, ModelMapper modelMapper) {
|
||||
this.modelMapper = modelMapper;
|
||||
this.categorieService = categorieService;
|
||||
this.movieService = movieService;
|
||||
}
|
||||
|
||||
private MovieDTO toDto(MovieEntity entity) {
|
||||
return modelMapper.map(entity, MovieDTO.class);
|
||||
}
|
||||
|
||||
private MovieEntity toEntity(MovieDTO dto) {
|
||||
final MovieEntity entity = modelMapper.map(dto, MovieEntity.class);
|
||||
entity.setCategorie(categorieService.get(dto.getCategorieId()));
|
||||
return entity;
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
public String getAll(@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
Model model) {
|
||||
|
||||
final Map<String, Object> attributes = PageAttributesMapper.toAttributes(
|
||||
movieService.getAll(0, page, Constants.DEFUALT_PAGE_SIZE), this::toDto);
|
||||
model.addAllAttributes(attributes);
|
||||
|
||||
model.addAttribute("categories", categorieService.getAll());
|
||||
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
model.addAttribute(CATEGORIEID_ATTRIBUTE, 0);
|
||||
return MOVIE_VIEW;
|
||||
}
|
||||
|
||||
@GetMapping("/categorieId/{id}")
|
||||
public String getAll(@PathVariable(name = "id") Integer categorieId,
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
Model model) {
|
||||
final Map<String, Object> attributes = PageAttributesMapper.toAttributes(
|
||||
movieService.getAll(categorieId, page, Constants.DEFUALT_PAGE_SIZE), this::toDto);
|
||||
model.addAllAttributes(attributes);
|
||||
model.addAttribute("categories", categorieService.getAll());
|
||||
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
model.addAttribute(CATEGORIEID_ATTRIBUTE, categorieId);
|
||||
return MOVIE_VIEW;
|
||||
}
|
||||
|
||||
@GetMapping("/edit/")
|
||||
public String create(@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page, Model model) {
|
||||
model.addAttribute("categories", categorieService.getAll());
|
||||
model.addAttribute(MOVIE_ATTRIBUTE, new MovieDTO());
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
return MOVIE_EDIT_VIEW;
|
||||
}
|
||||
|
||||
@PostMapping("/edit/")
|
||||
public String create(@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
@ModelAttribute(name = MOVIE_ATTRIBUTE) @Valid MovieDTO movieDTO,
|
||||
BindingResult bindingResult, Model model, RedirectAttributes redirectAttributes) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
return MOVIE_EDIT_VIEW;
|
||||
}
|
||||
model.addAttribute("categories", categorieService.getAll());
|
||||
model.addAttribute(CATEGORIEID_ATTRIBUTE, 0);
|
||||
redirectAttributes.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
movieService.create(toEntity(movieDTO));
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
|
||||
@GetMapping("/edit/{id}")
|
||||
public String update(@PathVariable(name = "id") Integer id,
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page, Model model) {
|
||||
if (id <= 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
model.addAttribute("categories", categorieService.getAll());
|
||||
model.addAttribute(MOVIE_ATTRIBUTE, toDto(movieService.get(id)));
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
return MOVIE_EDIT_VIEW;
|
||||
}
|
||||
|
||||
@PostMapping("/edit/{id}")
|
||||
public String update(@PathVariable(name = "id") Integer id,
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
@ModelAttribute(name = MOVIE_ATTRIBUTE) @Valid MovieDTO movieDTO,
|
||||
BindingResult bindingResult, Model model, RedirectAttributes redirectAttributes) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
return MOVIE_EDIT_VIEW;
|
||||
}
|
||||
if (id <= 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
redirectAttributes.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
movieService.update(id, toEntity(movieDTO));
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{id}")
|
||||
public String delete(@PathVariable(name = "id") Integer id,
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
redirectAttributes.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
movieService.delete(id);
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
|
||||
@GetMapping("/countView")
|
||||
public Integer countView(@RequestParam(name = "movieId", defaultValue = "0") Integer movieId) {
|
||||
return movieService.countView(movieId);
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package com.example.backend.movies.api;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public class MovieDTO {
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Integer id;
|
||||
|
||||
@NotNull
|
||||
@Min(1)
|
||||
private Integer categorieId;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 2, max = 50)
|
||||
private String name;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 2, max = 50)
|
||||
private String description;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 2, max = 50)
|
||||
private String duration;
|
||||
|
||||
private String image;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getCategorieId() {
|
||||
return categorieId;
|
||||
}
|
||||
|
||||
public void setCategorieId(Integer categorieId) {
|
||||
this.categorieId = categorieId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(String duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
}
|
@ -0,0 +1,237 @@
|
||||
package com.example.backend.movies.api;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.example.backend.categories.service.CategorieService;
|
||||
import com.example.backend.core.configurations.Constants;
|
||||
import com.example.backend.favorites.model.FavoriteEntity;
|
||||
import com.example.backend.favorites.service.FavoriteService;
|
||||
import com.example.backend.movies.model.MovieEntity;
|
||||
import com.example.backend.movies.service.MovieService;
|
||||
import com.example.backend.users.model.UserEntity;
|
||||
import com.example.backend.users.service.UserService;
|
||||
import com.example.backend.viewed.model.ViewedEntity;
|
||||
import com.example.backend.viewed.service.ViewedService;
|
||||
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import com.example.backend.core.api.PageAttributesMapper;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(MovieUserController.URL)
|
||||
public class MovieUserController {
|
||||
|
||||
public static final String URL = "/movies";
|
||||
private static final String MOVIE_VIEW = "movies";
|
||||
private static final String PAGE_ATTRIBUTE = "page";
|
||||
private static final String CATEGORIEID_ATTRIBUTE = "categorieId";
|
||||
|
||||
private final MovieService movieService;
|
||||
private final CategorieService categorieService;
|
||||
private final UserService userService;
|
||||
private final FavoriteService favoriteService;
|
||||
private final ViewedService viewedServise;
|
||||
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
public MovieUserController(MovieService movieService,
|
||||
CategorieService categorieService,
|
||||
ModelMapper modelMapper,
|
||||
UserService userService,
|
||||
FavoriteService favoriteService,
|
||||
ViewedService viewedServise) {
|
||||
this.modelMapper = modelMapper;
|
||||
this.categorieService = categorieService;
|
||||
this.movieService = movieService;
|
||||
this.userService = userService;
|
||||
this.favoriteService = favoriteService;
|
||||
this.viewedServise = viewedServise;
|
||||
}
|
||||
|
||||
private MovieDTO toDto(MovieEntity entity) {
|
||||
return modelMapper.map(entity, MovieDTO.class);
|
||||
}
|
||||
|
||||
private MovieUserDTO toMovieUserDto(MovieEntity entity) {
|
||||
return modelMapper.map(entity, MovieUserDTO.class);
|
||||
}
|
||||
|
||||
private List<MovieUserDTO> getListMovieUserDTOs(Integer categorieId, int page) {
|
||||
List<MovieDTO> movies = movieService.getAll(categorieId, page, Constants.DEFUALT_PAGE_SIZE)
|
||||
.stream()
|
||||
.map(this::toDto)
|
||||
.toList();
|
||||
List<MovieUserDTO> muDTO = new ArrayList<MovieUserDTO>();
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
Integer currentUserId = userService.getCurrentUserId(authentication.getName());
|
||||
|
||||
List<FavoriteEntity> favs = favoriteService.getAll(currentUserId);
|
||||
List<ViewedEntity> viewes = viewedServise.getAll(currentUserId);
|
||||
|
||||
for (MovieDTO movieDTO : movies) {
|
||||
MovieUserDTO newMovDto = new MovieUserDTO();
|
||||
newMovDto.setMovieDTO(movieDTO);
|
||||
newMovDto.setCountViewes(movieService.countView(movieDTO.getId()));
|
||||
|
||||
for (FavoriteEntity favoriteEntity : favs) {
|
||||
if ((int) favoriteEntity.getMovie().getId() == (int) movieDTO.getId()) {
|
||||
newMovDto.setFavorite(true);
|
||||
break;
|
||||
}
|
||||
newMovDto.setFavorite(false);
|
||||
}
|
||||
|
||||
for (ViewedEntity viewedEntity : viewes) {
|
||||
if ((int) viewedEntity.getMovie().getId() == (int) movieDTO.getId()) {
|
||||
newMovDto.setViewed(true);
|
||||
break;
|
||||
}
|
||||
newMovDto.setViewed(false);
|
||||
}
|
||||
|
||||
muDTO.add(newMovDto);
|
||||
}
|
||||
return muDTO;
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
public String getAll(@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
Model model) {
|
||||
List<MovieUserDTO> muDTO = getListMovieUserDTOs(0, page);
|
||||
model.addAttribute("movies", muDTO);
|
||||
model.addAttribute(CATEGORIEID_ATTRIBUTE, model);
|
||||
model.addAttribute("categories", categorieService.getAll());
|
||||
|
||||
final Map<String, Object> attributes = PageAttributesMapper.toAttributes(
|
||||
movieService.getAll(0, page, Constants.DEFUALT_PAGE_SIZE), this::toMovieUserDto);
|
||||
model.addAllAttributes(attributes);
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
model.addAttribute(CATEGORIEID_ATTRIBUTE, 0);
|
||||
return MOVIE_VIEW;
|
||||
}
|
||||
|
||||
@GetMapping("/categorieId/{id}")
|
||||
public String getAll(@PathVariable(name = "id") Integer categorieId,
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
Model model) {
|
||||
List<MovieUserDTO> muDTO = getListMovieUserDTOs(categorieId, page);
|
||||
|
||||
model.addAttribute("movies", muDTO);
|
||||
model.addAttribute("categories", categorieService.getAll());
|
||||
|
||||
final Map<String, Object> attributes = PageAttributesMapper.toAttributes(
|
||||
movieService.getAll(categorieId, page, Constants.DEFUALT_PAGE_SIZE), this::toMovieUserDto);
|
||||
model.addAllAttributes(attributes);
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
model.addAttribute(CATEGORIEID_ATTRIBUTE, categorieId);
|
||||
|
||||
return MOVIE_VIEW;
|
||||
}
|
||||
|
||||
@PostMapping("/changeFavStatus/{id}")
|
||||
public String changeFavStatus(@PathVariable(name = "id") Integer movieId,
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
RedirectAttributes redirectAttributes,
|
||||
Model model) {
|
||||
|
||||
boolean isFavorite = false;
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
Integer currentUserId = userService.getCurrentUserId(authentication.getName());
|
||||
|
||||
FavoriteEntity fav = favoriteService.findByUserIdAndMovieId(currentUserId, movieId);
|
||||
|
||||
if (fav == null) {
|
||||
isFavorite = false;
|
||||
} else {
|
||||
isFavorite = true;
|
||||
}
|
||||
|
||||
if (isFavorite == false) {
|
||||
|
||||
UserEntity user = userService.get(currentUserId);
|
||||
MovieEntity movie = movieService.get(movieId);
|
||||
|
||||
FavoriteEntity newFav = new FavoriteEntity(null, user, movie);
|
||||
|
||||
favoriteService.create(newFav);
|
||||
|
||||
} else {
|
||||
|
||||
FavoriteEntity delFav = favoriteService.findByUserIdAndMovieId(currentUserId, movieId);
|
||||
|
||||
favoriteService.delete(delFav.getId());
|
||||
}
|
||||
|
||||
redirectAttributes.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
|
||||
@PostMapping("/changeViewStatus/{id}")
|
||||
public String changeViewStatus(@PathVariable(name = "id") Integer movieId,
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
RedirectAttributes redirectAttributes,
|
||||
Model model) {
|
||||
|
||||
boolean isViewed = false;
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
Integer currentUserId = userService.getCurrentUserId(authentication.getName());
|
||||
|
||||
ViewedEntity view = viewedServise.findByUserIdAndMovieId(currentUserId, movieId);
|
||||
|
||||
if (view == null) {
|
||||
isViewed = false;
|
||||
} else {
|
||||
isViewed = true;
|
||||
}
|
||||
|
||||
if (isViewed == false) {
|
||||
|
||||
UserEntity user = userService.get(currentUserId);
|
||||
MovieEntity movie = movieService.get(movieId);
|
||||
|
||||
ViewedEntity newView = new ViewedEntity(null, user, movie);
|
||||
|
||||
viewedServise.create(newView);
|
||||
|
||||
} else {
|
||||
|
||||
ViewedEntity delView = viewedServise.findByUserIdAndMovieId(currentUserId, movieId);
|
||||
|
||||
viewedServise.delete(delView.getId());
|
||||
}
|
||||
|
||||
redirectAttributes.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
|
||||
@GetMapping("/card/{id}")
|
||||
public String getCardFilm(@PathVariable(name = "id") Integer movieId, Model model) {
|
||||
int countView = movieService.countView(movieId);
|
||||
MovieEntity movie = movieService.get(movieId);
|
||||
model.addAttribute("movie", movie);
|
||||
model.addAttribute("countView", countView); // Изменено на countView
|
||||
return "card-film";
|
||||
}
|
||||
|
||||
@GetMapping("/countView")
|
||||
public Integer countView(@RequestParam(name = "movieId", defaultValue = "0") Integer movieId) {
|
||||
return movieService.countView(movieId);
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.example.backend.movies.api;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public class MovieUserDTO {
|
||||
|
||||
MovieDTO movieDTO;
|
||||
|
||||
@NotBlank
|
||||
private boolean isFavorite;
|
||||
|
||||
@NotBlank
|
||||
private boolean isViewed;
|
||||
|
||||
private Integer countViewes;
|
||||
|
||||
public Integer getCountViewes() {
|
||||
return countViewes;
|
||||
}
|
||||
|
||||
public void setCountViewes(Integer countViewes) {
|
||||
this.countViewes = countViewes;
|
||||
}
|
||||
|
||||
public MovieDTO getMovieDTO() {
|
||||
return movieDTO;
|
||||
}
|
||||
|
||||
public void setMovieDTO(MovieDTO movieDTO) {
|
||||
this.movieDTO = movieDTO;
|
||||
}
|
||||
|
||||
public boolean isFavorite() {
|
||||
return isFavorite;
|
||||
}
|
||||
|
||||
public void setFavorite(boolean isFavorite) {
|
||||
this.isFavorite = isFavorite;
|
||||
}
|
||||
|
||||
public boolean isViewed() {
|
||||
return isViewed;
|
||||
}
|
||||
|
||||
public void setViewed(boolean isViewed) {
|
||||
this.isViewed = isViewed;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
package com.example.backend.movies.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.example.backend.categories.model.CategorieEntity;
|
||||
import com.example.backend.core.model.BaseEntity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.persistence.Transient;
|
||||
|
||||
@Entity
|
||||
@Table(name = "movies")
|
||||
public class MovieEntity extends BaseEntity {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "categorieId", nullable = false)
|
||||
private CategorieEntity categorie;
|
||||
|
||||
@Column(nullable = false, length = 50)
|
||||
private String name;
|
||||
|
||||
@Column(length = 300)
|
||||
private String description;
|
||||
|
||||
@Column(length = 50)
|
||||
private String duration;
|
||||
|
||||
@Column(nullable = true)
|
||||
private String image;
|
||||
|
||||
@Transient
|
||||
private boolean isFavorite;
|
||||
|
||||
public boolean isFavorite() {
|
||||
return isFavorite;
|
||||
}
|
||||
|
||||
public void setFavorite(boolean isFavorite) {
|
||||
this.isFavorite = isFavorite;
|
||||
}
|
||||
|
||||
public MovieEntity() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MovieEntity(Integer id, CategorieEntity categorie, String name, String description, String duration,
|
||||
String image) {
|
||||
|
||||
this.categorie = categorie;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.duration = duration;
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public MovieEntity(MovieEntity entity, boolean isFavorite) {
|
||||
this(entity.id, entity.categorie, entity.description, entity.duration, entity.image, entity.name);
|
||||
this.isFavorite = isFavorite;
|
||||
}
|
||||
|
||||
public CategorieEntity getCategorie() {
|
||||
return categorie;
|
||||
}
|
||||
|
||||
public void setCategorie(CategorieEntity categorie) {
|
||||
this.categorie = categorie;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(String duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, categorie, name, description, duration, image);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
final MovieEntity other = (MovieEntity) obj;
|
||||
return Objects.equals(other.getId(), id)
|
||||
&& Objects.equals(other.getCategorie(), categorie)
|
||||
&& Objects.equals(other.getName(), name)
|
||||
&& Objects.equals(other.getDescription(), description)
|
||||
&& Objects.equals(other.getDuration(), duration)
|
||||
&& Objects.equals(other.getImage(), image);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.example.backend.movies.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import com.example.backend.movies.model.MovieEntity;
|
||||
|
||||
public interface MovieRepository
|
||||
extends CrudRepository<MovieEntity, Integer>, PagingAndSortingRepository<MovieEntity, Integer> {
|
||||
|
||||
Optional<MovieEntity> findByNameIgnoreCase(String name);
|
||||
|
||||
Optional<MovieEntity> findByCategorieIdAndId(Integer categorieId, Integer id);
|
||||
|
||||
Page<MovieEntity> findByCategorieId(Integer categorieId, Pageable page);
|
||||
|
||||
List<MovieEntity> findByCategorieId(Integer categorieId);
|
||||
|
||||
Optional<MovieEntity> deleteByCategorieId(Integer categorieId);
|
||||
|
||||
// @Query("")
|
||||
|
||||
@Query("SELECT COUNT(DISTINCT v.user.id) FROM ViewedEntity v WHERE v.movie.id = :movieId")
|
||||
Integer getCountViews(@Param("movieId") Integer movieId);
|
||||
|
||||
@Query("select new (com.example.backend.movies.model.MovieEntity(m, (case when f.user.id = :userId then true else false end))) from MovieEntity m left join FavoriteEntity f on m.id=f.movie.id")
|
||||
List<MovieEntity> getAndSetFavoriteMovies(@Param("userId") Integer userId);
|
||||
|
||||
// select u.id, u.username,u.name,u.surname,(case when s.SUBSCRIBER_ID=1 then
|
||||
// true else false end)as"subscribed"
|
||||
// from USERS u left join SUBSCRIBES s on u.id=s.user_id;
|
||||
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package com.example.backend.movies.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import com.example.backend.core.errors.NotFoundException;
|
||||
import com.example.backend.favorites.repository.FavoriteRepository;
|
||||
import com.example.backend.movies.model.MovieEntity;
|
||||
import com.example.backend.movies.repository.MovieRepository;
|
||||
import com.example.backend.viewed.repository.ViewedRepository;
|
||||
|
||||
@Service
|
||||
public class MovieService {
|
||||
|
||||
private final MovieRepository repository;
|
||||
private final FavoriteRepository favoriteRepository;
|
||||
private final ViewedRepository viewedRepository;
|
||||
|
||||
public MovieService(MovieRepository repository, FavoriteRepository favoriteRepository,
|
||||
ViewedRepository viewedRepository) {
|
||||
this.repository = repository;
|
||||
this.favoriteRepository = favoriteRepository;
|
||||
this.viewedRepository = viewedRepository;
|
||||
}
|
||||
|
||||
private void checkName(String name) {
|
||||
if (repository.findByNameIgnoreCase(name).isPresent()) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Type with name %s is already exists", name));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Page<MovieEntity> getAll(Integer categorieId, int page, int size) {
|
||||
if (categorieId < 0) {
|
||||
throw new IllegalArgumentException(String.format("This %d id is not found", categorieId));
|
||||
}
|
||||
if (categorieId == 0) {
|
||||
return repository.findAll(PageRequest.of(page, size, Sort.by("id")));
|
||||
}
|
||||
return repository.findByCategorieId(categorieId, PageRequest.of(page, size, Sort.by("id")));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<MovieEntity> getAll(Integer categorieId) {
|
||||
if (categorieId < 0) {
|
||||
throw new IllegalArgumentException(String.format("This %d id is not found", categorieId));
|
||||
}
|
||||
if (categorieId == 0) {
|
||||
return StreamSupport.stream(repository.findAll().spliterator(), false).toList();
|
||||
}
|
||||
return repository.findByCategorieId(categorieId);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public MovieEntity get(Integer id) {
|
||||
return repository.findById(id).orElseThrow(() -> new NotFoundException(MovieEntity.class, id));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public MovieEntity create(MovieEntity entity) {
|
||||
if (entity == null) {
|
||||
throw new IllegalArgumentException("Сущность не найдена");
|
||||
}
|
||||
checkName(entity.getName());
|
||||
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public MovieEntity update(Integer id, MovieEntity entity) {
|
||||
final MovieEntity exisEntity = get(id);
|
||||
exisEntity.setCategorie(entity.getCategorie());
|
||||
exisEntity.setName(entity.getName());
|
||||
exisEntity.setDescription(entity.getDescription());
|
||||
exisEntity.setDuration(entity.getDuration());
|
||||
exisEntity.setImage(entity.getImage());
|
||||
repository.save(exisEntity);
|
||||
return exisEntity;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public MovieEntity delete(Integer id) {
|
||||
final MovieEntity exisEntity = get(id);
|
||||
favoriteRepository.deleteByMovieId(exisEntity.getId());
|
||||
viewedRepository.deleteByMovieId(exisEntity.getId());
|
||||
|
||||
repository.delete(exisEntity);
|
||||
return exisEntity;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Integer countView(Integer movieId) {
|
||||
|
||||
return repository.getCountViews(movieId);
|
||||
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<MovieEntity> setAndGetFavorites(Integer userId) {
|
||||
return repository.getAndSetFavoriteMovies(userId);
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
package com.example.backend.users.api;
|
||||
|
||||
import java.util.Map;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.example.backend.core.api.PageAttributesMapper;
|
||||
import com.example.backend.core.configurations.Constants;
|
||||
import com.example.backend.users.model.UserEntity;
|
||||
import com.example.backend.users.service.UserService;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(UserController.URL)
|
||||
public class UserController {
|
||||
|
||||
public static final String URL = Constants.ADMIN_PREFIX + "/user";
|
||||
private static final String USER_VIEW = "user";
|
||||
private static final String USER_EDIT_VIEW = "user-edit";
|
||||
private static final String PAGE_ATTRIBUTE = "page";
|
||||
private static final String USER_ATTRIBUTE = "user";
|
||||
|
||||
private final UserService userService;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
public UserController(UserService userService, ModelMapper modelMapper) {
|
||||
this.modelMapper = modelMapper;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
private UserEntity toEntity(UserDTO dto) {
|
||||
return modelMapper.map(dto, UserEntity.class);
|
||||
}
|
||||
|
||||
private UserDTO toDto(UserEntity entity) {
|
||||
return modelMapper.map(entity, UserDTO.class);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public String getAll(
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
Model model) {
|
||||
final Map<String, Object> attributes = PageAttributesMapper.toAttributes(
|
||||
userService.getAll(page, Constants.DEFUALT_PAGE_SIZE), this::toDto);
|
||||
model.addAllAttributes(attributes);
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
return USER_VIEW;
|
||||
}
|
||||
|
||||
@GetMapping("/edit/")
|
||||
public String create(@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
Model model) {
|
||||
model.addAttribute(USER_ATTRIBUTE, new UserDTO());
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
return USER_EDIT_VIEW;
|
||||
}
|
||||
|
||||
@PostMapping("/edit/")
|
||||
public String create(
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
@ModelAttribute(name = USER_ATTRIBUTE) @Valid UserDTO user,
|
||||
BindingResult bindingResult,
|
||||
Model model,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
return USER_EDIT_VIEW;
|
||||
}
|
||||
redirectAttributes.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
userService.create(toEntity(user));
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
|
||||
@GetMapping("/edit/{id}")
|
||||
public String update(
|
||||
@PathVariable(name = "id") Integer id,
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
Model model) {
|
||||
if (id <= 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
model.addAttribute(USER_ATTRIBUTE, toDto(userService.get(id)));
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
return USER_EDIT_VIEW;
|
||||
}
|
||||
|
||||
@PostMapping("/edit/{id}")
|
||||
public String update(
|
||||
@PathVariable(name = "id") Integer id,
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
@ModelAttribute(name = USER_ATTRIBUTE) @Valid UserDTO user,
|
||||
BindingResult bindingResult,
|
||||
Model model,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
return USER_EDIT_VIEW;
|
||||
}
|
||||
if (id <= 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
redirectAttributes.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
userService.update(id, toEntity(user));
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{id}")
|
||||
public String delete(
|
||||
@PathVariable(name = "id") Integer id,
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
redirectAttributes.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
userService.delete(id);
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package com.example.backend.users.api;
|
||||
|
||||
import com.example.backend.users.model.UserRole;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public class UserDTO {
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Integer id;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 2, max = 90)
|
||||
private String login;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 2, max = 90)
|
||||
private String password;
|
||||
|
||||
@NotNull
|
||||
private UserRole role;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public UserRole getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(UserRole role) {
|
||||
this.role = role;
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.example.backend.users.api;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.example.backend.core.configurations.Constants;
|
||||
import com.example.backend.users.model.UserEntity;
|
||||
import com.example.backend.users.model.UserRole;
|
||||
import com.example.backend.users.service.UserService;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(UserSignupController.URL)
|
||||
public class UserSignupController {
|
||||
public static final String URL = "/signup";
|
||||
|
||||
private static final String SIGNUP_VIEW = "signup";
|
||||
private static final String USER_ATTRIBUTE = "user";
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
public UserSignupController(
|
||||
UserService userService,
|
||||
ModelMapper modelMapper) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
private UserEntity toEntity(UserSignupDTO dto) {
|
||||
final UserEntity entity = new UserEntity();
|
||||
entity.setLogin(dto.getLogin());
|
||||
entity.setPassword(dto.getPassword());
|
||||
entity.setRole(dto.getIsAdmin() ? UserRole.ADMIN : UserRole.USER);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public String getSignup(Model model) {
|
||||
model.addAttribute(USER_ATTRIBUTE, new UserSignupDTO());
|
||||
return SIGNUP_VIEW;
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public String signup(
|
||||
@ModelAttribute(name = USER_ATTRIBUTE) @Valid UserSignupDTO user,
|
||||
BindingResult bindingResult,
|
||||
Model model) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return SIGNUP_VIEW;
|
||||
}
|
||||
if (!Objects.equals(user.getPassword(), user.getPasswordConfirm())) {
|
||||
bindingResult.rejectValue("password", "signup:passwords", "Пароли не совпадают.");
|
||||
model.addAttribute(USER_ATTRIBUTE, user);
|
||||
return SIGNUP_VIEW;
|
||||
}
|
||||
userService.create(toEntity(user));
|
||||
return Constants.REDIRECT_VIEW + Constants.LOGIN_URL + "?signup";
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.example.backend.users.api;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public class UserSignupDTO {
|
||||
@NotBlank
|
||||
@Size(min = 3, max = 100)
|
||||
private String login;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 3, max = 90)
|
||||
private String password;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 3, max = 90)
|
||||
private String passwordConfirm;
|
||||
|
||||
private boolean isAdmin; // Новое поле для определения роли пользователя
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPasswordConfirm() {
|
||||
return passwordConfirm;
|
||||
}
|
||||
|
||||
public void setPasswordConfirm(String passwordConfirm) {
|
||||
this.passwordConfirm = passwordConfirm;
|
||||
}
|
||||
|
||||
public boolean getIsAdmin() {
|
||||
return isAdmin;
|
||||
}
|
||||
|
||||
public void setIsAdmin(boolean isAdmin) {
|
||||
this.isAdmin = isAdmin;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package com.example.backend.users.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.example.backend.core.model.BaseEntity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
public class UserEntity extends BaseEntity {
|
||||
|
||||
@Column(nullable = false, unique = true, length = 90)
|
||||
private String login;
|
||||
|
||||
@Column(nullable = false, length = 90)
|
||||
private String password;
|
||||
|
||||
private UserRole role;
|
||||
|
||||
public UserEntity() {
|
||||
|
||||
}
|
||||
|
||||
public UserEntity(Integer id, String login, String password) {
|
||||
this.login = login;
|
||||
this.password = password;
|
||||
this.role = UserRole.USER;
|
||||
}
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public UserRole getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(UserRole role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, login, password, role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
final UserEntity other = (UserEntity) obj;
|
||||
return Objects.equals(other.getId(), id) &&
|
||||
Objects.equals(other.getLogin(), login) &&
|
||||
Objects.equals(other.getRole(), role) &&
|
||||
Objects.equals(other.getPassword(), password);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.example.backend.users.model;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
||||
public enum UserRole implements GrantedAuthority {
|
||||
ADMIN,
|
||||
USER;
|
||||
|
||||
private static final String PREFIX = "ROLE_";
|
||||
|
||||
@Override
|
||||
public String getAuthority() {
|
||||
return PREFIX + this.name();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.example.backend.users.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
|
||||
import com.example.backend.users.model.UserEntity;
|
||||
|
||||
public interface UserRepository
|
||||
extends CrudRepository<UserEntity, Integer>, PagingAndSortingRepository<UserEntity, Integer> {
|
||||
Optional<UserEntity> findByLoginIgnoreCase(String login);
|
||||
|
||||
Integer getIdByLoginIgnoreCase(String login);
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
package com.example.backend.users.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import com.example.backend.core.configurations.Constants;
|
||||
import com.example.backend.core.errors.NotFoundException;
|
||||
import com.example.backend.core.security.UserPrincipal;
|
||||
import com.example.backend.favorites.repository.FavoriteRepository;
|
||||
import com.example.backend.users.model.UserEntity;
|
||||
import com.example.backend.users.model.UserRole;
|
||||
import com.example.backend.users.repository.UserRepository;
|
||||
import com.example.backend.viewed.repository.ViewedRepository;
|
||||
|
||||
@Service
|
||||
public class UserService implements UserDetailsService {
|
||||
|
||||
private final UserRepository repository;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
private final FavoriteRepository favoriteRepository;
|
||||
private final ViewedRepository viewedRepository;
|
||||
|
||||
public UserService(UserRepository repository, PasswordEncoder passwordEncoder,
|
||||
FavoriteRepository favoriteRepository,
|
||||
ViewedRepository viewedRepository) {
|
||||
this.repository = repository;
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
this.favoriteRepository = favoriteRepository;
|
||||
this.viewedRepository = viewedRepository;
|
||||
}
|
||||
|
||||
private void checkLogin(Integer id, String login) {
|
||||
final Optional<UserEntity> existsUser = repository.findByLoginIgnoreCase(login);
|
||||
if (existsUser.isPresent() && !existsUser.get().getId().equals(id)) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("User with login %s is already exists", login));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<UserEntity> getAll() {
|
||||
return StreamSupport.stream(repository.findAll().spliterator(), false).toList();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Page<UserEntity> getAll(int page, int size) {
|
||||
return repository.findAll(PageRequest.of(page, size, Sort.by("id")));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public UserEntity get(Integer id) {
|
||||
return repository.findById(id).orElseThrow(() -> new NotFoundException(UserEntity.class, id));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
private UserEntity getByUsername(String username) {
|
||||
return repository.findByLoginIgnoreCase(username)
|
||||
.orElseThrow(() -> new IllegalArgumentException(
|
||||
String.format("user with login %s is not found?", username)));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public UserEntity create(UserEntity entity) {
|
||||
if (entity == null) {
|
||||
throw new IllegalArgumentException("Entity is null");
|
||||
}
|
||||
checkLogin(null, entity.getLogin());
|
||||
final String password = Optional.ofNullable(entity.getPassword()).orElse("");
|
||||
entity.setPassword(
|
||||
passwordEncoder.encode(StringUtils.hasText(password.strip()) ? password : Constants.DEFAULT_PASSWORD));
|
||||
entity.setRole(Optional.ofNullable(entity.getRole()).orElse(UserRole.USER));
|
||||
repository.save(entity);
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public UserEntity update(Integer id, UserEntity entity) {
|
||||
final UserEntity existsentity = get(id);
|
||||
checkLogin(id, entity.getLogin());
|
||||
existsentity.setLogin(entity.getLogin());
|
||||
existsentity.setPassword(entity.getPassword());
|
||||
existsentity.setRole(entity.getRole());
|
||||
repository.save(existsentity);
|
||||
return existsentity;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public UserEntity delete(Integer id) {
|
||||
final UserEntity existsentity = get(id);
|
||||
favoriteRepository.deleteByUserId(existsentity.getId());
|
||||
viewedRepository.deleteByUserId(existsentity.getId());
|
||||
|
||||
repository.delete(existsentity);
|
||||
return existsentity;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Integer getCurrentUserId(String name) {
|
||||
final Optional<UserEntity> user = repository.findByLoginIgnoreCase(name);
|
||||
if (user.isEmpty()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return user.get().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
final UserEntity existUser = getByUsername(username);
|
||||
return new UserPrincipal(existUser);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,182 @@
|
||||
package com.example.backend.viewed.api;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.example.backend.core.configurations.Constants;
|
||||
import com.example.backend.favorites.model.FavoriteEntity;
|
||||
import com.example.backend.favorites.service.FavoriteService;
|
||||
import com.example.backend.viewed.model.ViewedEntity;
|
||||
import com.example.backend.viewed.service.ViewedService;
|
||||
import com.example.backend.movies.api.MovieDTO;
|
||||
import com.example.backend.movies.api.MovieUserDTO;
|
||||
import com.example.backend.movies.model.MovieEntity;
|
||||
import com.example.backend.movies.service.MovieService;
|
||||
import com.example.backend.users.model.UserEntity;
|
||||
import com.example.backend.users.service.UserService;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(ViewedController.URL)
|
||||
public class ViewedController {
|
||||
|
||||
public static final String URL = "/viewed";
|
||||
private static final String FAVORITE_VIEW = "viewed";
|
||||
private static final String PAGE_ATTRIBUTE = "page";
|
||||
|
||||
private final FavoriteService favoriteService;
|
||||
private final UserService userService;
|
||||
private final MovieService movieService;
|
||||
private final ModelMapper modelMapper;
|
||||
private final ViewedService viewedServise;
|
||||
|
||||
public ViewedController(
|
||||
FavoriteService favoriteService, UserService userService,
|
||||
MovieService movieService, ModelMapper modelMapper, ViewedService viewedServise) {
|
||||
this.modelMapper = modelMapper;
|
||||
this.userService = userService;
|
||||
this.favoriteService = favoriteService;
|
||||
this.viewedServise = viewedServise;
|
||||
this.movieService = movieService;
|
||||
}
|
||||
|
||||
private MovieDTO toDtoMovie(MovieEntity entity) {
|
||||
return modelMapper.map(entity, MovieDTO.class);
|
||||
}
|
||||
|
||||
private List<MovieUserDTO> getListMovieUserDTOs(Integer categorieId, int page) {
|
||||
List<MovieDTO> movies = movieService.getAll(categorieId, page, Constants.DEFUALT_PAGE_SIZE)
|
||||
.stream()
|
||||
.map(this::toDtoMovie)
|
||||
.toList();
|
||||
List<MovieUserDTO> muDTO = new ArrayList<MovieUserDTO>();
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
Integer currentUserId = userService.getCurrentUserId(authentication.getName());
|
||||
|
||||
List<FavoriteEntity> favs = favoriteService.getAll(currentUserId);
|
||||
List<ViewedEntity> viewes = viewedServise.getAll(currentUserId);
|
||||
|
||||
for (MovieDTO movieDTO : movies) {
|
||||
MovieUserDTO newMovDto = new MovieUserDTO();
|
||||
newMovDto.setMovieDTO(movieDTO);
|
||||
newMovDto.setCountViewes(movieService.countView(movieDTO.getId()));
|
||||
|
||||
for (FavoriteEntity favoriteEntity : favs) {
|
||||
if ((int) favoriteEntity.getMovie().getId() == (int) movieDTO.getId()) {
|
||||
newMovDto.setFavorite(true);
|
||||
break;
|
||||
}
|
||||
newMovDto.setFavorite(false);
|
||||
}
|
||||
|
||||
for (ViewedEntity viewedEntity : viewes) {
|
||||
if ((int) viewedEntity.getMovie().getId() == (int) movieDTO.getId()) {
|
||||
newMovDto.setViewed(true);
|
||||
break;
|
||||
}
|
||||
newMovDto.setViewed(false);
|
||||
}
|
||||
|
||||
muDTO.add(newMovDto);
|
||||
}
|
||||
return muDTO;
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
public String getAll(Model model, @RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page) {
|
||||
List<MovieUserDTO> muDTO = getListMovieUserDTOs(0, page);
|
||||
model.addAttribute("movies", muDTO);
|
||||
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
return FAVORITE_VIEW;
|
||||
}
|
||||
|
||||
@PostMapping("/changeFavStatus/{id}")
|
||||
public String changeFavStatus(@PathVariable(name = "id") Integer movieId,
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
Model model) {
|
||||
|
||||
boolean isFavorite = false;
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
Integer currentUserId = userService.getCurrentUserId(authentication.getName());
|
||||
|
||||
FavoriteEntity fav = favoriteService.findByUserIdAndMovieId(currentUserId, movieId);
|
||||
|
||||
if (fav == null) {
|
||||
isFavorite = false;
|
||||
} else {
|
||||
isFavorite = true;
|
||||
}
|
||||
|
||||
if (isFavorite == false) {
|
||||
|
||||
UserEntity user = userService.get(currentUserId);
|
||||
MovieEntity movie = movieService.get(movieId);
|
||||
|
||||
FavoriteEntity newFav = new FavoriteEntity(null, user, movie);
|
||||
|
||||
favoriteService.create(newFav);
|
||||
|
||||
} else {
|
||||
|
||||
FavoriteEntity delFav = favoriteService.findByUserIdAndMovieId(currentUserId, movieId);
|
||||
|
||||
favoriteService.delete(delFav.getId());
|
||||
}
|
||||
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
|
||||
@PostMapping("/changeViewStatus/{id}")
|
||||
public String changeViewStatus(@PathVariable(name = "id") Integer movieId,
|
||||
@RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page,
|
||||
Model model) {
|
||||
|
||||
boolean isViewed = false;
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
Integer currentUserId = userService.getCurrentUserId(authentication.getName());
|
||||
|
||||
ViewedEntity view = viewedServise.findByUserIdAndMovieId(currentUserId, movieId);
|
||||
|
||||
if (view == null) {
|
||||
isViewed = false;
|
||||
} else {
|
||||
isViewed = true;
|
||||
}
|
||||
|
||||
if (isViewed == false) {
|
||||
|
||||
UserEntity user = userService.get(currentUserId);
|
||||
MovieEntity movie = movieService.get(movieId);
|
||||
|
||||
ViewedEntity newView = new ViewedEntity(null, user, movie);
|
||||
|
||||
viewedServise.create(newView);
|
||||
|
||||
} else {
|
||||
|
||||
ViewedEntity delView = viewedServise.findByUserIdAndMovieId(currentUserId, movieId);
|
||||
|
||||
viewedServise.delete(delView.getId());
|
||||
}
|
||||
|
||||
model.addAttribute(PAGE_ATTRIBUTE, page);
|
||||
|
||||
return Constants.REDIRECT_VIEW + URL;
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.example.backend.viewed.api;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public class ViewedDto {
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Integer id;
|
||||
|
||||
@NotNull
|
||||
@Min(1)
|
||||
private Integer userId;
|
||||
|
||||
@NotNull
|
||||
@Min(1)
|
||||
private Integer movieId;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Integer getMovieId() {
|
||||
return movieId;
|
||||
}
|
||||
|
||||
public void setMovieId(Integer movieId) {
|
||||
this.movieId = movieId;
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.example.backend.viewed.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.example.backend.core.model.BaseEntity;
|
||||
import com.example.backend.movies.model.MovieEntity;
|
||||
import com.example.backend.users.model.UserEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "viewes")
|
||||
public class ViewedEntity extends BaseEntity {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "userId", nullable = false)
|
||||
private UserEntity user;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "movieId", nullable = false)
|
||||
private MovieEntity movie;
|
||||
|
||||
public ViewedEntity() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ViewedEntity(Integer id, UserEntity user, MovieEntity movie) {
|
||||
this.user = user;
|
||||
this.movie = movie;
|
||||
}
|
||||
|
||||
public UserEntity getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(UserEntity user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public MovieEntity getMovie() {
|
||||
return movie;
|
||||
}
|
||||
|
||||
public void setMovie(MovieEntity movie) {
|
||||
this.movie = movie;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, user, movie);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
final ViewedEntity other = (ViewedEntity) obj;
|
||||
return Objects.equals(other.getId(), id)
|
||||
&& Objects.equals(other.getUser(), user)
|
||||
&& Objects.equals(other.getMovie(), movie);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.example.backend.viewed.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
|
||||
import com.example.backend.viewed.model.ViewedEntity;
|
||||
|
||||
public interface ViewedRepository
|
||||
extends CrudRepository<ViewedEntity, Integer>, PagingAndSortingRepository<ViewedEntity, Integer> {
|
||||
|
||||
List<ViewedEntity> findByUserId(Integer userId);
|
||||
|
||||
Optional<ViewedEntity> findOneByUserIdAndId(Integer userId, Integer id);
|
||||
|
||||
ViewedEntity findByUserIdAndMovieId(Integer userId, Integer movieId);
|
||||
|
||||
Optional<ViewedEntity> deleteByMovieId(Integer movieId);
|
||||
|
||||
Optional<ViewedEntity> deleteByUserId(Integer user);
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package com.example.backend.viewed.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.backend.core.errors.NotFoundException;
|
||||
import com.example.backend.viewed.model.ViewedEntity;
|
||||
import com.example.backend.viewed.repository.ViewedRepository;
|
||||
|
||||
@Service
|
||||
public class ViewedService {
|
||||
private final ViewedRepository repository;
|
||||
|
||||
public ViewedService(ViewedRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<ViewedEntity> getAll(Integer userId) {
|
||||
if (userId == 0) {
|
||||
return StreamSupport.stream(repository.findAll().spliterator(), false).toList();
|
||||
}
|
||||
return repository.findByUserId(userId);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public ViewedEntity get(Integer id) {
|
||||
return repository.findById(id).orElseThrow(() -> new NotFoundException(ViewedEntity.class, id));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ViewedEntity findByUserIdAndMovieId(Integer uId, Integer mId) {
|
||||
return repository.findByUserIdAndMovieId(uId, mId);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ViewedEntity create(ViewedEntity entity) {
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ViewedEntity update(Integer id, ViewedEntity entity) {
|
||||
final ViewedEntity exisEntity = get(id);
|
||||
exisEntity.setUser(entity.getUser());
|
||||
exisEntity.setMovie(entity.getMovie());
|
||||
return repository.save(exisEntity);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ViewedEntity delete(Integer id) {
|
||||
final ViewedEntity exisEntity = get(id);
|
||||
repository.delete(exisEntity);
|
||||
return exisEntity;
|
||||
}
|
||||
}
|
20
backend/src/main/resources/application.properties
Normal file
20
backend/src/main/resources/application.properties
Normal file
@ -0,0 +1,20 @@
|
||||
# Server
|
||||
spring.main.banner-mode=off
|
||||
server.port=8080
|
||||
|
||||
# Logger settings
|
||||
# Available levels are: TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF
|
||||
logging.level.com.example.demo=DEBUG
|
||||
|
||||
# JPA Settings
|
||||
spring.datasource.url=jdbc:h2:file:./data
|
||||
spring.datasource.username=elina
|
||||
spring.datasource.password=elina
|
||||
spring.datasource.driver-class-name=org.h2.Driver
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.open-in-view=false
|
||||
#spring.jpa.show-sql=true
|
||||
#spring.jpa.properties.hibernate.format_sql=true
|
||||
|
||||
# H2 console
|
||||
spring.h2.console.enabled=true
|
163
backend/src/main/resources/public/css/style.css
Normal file
163
backend/src/main/resources/public/css/style.css
Normal file
@ -0,0 +1,163 @@
|
||||
@font-face {
|
||||
font-family: Candara;
|
||||
src: url("../fonts/candara-light.ttf");
|
||||
}
|
||||
|
||||
/* HEAD */
|
||||
.logo {
|
||||
size: 2vh;
|
||||
}
|
||||
|
||||
/* NAVBAR */
|
||||
.my-navbar {
|
||||
font-family: Candara;
|
||||
background-color: #3C2C72;
|
||||
font-size: 2.5vh;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.my-navbar.link a:hover {
|
||||
font-family: Candara;
|
||||
text-decoration: underline !important;
|
||||
color: rgb(251, 158, 149);
|
||||
}
|
||||
|
||||
.my-navbar.logo {
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
/* FOOTER */
|
||||
.my-footer {
|
||||
font-family: Candara;
|
||||
background-color: #3C2C72;
|
||||
color: white;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
|
||||
/* SIGNUP РЕГИСТРАЦИЯ!!! */
|
||||
#login-page {
|
||||
font-family: Candara;
|
||||
background-image: url("../images/logo_light.png");
|
||||
background-color: rgb(0, 0, 0);
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.col {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.input-fill {
|
||||
font-size: 3vh;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 300px;
|
||||
height: 50px;
|
||||
font-size: 25px;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
@media screen and (max-width: 576px) {
|
||||
|
||||
p,
|
||||
.are-you-admin {
|
||||
font-size: min(10vw, 25px);
|
||||
}
|
||||
|
||||
.btn {
|
||||
font-size: min(10vw, 18px);
|
||||
width: 30vh;
|
||||
}
|
||||
}
|
||||
|
||||
.are-you-admin {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
/* LOGIN ВХОД!!! */
|
||||
|
||||
.main-bg-into {
|
||||
/* background-color: black; */
|
||||
background-color: rgb(92, 55, 137);
|
||||
background-image: url("../images/logotip_LC.png");
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
#into-page {
|
||||
font-family: Candara;
|
||||
background-color: rgba(0, 0, 0, 0.6);
|
||||
|
||||
background-blend-mode: multiply;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.text-label {
|
||||
font-size: 25px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 300px;
|
||||
height: 50px;
|
||||
font-size: 25px;
|
||||
transition: 0.9s;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
@media screen and (max-width: 576px) {
|
||||
|
||||
.p {
|
||||
font-size: min(10vw, 36px);
|
||||
}
|
||||
|
||||
.btn {
|
||||
font-size: min(10vw, 25px);
|
||||
width: 30vh;
|
||||
}
|
||||
}
|
||||
|
||||
.error {
|
||||
font-family: CandaraBold;
|
||||
color: #f1ff56;
|
||||
text-align: center;
|
||||
font-size: 3.5vh;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.bi-edit-pen {
|
||||
color: rgb(72, 108, 16);
|
||||
height: 25px;
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
|
||||
.bi-edit-pen:hover {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
|
||||
.bi-cart-delete {
|
||||
color: red;
|
||||
height: 25px;
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
|
||||
.bi-cart-delete:hover {
|
||||
transform: scale(1.2);
|
||||
}
|
0
backend/src/main/resources/public/favicon.ico
Normal file
0
backend/src/main/resources/public/favicon.ico
Normal file
BIN
backend/src/main/resources/public/fonts/candara-light.ttf
Normal file
BIN
backend/src/main/resources/public/fonts/candara-light.ttf
Normal file
Binary file not shown.
BIN
backend/src/main/resources/public/images/logo_light.png
Normal file
BIN
backend/src/main/resources/public/images/logo_light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 458 KiB |
BIN
backend/src/main/resources/public/images/logo_livecinema.png
Normal file
BIN
backend/src/main/resources/public/images/logo_livecinema.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
BIN
backend/src/main/resources/public/images/logotip_LC.png
Normal file
BIN
backend/src/main/resources/public/images/logotip_LC.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 118 KiB |
24
backend/src/main/resources/templates/card-film.html
Normal file
24
backend/src/main/resources/templates/card-film.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{index}">
|
||||
|
||||
<head>
|
||||
<title>Карточка фильма</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main layout:fragment="content">
|
||||
<div class="d-flex flex-row justify-content-center align-items-center mb-5 mt-5" th:object="${movie}">
|
||||
<div class="d-flex flex-column justify-content-center align-items-center" th:object="${countView}">
|
||||
<img th:src="|https://live.funnelmates.com/wp-content/uploads/2021/08/placeholder-200x200-1-1-1.jpeg|"
|
||||
class="rounded-3 mt-3 mb-3"></img>
|
||||
<p class="category-name text-center mt-2 mb-3" th:text="${movie.name}"></p>
|
||||
<p class="category-name text-center mt-2 mb-3" th:text="${movie.description}"></p>
|
||||
<p class="category-name text-center mt-2 mb-3" th:text="${movie.duration}"></p>
|
||||
<p class="category-name text-center mt-2 mb-3" th:text="'Вот столько человек меня
|
||||
посмотрели...' + ${countView}"></p>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
30
backend/src/main/resources/templates/categorie-edit.html
Normal file
30
backend/src/main/resources/templates/categorie-edit.html
Normal file
@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{index}">
|
||||
|
||||
<head>
|
||||
<title>Редактирование категории</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main layout:fragment="content">
|
||||
<h1>Редактирование/Создание категории</h1>
|
||||
<form action="#" th:action="@{/admin/categories/edit/{id}(id=${categorie.id})}" th:object="${categorie}"
|
||||
method="post" enctype="multipart/form-data">
|
||||
<div class="mb-3">
|
||||
<label for="id" class="form-label">ID</label>
|
||||
<input type="text" th:value="*{id}" id="id" class="form-control" readonly disabled>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="name">Название:</label>
|
||||
<input class="form-control" type="text" id="name" th:field="*{name}" />
|
||||
<div th:if="${#fields.hasErrors('name')}" th:errors="*{name}" class="invalid-feedback"></div>
|
||||
</div>
|
||||
<div class="mb-3 d-flex flex-row">
|
||||
<button class="btn btn-primary me-2 button-fixed-width" type="submit">Сохранить</button>
|
||||
<a class="btn btn-secondary button-fixed-width" th:href="@{/admin/categories}">Отмена</a>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
112
backend/src/main/resources/templates/categories.html
Normal file
112
backend/src/main/resources/templates/categories.html
Normal file
@ -0,0 +1,112 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{index}">
|
||||
|
||||
<head>
|
||||
<title>Категории</title>
|
||||
<style>
|
||||
.card-img-top {
|
||||
height: 200px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.categories-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
flex: 1 1 calc(33.333% - 10px);
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<th:block sec:authorize="isAuthenticated()" th:with="userName=${#authentication.name}">
|
||||
<main layout:fragment="content">
|
||||
<th:block sec:authorize="hasRole('ADMIN')">
|
||||
<div class="d-flex flex-row me-2 justify-content-center mt-3 mb-3">
|
||||
<a th:href="@{/admin/categories/edit/}" class="btn btn-primary">Добавить категорию</a>
|
||||
</div>
|
||||
<th:block th:switch="${categories.size()}">
|
||||
<h2 class="d-flex flex-column justify-content-center align-items-center" th:case="0">Данные
|
||||
отсутствуют</h2>
|
||||
<th:block th:case="*">
|
||||
<div class="categories-container d-flex flex-row justify-content-center mt-3 mb-3">
|
||||
<div class="category-item d-flex flex-column justify-content-center align-items-center mb-5 mb-md-0"
|
||||
th:each="categorie : ${categories}">
|
||||
<div class="category-card">
|
||||
<a th:href="@{/admin/movies/categorieId/{id}(id=${categorie.id})}">
|
||||
<img class="card-img-top rounded-3"
|
||||
th:src="${categorie.image != null ? categorie.image : 'https://live.funnelmates.com/wp-content/uploads/2021/08/placeholder-200x200-1-1-1.jpeg'}" />
|
||||
</a>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title" th:text="${categorie.name}"></h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex flex-row me-ms-mt-2">
|
||||
<form th:action="@{/admin/categories/edit/{id}(id=${categorie.id})}" method="get">
|
||||
<button type="submit" class="btn btn-link button-link">
|
||||
<svg class="bi-edit-pen" viewBox="0 0 127 127" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M105.5 26L37 114.5C34.5 117 16.3 121.7 7.5 122.5C79.1 34.1 101 5.5 102 4C104.833 4.5 119.3 14.6 122.5 21C105 44 98.5 55 111.5 58.5"
|
||||
stroke="#008315" stroke-width="6" stroke-linecap="round" />
|
||||
</svg>
|
||||
</button>
|
||||
</form>
|
||||
<form th:action="@{/admin/categories/delete/{id}(id=${categorie.id})}"
|
||||
method="post">
|
||||
<button type="submit" class="btn btn-link button-link"
|
||||
onclick="return confirm('Вы уверены?')">
|
||||
<svg class="bi-cart-delete" viewBox="0 0 154 164" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M44.5 123C4.99995 119.5 -11.8431 56.4293 24 19.5C40.5 2.50001 72.5 -5.5 101.5 27.5L115.5 14.5"
|
||||
stroke="#D10000" stroke-width="8" stroke-linecap="round" />
|
||||
<path
|
||||
d="M65.2123 159.963L56 60.0001C88.0236 76.3307 119.521 77.4194 149 60.0001C141.63 142.346 140.08 160.953 140.226 159.963H65.2123Z"
|
||||
stroke="#D10000" stroke-width="8" />
|
||||
<path d="M121 36L101.582 55L75 31" stroke="#D10000" stroke-width="8"
|
||||
stroke-linecap="round" />
|
||||
</svg>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</th:block>
|
||||
</th:block>
|
||||
</th:block>
|
||||
|
||||
<th:block sec:authorize="hasRole('USER')">
|
||||
<th:block th:switch="${categories.size()}">
|
||||
<h2 th:case="0">Данные отсутствуют</h2>
|
||||
<th:block th:case="*">
|
||||
<div class="categories-container d-flex flex-row justify-content-center mt-3 mb-3">
|
||||
<div class="category-item d-flex flex-column justify-content-center align-items-center mb-5 mb-md-0"
|
||||
th:each="categorie : ${categories}">
|
||||
<div class="category-card mt-3 mb-3">
|
||||
<a th:href="@{/movies/categorieId/{id}(id=${categorie.id})}">
|
||||
<img class="card-img-top rounded-3"
|
||||
th:src="${categorie.image != null ? categorie.image : 'https://live.funnelmates.com/wp-content/uploads/2021/08/placeholder-200x200-1-1-1.jpeg'}" />
|
||||
</a>
|
||||
<div class="card-body mb-3">
|
||||
<h5 class="card-title" th:text="${categorie.name}"></h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</th:block>
|
||||
</th:block>
|
||||
</th:block>
|
||||
|
||||
</main>
|
||||
|
||||
</th:block>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
76
backend/src/main/resources/templates/default.html
Normal file
76
backend/src/main/resources/templates/default.html
Normal file
@ -0,0 +1,76 @@
|
||||
<!-- <!DOCTYPE html>
|
||||
<html lang="ru" data-bs-theme="dark" xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity6">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image" src="/images/logo_livecinema.png">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title layout:title-pattern="$LAYOUT_TITLE - $CONTENT_TITLE">LiveCinema</title>
|
||||
<script type="text/javascript" src="/webjars/bootstrap/5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<link rel="stylesheet" href="/webjars/bootstrap/5.3.3/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="/webjars/bootstrap-icons/1.11.3/font/bootstrap-icons.min.css" />
|
||||
<link rel="stylesheet" href="/css/style.css" />
|
||||
<meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate">
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Expires" content="0">
|
||||
</head>
|
||||
|
||||
<body class="d-flex flex-column flex-fill h-100">
|
||||
<nav expand="md" data-bs-theme="dark" class="navbar my-navbar navbar-expand-md">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">
|
||||
<img src="/images/logo_livecinema.png" class="logo" style="height: 2vh;" />
|
||||
LiveCinema
|
||||
</a>
|
||||
<th:block sec:authorize="isAuthenticated()" th:with="userName=${#authentication.name}">
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#main-navbar"
|
||||
aria-controls="main-navbar" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="main-navbar">
|
||||
<ul class="navbar-nav me-auto link" th:with="activeLink=${#objects.nullSafe(servletPath, '')}">
|
||||
<th:block sec:authorize="hasRole('ADMIN')">
|
||||
<a class="nav-link" href="/admin/user"
|
||||
th:classappend="${activeLink.startsWith('/admin/user')? 'active' : '' }">Пользователи</a>
|
||||
<a class="nav-link" href="/admin/categories"
|
||||
th:classappend="${activeLink.startsWith('/admin/categories')? 'active' : '' }">Категории</a>
|
||||
<a class="nav-link" href="/admin/movies"
|
||||
th:classappend="${activeLink.startsWith('/admin/movies') ? 'active' : '' }">Фильмы</a>
|
||||
<a class="nav-link" href="/admin/favorites"
|
||||
th:classappend="${activeLink.startsWith('/admin/favorites') ? 'active' : '' }">Избранные</a>
|
||||
<a class="nav-link" href="/admin/viewed"
|
||||
th:classappend="${activeLink.startsWith('/admin/viewed') ? 'active' : '' }">Просмотренные</a>
|
||||
<a class="nav-link" href="/h2-console/" target="_blank">Консоль H2</a>
|
||||
</th:block>
|
||||
<th:block sec:authorize="hasRole('USER')">
|
||||
<a class="nav-link" href="/categories"
|
||||
th:classappend="${activeLink.startsWith('/categories') ? 'active' : '' }">Категории</a>
|
||||
<a class="nav-link" href="/movies"
|
||||
th:classappend="${activeLink.startsWith('/movies') ? 'active' : '' }">Фильмы</a>
|
||||
<a class="nav-link" href="/favorites"
|
||||
th:classappend="${activeLink.startsWith('/favorites') ? 'active' : '' }">Избранные</a>
|
||||
<a class="nav-link" href="/viewed"
|
||||
th:classappend="${activeLink.startsWith('/viewed') ? 'active' : '' }">Просмотренные</a>
|
||||
</th:block>
|
||||
</ul>
|
||||
<ul class="navbar-nav" th:if="${not #strings.isEmpty(userName)}">
|
||||
<form th:action="@{/logout}" method="post">
|
||||
<button type="submit" class="navbar-brand nav-link" onclick="return confirm('Вы уверены?')">
|
||||
Выход ([[${userName}]])
|
||||
</button>
|
||||
</form>
|
||||
</ul>
|
||||
</div>
|
||||
</th:block>
|
||||
</div>
|
||||
</nav>
|
||||
<main layout:fragment="content" class="d-flex flex-column flex-fill">
|
||||
</main>
|
||||
<footer class="my-footer mt-auto d-flex flex-shrink-0 justify-content-center">
|
||||
Бакальская Е.Д. (@)LiveCinema [[${#dates.year(#dates.createNow())}]]. Все права защищены
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
</html> -->
|
37
backend/src/main/resources/templates/error.html
Normal file
37
backend/src/main/resources/templates/error.html
Normal file
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{index}">
|
||||
|
||||
<head>
|
||||
<title>Ошибка</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main layout:fragment="content">
|
||||
<ul class="list-group mb-2">
|
||||
<th:block th:if="${#strings.isEmpty(message)}">
|
||||
<li class="list-group-item">
|
||||
Неизвестная ошибка
|
||||
</li>
|
||||
</th:block>
|
||||
<th:block th:if="${not #strings.isEmpty(message)}">
|
||||
<li class="list-group-item">
|
||||
<strong>Ошибка:</strong> [[${message}]]
|
||||
</li>
|
||||
</th:block>
|
||||
<th:block th:if="${not #strings.isEmpty(url)}">
|
||||
<li class="list-group-item">
|
||||
<strong>Адрес:</strong> [[${url}]]
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Класс исключения:</strong> [[${exception}]]
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
[[${method}]] ([[${file}]]:[[${line}]])
|
||||
</li>
|
||||
</th:block>
|
||||
</ul>
|
||||
<a class="btn btn-primary button-fixed-width" href="/">На главную</a>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
68
backend/src/main/resources/templates/favs.html
Normal file
68
backend/src/main/resources/templates/favs.html
Normal file
@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{index}">
|
||||
|
||||
<head>
|
||||
<title>Избранные</title>
|
||||
<style>
|
||||
.card-img-top {
|
||||
height: 200px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.categories-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
flex: 1 1 calc(33.333% - 10px);
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main layout:fragment="content">
|
||||
<th:block th:switch="${movies.size()}">
|
||||
<h2 th:case="0">Данные отсутствуют</h2>
|
||||
<th:block th:case="*">
|
||||
<div class="categories-container d-flex flex-row justify-content-center mt-3 mb-3">
|
||||
<div class="category-item d-flex flex-column justify-content-center align-items-center mb-5 mb-md-0"
|
||||
th:each="movie : ${movies}" th:if="${movie.isFavorite}">
|
||||
|
||||
<div class="category-card">
|
||||
<a th:href="@{/movies/card/{id}(id=${movie.movieDTO.id})}">
|
||||
<img class="card-img-top rounded-3"
|
||||
th:src="|https://live.funnelmates.com/wp-content/uploads/2021/08/placeholder-200x200-1-1-1.jpeg|" />
|
||||
</a>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title" th:text="${movie.movieDTO.name}"></h5>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-row ms-mt-2">
|
||||
<form th:action="@{/favs/changeFavStatus/{id}(id=${movie.movieDTO.id})}" method="post">
|
||||
<input type="hidden" th:name="page" th:value="${page}">
|
||||
<button type="submit" class="btn btn-link button-link">
|
||||
<i th:if="${movie.isFavorite}" class="heart-icon bi bi-heart-fill"></i>
|
||||
<i th:if="${!movie.isFavorite}" class="heart-icon bi bi-heart"></i>
|
||||
</button>
|
||||
</form>
|
||||
<form th:action="@{/favs/changeViewStatus/{id}(id=${movie.movieDTO.id})}" method="post">
|
||||
<input type="hidden" th:name="page" th:value="${page}">
|
||||
<button type="submit" class="btn btn-link button-link">
|
||||
<i th:if="${movie.isViewed}" class="eye-icon bi bi-eye-fill"></i>
|
||||
<i th:if="${!movie.isViewed}" class="eye-icon bi bi-eye"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</th:block>
|
||||
</th:block>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
72
backend/src/main/resources/templates/index.html
Normal file
72
backend/src/main/resources/templates/index.html
Normal file
@ -0,0 +1,72 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru" data-bs-theme="dark" xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity6">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image" src="/images/logo_livecinema.png">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title layout:title-pattern="$LAYOUT_TITLE - $CONTENT_TITLE">LiveCinema</title>
|
||||
<script type="text/javascript" src="/webjars/bootstrap/5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<link rel="stylesheet" href="/webjars/bootstrap/5.3.3/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="/webjars/bootstrap-icons/1.11.3/font/bootstrap-icons.min.css" />
|
||||
<link rel="stylesheet" href="/css/style.css" />
|
||||
<meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate">
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Expires" content="0">
|
||||
</head>
|
||||
|
||||
<body class="d-flex flex-column flex-fill h-100">
|
||||
<nav expand="md" data-bs-theme="dark" class="navbar my-navbar navbar-expand-md">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">
|
||||
<img src="/images/logo_livecinema.png" class="logo" style="height: 2vh;" />
|
||||
LiveCinema
|
||||
</a>
|
||||
<th:block sec:authorize="isAuthenticated()" th:with="userName=${#authentication.name}">
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#main-navbar"
|
||||
aria-controls="main-navbar" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="main-navbar">
|
||||
<ul class="navbar-nav me-auto link" th:with="activeLink=${#objects.nullSafe(servletPath, '')}">
|
||||
<th:block sec:authorize="hasRole('ADMIN')">
|
||||
<a class="nav-link" href="/admin/user"
|
||||
th:classappend="${activeLink.startsWith('/admin/user')? 'active' : '' }">Пользователи</a>
|
||||
<a class="nav-link" href="/admin/categories"
|
||||
th:classappend="${activeLink.startsWith('/admin/categories')? 'active' : '' }">Категории</a>
|
||||
<a class="nav-link" href="/admin/movies"
|
||||
th:classappend="${activeLink.startsWith('/admin/movies') ? 'active' : '' }">Фильмы</a>
|
||||
<a class="nav-link" href="/h2-console/" target="_blank">Консоль H2</a>
|
||||
</th:block>
|
||||
<th:block sec:authorize="hasRole('USER')">
|
||||
<a class="nav-link" href="/categories"
|
||||
th:classappend="${activeLink.startsWith('/categories') ? 'active' : '' }">Категории</a>
|
||||
<a class="nav-link" href="/movies"
|
||||
th:classappend="${activeLink.startsWith('/movies') ? 'active' : '' }">Фильмы</a>
|
||||
<a class="nav-link" href="/favs"
|
||||
th:classappend="${activeLink.startsWith('/favs') ? 'active' : '' }">Избранные</a>
|
||||
<a class="nav-link" href="/viewed"
|
||||
th:classappend="${activeLink.startsWith('/viewed') ? 'active' : '' }">Просмотренные</a>
|
||||
</th:block>
|
||||
</ul>
|
||||
<ul class="navbar-nav" th:if="${not #strings.isEmpty(userName)}">
|
||||
<form th:action="@{/logout}" method="post">
|
||||
<button type="submit" class="navbar-brand nav-link" onclick="return confirm('Вы уверены?')">
|
||||
Выход ([[${userName}]])
|
||||
</button>
|
||||
</form>
|
||||
</ul>
|
||||
</div>
|
||||
</th:block>
|
||||
</div>
|
||||
</nav>
|
||||
<main layout:fragment="content" class="d-flex flex-column flex-fill">
|
||||
</main>
|
||||
<footer class="my-footer mt-auto d-flex flex-shrink-0 justify-content-center">
|
||||
Бакальская Е.Д. (@)LiveCinema [[${#dates.year(#dates.createNow())}]]. Все права защищены
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
</html>
|
47
backend/src/main/resources/templates/login.html
Normal file
47
backend/src/main/resources/templates/login.html
Normal file
@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{index}">
|
||||
|
||||
<head>
|
||||
<title>Вход</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main layout:fragment="content" class="main-bg-into w-100 flex-fill d-flex justify-content-center p-0 m-0">
|
||||
<form action="#" th:action="@{/login}" method="post"
|
||||
class="body flex-fill d-flex flex-column justify-content-around align-items-center" id="into-page">
|
||||
|
||||
<p class="text-label mt-4 d-flex flex-column align-items-center align-content-center">
|
||||
Имя пользователя / электронная почта
|
||||
</p>
|
||||
|
||||
<div class="mb-2 w-50">
|
||||
<input id="username" class="form-control" placeholder="Имя пользователя / Эл. Почта" type="text"
|
||||
name='username' required minlength="3" maxlength="50">
|
||||
</input>
|
||||
<p th:if="${param.error}" class="error mt-2">
|
||||
Введите правильное имя пользователя
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p class="text-label d-flex flex-column align-items-center">
|
||||
Пароль
|
||||
</p>
|
||||
<div class="mb-2 w-50">
|
||||
<input id="password" class="form-control" placeholder="Пароль" type="password" name='password' required
|
||||
minlength="4" maxlength="20">
|
||||
</input>
|
||||
<p th:if="${param.error}" class="error mt-2">
|
||||
Введите верный пароль
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 h-25 d-flex flex-column justify-content-center mb-4">
|
||||
<a class="btn btn-secondary button-fixed-width" href="/signup">Регистрация</a>
|
||||
<button type="submit" class="btn btn-light">Войти</button>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
53
backend/src/main/resources/templates/movie-edit.html
Normal file
53
backend/src/main/resources/templates/movie-edit.html
Normal file
@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{index}">
|
||||
|
||||
<head>
|
||||
<title>Редактирование/создание ФиЛьМа =3</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main layout:fragment="content">
|
||||
<h1>Редактирование/создание ФиЛьМа =3</h1>
|
||||
<form action="#" th:action="@{/admin/movies/edit/{id}(id=${movie.id},page=${page})}" th:object="${movie}"
|
||||
method="post" enctype="multipart/form-data">
|
||||
<div class="mb-3">
|
||||
<label for="id" class="form-label">ID</label>
|
||||
<input type="text" th:value="*{id}" id="id" class="form-control" readonly disabled>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="name">Название:</label>
|
||||
<input class="form-control" type="text" id="name" th:field="*{name}" />
|
||||
<div th:if="${#fields.hasErrors('name')}" th:errors="*{name}" class="invalid-feedback"></div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="description">Описание:</label>
|
||||
<input class="form-control" type="text" id="description" th:field="*{description}" />
|
||||
<div th:if="${#fields.hasErrors('description')}" th:errors="*{description}" class="invalid-feedback">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="duration">Продолжительность:</label>
|
||||
<input class="form-control" type="text" id="duration" th:field="*{duration}" />
|
||||
<div th:if="${#fields.hasErrors('duration')}" th:errors="*{duration}" class="invalid-feedback"></div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="categorie">Категория:</label>
|
||||
<select th:field="*{categorieId}" id="categorie" class="form-select">
|
||||
<option value="" selected>Выберите категорию</option>
|
||||
<option th:each="categorie : ${categories}" th:value="${categorie.id}" th:text="${categorie.name}">
|
||||
</option>
|
||||
</select>
|
||||
<div th:if="${#fields.hasErrors('categorieId')}" th:errors="*{categorieId}" class="invalid-feedback">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 d-flex flex-row">
|
||||
<button class="btn btn-primary me-2 button-fixed-width" type="submit">Сохранить</button>
|
||||
<a class="btn btn-secondary button-fixed-width" th:href="@{/admin/movies(page=${page})}">Отмена</a>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
148
backend/src/main/resources/templates/movies.html
Normal file
148
backend/src/main/resources/templates/movies.html
Normal file
@ -0,0 +1,148 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{index}">
|
||||
|
||||
<head>
|
||||
<title>Фильмы</title>
|
||||
<style>
|
||||
.card-img-top {
|
||||
height: 200px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.categories-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
flex: 1 1 calc(33.333% - 10px);
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main layout:fragment="content">
|
||||
|
||||
<th:block sec:authorize="hasRole('ADMIN')">
|
||||
<div class="d-flex flex-row me-2 justify-content-center mt-3 mb-3">
|
||||
<a th:href="@{/admin/movies/edit/(page=${page})}" class="btn btn-primary">Добавить фильм</a>
|
||||
</div>
|
||||
<th:block th:switch="${items.size()}">
|
||||
<h2 class="d-flex flex-column justify-content-center align-items-center" th:case="0">Данные отсутствуют
|
||||
</h2>
|
||||
|
||||
<th:block th:case="*">
|
||||
<div class="categories-container d-flex flex-row justify-content-center mt-3 mb-3">
|
||||
<div class="category-item d-flex flex-column justify-content-center align-items-center mb-5 mb-md-0"
|
||||
th:each="movie : ${items}">
|
||||
<div class="category-card">
|
||||
<img class="card-img-top rounded-3"
|
||||
th:src="|https://live.funnelmates.com/wp-content/uploads/2021/08/placeholder-200x200-1-1-1.jpeg|" />
|
||||
<div class="card-body">
|
||||
<h5 class="card-title" th:text="${movie.name}"></h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex flex-row me-ms-mt-2">
|
||||
<form th:action="@{/admin/movies/edit/{id}(id=${movie.id})}" method="get">
|
||||
<input type="hidden" th:name="page" th:value="${page}">
|
||||
<button type="submit" class="btn btn-link button-link">
|
||||
<svg class="bi-edit-pen" viewBox="0 0 127 127" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M105.5 26L37 114.5C34.5 117 16.3 121.7 7.5 122.5C79.1 34.1 101 5.5 102 4C104.833 4.5 119.3 14.6 122.5 21C105 44 98.5 55 111.5 58.5"
|
||||
stroke="#008315" stroke-width="6" stroke-linecap="round" />
|
||||
</svg>
|
||||
</button>
|
||||
</form>
|
||||
<form th:action="@{/admin/movies/delete/{id}(id=${movie.id})}" method="post">
|
||||
<input type="hidden" th:name="page" th:value="${page}">
|
||||
<button type="submit" class="btn btn-link button-link"
|
||||
onclick="return confirm('Вы уверены?')">
|
||||
<svg class="bi-cart-delete" viewBox="0 0 154 164" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M44.5 123C4.99995 119.5 -11.8431 56.4293 24 19.5C40.5 2.50001 72.5 -5.5 101.5 27.5L115.5 14.5"
|
||||
stroke="#D10000" stroke-width="8" stroke-linecap="round" />
|
||||
<path
|
||||
d="M65.2123 159.963L56 60.0001C88.0236 76.3307 119.521 77.4194 149 60.0001C141.63 142.346 140.08 160.953 140.226 159.963H65.2123Z"
|
||||
stroke="#D10000" stroke-width="8" />
|
||||
<path d="M121 36L101.582 55L75 31" stroke="#D10000" stroke-width="8"
|
||||
stroke-linecap="round" />
|
||||
</svg>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</th:block>
|
||||
|
||||
</th:block>
|
||||
|
||||
<th:block th:replace="~{ pagination :: pagination (
|
||||
url=${'admin/movies'},
|
||||
totalPages=${totalPages},
|
||||
currentPage=${currentPage}) }" />
|
||||
|
||||
</th:block>
|
||||
|
||||
<th:block sec:authorize="hasRole('USER')">
|
||||
<th:block th:switch="${movies.size()}">
|
||||
<h2 th:case="0">Данные отсутствуют</h2>
|
||||
<th:block th:case="*">
|
||||
|
||||
<div class="categories-container d-flex flex-row justify-content-center mt-3 mb-3">
|
||||
<div class="category-item d-flex flex-column justify-content-center align-items-center mb-5 mb-md-0"
|
||||
th:each="movie : ${movies}">
|
||||
|
||||
<div class="category-card">
|
||||
<a th:href="@{/movies/card/{id}(id=${movie.movieDTO.id})}">
|
||||
<img class="card-img-top rounded-3"
|
||||
th:src="|https://live.funnelmates.com/wp-content/uploads/2021/08/placeholder-200x200-1-1-1.jpeg|" />
|
||||
</a>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title" th:text="${movie.movieDTO.name}"></h5>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-row ms-mt-2">
|
||||
|
||||
<form th:action="@{/movies/changeFavStatus/{id}(id=${movie.movieDTO.id},page=${page})}"
|
||||
method="post">
|
||||
<input type="hidden" th:name="page" th:value="${page}">
|
||||
<button type="submit" class="btn btn-link button-link">
|
||||
<i th:if="${movie.isFavorite}" class="heart-icon bi bi-heart-fill"></i>
|
||||
<i th:if="${!movie.isFavorite}" class="heart-icon bi bi-heart"></i>
|
||||
</button>
|
||||
</form>
|
||||
<form th:action="@{/movies/changeViewStatus/{id}(id=${movie.movieDTO.id},page=${page})}"
|
||||
method="post">
|
||||
<input type="hidden" th:name="page" th:value="${page}">
|
||||
<button type="submit" class="btn btn-link button-link">
|
||||
<i th:if="${movie.isViewed}" class="eye-icon bi bi-eye-fill"></i>
|
||||
<i th:if="${!movie.isViewed}" class="eye-icon bi bi-eye"></i>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</th:block>
|
||||
|
||||
</th:block>
|
||||
<th:block th:replace="~{ pagination :: pagination (
|
||||
url=${'movies'},
|
||||
totalPages=${totalPages},
|
||||
currentPage=${currentPage}) }" />
|
||||
</th:block>
|
||||
|
||||
|
||||
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
51
backend/src/main/resources/templates/pagination.html
Normal file
51
backend/src/main/resources/templates/pagination.html
Normal file
@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<body>
|
||||
|
||||
<th:block th:fragment="pagination (url, totalPages, currentPage)">
|
||||
<nav th:if="${totalPages > 1}" th:with="
|
||||
maxPage=2,
|
||||
currentPage=${currentPage + 1}">
|
||||
<ul class="pagination justify-content-center"
|
||||
th:with="
|
||||
seqFrom=${currentPage - maxPage < 1 ? 1 : currentPage - maxPage},
|
||||
seqTo=${currentPage + maxPage > totalPages ? totalPages : currentPage + maxPage}">
|
||||
<th:block th:if="${currentPage > maxPage + 1}">
|
||||
<li class="page-item">
|
||||
<a class="page-link" aria-label="Previous" th:href="@{/{url}?page=0(url=${url})}">
|
||||
<span aria-hidden="true">«</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link" aria-label="Previous">
|
||||
<span aria-hidden="true">…</span>
|
||||
</span>
|
||||
</li>
|
||||
</th:block>
|
||||
<li class="page-item" th:each="page : ${#numbers.sequence(seqFrom, seqTo)}"
|
||||
th:classappend="${page == currentPage} ? 'active' : ''">
|
||||
<a class="page-link" th:href="@{/{url}?page={page}(url=${url},page=${page - 1})}">
|
||||
<span th:text="${page}" />
|
||||
</a>
|
||||
</li>
|
||||
<th:block th:if="${currentPage < totalPages - maxPage}">
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link" aria-label="Previous">
|
||||
<span aria-hidden="true">…</span>
|
||||
</span>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" aria-label="Next"
|
||||
th:href="@{/{url}?page={page}(url=${url},page=${totalPages - 1})}">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a>
|
||||
</li>
|
||||
</th:block>
|
||||
</ul>
|
||||
</nav>
|
||||
</th:block>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
62
backend/src/main/resources/templates/signup.html
Normal file
62
backend/src/main/resources/templates/signup.html
Normal file
@ -0,0 +1,62 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{index}">
|
||||
|
||||
<head>
|
||||
<title>Регистрация</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main layout:fragment="content">
|
||||
<form action="#" th:action="@{/signup}" th:object="${user}" method="post" class="flex-fill d-flex"
|
||||
id="login-page">
|
||||
|
||||
<div class="container d-flex flex-column justify-content-center align-items-center">
|
||||
|
||||
<p class="input-fill mt-4 d-flex flex-column align-items-center">
|
||||
Имя пользователя
|
||||
</p>
|
||||
<div class="mb-4 w-50">
|
||||
<input th:field="*{login}" id="login" class="form-control" placeholder="Имя пользователя"
|
||||
type="text" name='login' required minlength="3" maxlength="50">
|
||||
</input>
|
||||
</div>
|
||||
<div th:if="${#fields.hasErrors('login')}" th:errors="*{login}" class="invalid-feedback"></div>
|
||||
|
||||
<p class="input-fill d-flex flex-column align-items-center">
|
||||
Пароль
|
||||
</p>
|
||||
<div class="mb-4 w-50">
|
||||
<input th:field="*{password}" id="password" class="form-control" placeholder="Пароль"
|
||||
type="password" name='password' required minlength="3" maxlength="20">
|
||||
</input>
|
||||
</div>
|
||||
<div th:if="${#fields.hasErrors('password')}" th:errors="*{password}" class="invalid-feedback">
|
||||
</div>
|
||||
|
||||
<p class="input-fill d-flex flex-column align-items-center">
|
||||
Пароль повторно
|
||||
</p>
|
||||
<div class="mb-4 w-50">
|
||||
<input th:field="*{passwordConfirm}" id="passwordConfirm" class="form-control"
|
||||
placeholder="Пароль повторно" type="password" required minlength="3" maxlength="20">
|
||||
</input>
|
||||
</div>
|
||||
<div th:if="${#fields.hasErrors('passwordConfirm')}" th:errors="*{passwordConfirm}"
|
||||
class="invalid-feedback">
|
||||
</div>
|
||||
|
||||
<div class="check-admin mt-4 d-flex flex-row justify-content-center mb-4">
|
||||
<input th:field="*{isAdmin}" class='isAdmin-check' type="checkbox" name="isAdmin" />
|
||||
<label for="isAdmin" class='are-you-admin'> Вы админ? </label>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 h-25 d-flex flex-column justify-content-center mb-4">
|
||||
<button type="submit" class="btn btn-light">Зарегистрироваться</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
30
backend/src/main/resources/templates/user-edit.html
Normal file
30
backend/src/main/resources/templates/user-edit.html
Normal file
@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{index}">
|
||||
|
||||
<head>
|
||||
<title>Редакторовать/Создать пользователя</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main layout:fragment="content">
|
||||
<form action="#" th:action="@{/admin/user/edit/{id}(id=${user.id},page=${page})}" th:object="${user}"
|
||||
method="post">
|
||||
<div class="mb-3">
|
||||
<label for="id" class="form-label">ID</label>
|
||||
<input type="text" th:value="*{id}" id="id" class="form-control" readonly disabled>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="login" class="form-label">Имя пользователя</label>
|
||||
<input type="text" th:field="*{login}" id="login" class="form-control">
|
||||
<div th:if="${#fields.hasErrors('login')}" th:errors="*{login}" class="invalid-feedback"></div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 d-flex flex-row">
|
||||
<button class="btn btn-primary me-2 button-fixed-width" type="submit">Сохранить</button>
|
||||
<a class="btn btn-secondary button-fixed-width" th:href="@{/admin/user(page=${page})}">Отмена</a>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
56
backend/src/main/resources/templates/user.html
Normal file
56
backend/src/main/resources/templates/user.html
Normal file
@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{index}">
|
||||
|
||||
<head>
|
||||
<title>Пользователи</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main layout:fragment="content" class="overflow-auto" style="max-height: 100vh;">
|
||||
<th:block th:switch="${items.size()}">
|
||||
<h2 th:case="0">Данные отсутствуют</h2>
|
||||
<th:block th:case="*">
|
||||
<h2>Пользователи</h2>
|
||||
<div class="d-flex flex-column justify-content-center align-items-center">
|
||||
<a th:href="@{/admin/user/edit/(page=${page})}" class="btn btn-primary">Добавить пользователя</a>
|
||||
</div>
|
||||
<table class="table">
|
||||
<caption></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="w-10">ID</th>
|
||||
<th scope="col" class="w-auto">Имя пользователя</th>
|
||||
<th scope="col" class="w-10"></th>
|
||||
<th scope="col" class="w-10"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="user : ${items}">
|
||||
<th scope="row" th:text="${user.id}"></th>
|
||||
<td th:text="${user.login}"></td>
|
||||
<td>
|
||||
<form th:action="@{/admin/user/edit/{id}(id=${user.id})}" method="get">
|
||||
<input type="hidden" th:name="page" th:value="${page}">
|
||||
<button type="submit" class="btn btn-link button-link">Редактировать</button>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form th:action="@{/admin/user/delete/{id}(id=${user.id})}" method="post">
|
||||
<input type="hidden" th:name="page" th:value="${page}">
|
||||
<button type="submit" class="btn btn-link button-link"
|
||||
onclick="return confirm('Вы уверены?')">Удалить</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</th:block>
|
||||
<th:block th:replace="~{ pagination :: pagination (
|
||||
url=${'admin/user'},
|
||||
totalPages=${totalPages},
|
||||
currentPage=${currentPage}) }" />
|
||||
</th:block>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
67
backend/src/main/resources/templates/viewed.html
Normal file
67
backend/src/main/resources/templates/viewed.html
Normal file
@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{index}">
|
||||
|
||||
<head>
|
||||
<title>Просмотренные</title>
|
||||
<style>
|
||||
.card-img-top {
|
||||
height: 200px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.categories-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
flex: 1 1 calc(33.333% - 10px);
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main layout:fragment="content">
|
||||
<th:block th:switch="${movies.size()}">
|
||||
<h2 th:case="0">Данные отсутствуют</h2>
|
||||
<th:block th:case="*">
|
||||
<div class="categories-container d-flex flex-row justify-content-center mt-3 mb-3">
|
||||
<div class="category-item d-flex flex-column justify-content-center align-items-center mb-5 mb-md-0"
|
||||
th:each="movie : ${movies}" th:if="${movie.isViewed}">
|
||||
|
||||
<div class="category-card">
|
||||
<a th:href="@{/movies/card/{id}(id=${movie.movieDTO.id})}">
|
||||
<img class="card-img-top rounded-3"
|
||||
th:src="|https://live.funnelmates.com/wp-content/uploads/2021/08/placeholder-200x200-1-1-1.jpeg|" />
|
||||
</a>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title" th:text="${movie.movieDTO.name}"></h5>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-row ms-mt-2">
|
||||
<form th:action="@{/viewed/changeFavStatus/{id}(id=${movie.movieDTO.id})}" method="post">
|
||||
<input type="hidden" th:name="page" th:value="${page}">
|
||||
<button type="submit" class="btn btn-link button-link">
|
||||
<i th:if="${movie.isFavorite}" class="heart-icon bi bi-heart-fill"></i>
|
||||
<i th:if="${!movie.isFavorite}" class="heart-icon bi bi-heart"></i>
|
||||
</button>
|
||||
</form>
|
||||
<form th:action="@{/viewed/changeViewStatus/{id}(id=${movie.movieDTO.id})}" method="post">
|
||||
<input type="hidden" th:name="page" th:value="${page}">
|
||||
<button type="submit" class="btn btn-link button-link">
|
||||
<i th:if="${movie.isViewed}" class="eye-icon bi bi-eye-fill"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</th:block>
|
||||
</th:block>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
BIN
data.mv.db
Normal file
BIN
data.mv.db
Normal file
Binary file not shown.
865
data.trace.db
Normal file
865
data.trace.db
Normal file
@ -0,0 +1,865 @@
|
||||
2024-04-15 12:19:20.050452+04:00 database: wrong user or password; user: "SA"
|
||||
org.h2.message.DbException: Неверное имя пользователя или пароль
|
||||
Wrong user name or password [28000-224]
|
||||
at org.h2.message.DbException.get(DbException.java:223)
|
||||
at org.h2.message.DbException.get(DbException.java:199)
|
||||
at org.h2.message.DbException.get(DbException.java:188)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:154)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:343)
|
||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:125)
|
||||
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:288)
|
||||
at org.h2.server.web.WebServer.getConnection(WebServer.java:811)
|
||||
at org.h2.server.web.WebApp.login(WebApp.java:1039)
|
||||
at org.h2.server.web.WebApp.process(WebApp.java:227)
|
||||
at org.h2.server.web.WebApp.processRequest(WebApp.java:177)
|
||||
at org.h2.server.web.JakartaWebServlet.doGet(JakartaWebServlet.java:129)
|
||||
at org.h2.server.web.JakartaWebServlet.doPost(JakartaWebServlet.java:166)
|
||||
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:590)
|
||||
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
|
||||
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
|
||||
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
|
||||
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
|
||||
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
|
||||
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
|
||||
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
|
||||
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
|
||||
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
|
||||
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)
|
||||
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
|
||||
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
|
||||
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
|
||||
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)
|
||||
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
|
||||
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
|
||||
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744)
|
||||
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
|
||||
at java.base/java.lang.Thread.run(Thread.java:842)
|
||||
Caused by: org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Неверное имя пользователя или пароль
|
||||
Wrong user name or password [28000-224]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:522)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
|
||||
... 50 more
|
||||
2024-04-15 12:20:09.391447+04:00 jdbc[13]: exception
|
||||
org.h2.jdbc.JdbcSQLSyntaxErrorException: Синтаксическая ошибка в выражении SQL "SELECT * FROM CATEGORIES CATEGORIES [*]FAVORITES"
|
||||
Syntax error in SQL statement "SELECT * FROM CATEGORIES CATEGORIES [*]FAVORITES"; SQL statement:
|
||||
SELECT * FROM CATEGORIES CATEGORIES FAVORITES [42000-224]
|
||||
2024-04-15 16:29:01.404545+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Значение слишком длинное для поля "PASSWORD CHARACTER VARYING(5)": "'string' (6)"
|
||||
Value too long for column "PASSWORD CHARACTER VARYING(5)": "'string' (6)"; SQL statement:
|
||||
insert into users (is_admin,password,username,id) values (?,?,?,?) [22001-224]
|
||||
2024-04-15 16:29:07.847974+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Значение слишком длинное для поля "PASSWORD CHARACTER VARYING(5)": "'string' (6)"
|
||||
Value too long for column "PASSWORD CHARACTER VARYING(5)": "'string' (6)"; SQL statement:
|
||||
insert into users (is_admin,password,username,id) values (?,?,?,?) [22001-224]
|
||||
2024-04-29 00:12:28.578523+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Значение слишком длинное для поля "PASSWORD CHARACTER VARYING(5)": "'string' (6)"
|
||||
Value too long for column "PASSWORD CHARACTER VARYING(5)": "'string' (6)"; SQL statement:
|
||||
insert into users (is_admin,password,username,id) values (?,?,?,?) [22001-224]
|
||||
2024-05-12 10:12:25.785506+04:00 database: flush
|
||||
org.h2.message.DbException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]"
|
||||
General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]" [50000-224]
|
||||
at org.h2.message.DbException.get(DbException.java:212)
|
||||
at org.h2.message.DbException.convert(DbException.java:407)
|
||||
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:122)
|
||||
at org.h2.mvstore.MVStore.handleException(MVStore.java:1546)
|
||||
at org.h2.mvstore.MVStore.panic(MVStore.java:371)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:291)
|
||||
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035)
|
||||
at org.h2.mvstore.db.Store.<init>(Store.java:133)
|
||||
at org.h2.engine.Database.<init>(Database.java:326)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:92)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:343)
|
||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:125)
|
||||
at org.h2.Driver.connect(Driver.java:59)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100)
|
||||
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.getConnectionUrl(H2ConsoleAutoConfiguration.java:94)
|
||||
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
|
||||
at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
|
||||
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
|
||||
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
|
||||
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
|
||||
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
|
||||
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
|
||||
at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
|
||||
at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
|
||||
at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)
|
||||
at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.logDataSources(H2ConsoleAutoConfiguration.java:86)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.lambda$h2Console$0(H2ConsoleAutoConfiguration.java:69)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.withThreadContextClassLoader(H2ConsoleAutoConfiguration.java:78)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.h2Console(H2ConsoleAutoConfiguration.java:69)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140)
|
||||
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644)
|
||||
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1335)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1165)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:210)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:201)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:96)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:85)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:266)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:240)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:52)
|
||||
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4880)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
|
||||
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
|
||||
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
|
||||
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
|
||||
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
|
||||
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:845)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
|
||||
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
|
||||
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
|
||||
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
|
||||
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
|
||||
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:240)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:921)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:437)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:105)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:499)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:218)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:188)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162)
|
||||
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:618)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
|
||||
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
|
||||
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:334)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
|
||||
at com.example.backend.BackendApplication.main(BackendApplication.java:32)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)
|
||||
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]"
|
||||
General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]" [50000-224]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:566)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
|
||||
... 103 more
|
||||
Caused by: org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]
|
||||
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)
|
||||
at org.h2.mvstore.SingleFileStore.lockFileChannel(SingleFileStore.java:143)
|
||||
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:117)
|
||||
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:286)
|
||||
... 97 more
|
||||
2024-05-12 10:12:27.410246+04:00 database: flush
|
||||
org.h2.message.DbException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]"
|
||||
General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]" [50000-224]
|
||||
at org.h2.message.DbException.get(DbException.java:212)
|
||||
at org.h2.message.DbException.convert(DbException.java:407)
|
||||
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:122)
|
||||
at org.h2.mvstore.MVStore.handleException(MVStore.java:1546)
|
||||
at org.h2.mvstore.MVStore.panic(MVStore.java:371)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:291)
|
||||
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035)
|
||||
at org.h2.mvstore.db.Store.<init>(Store.java:133)
|
||||
at org.h2.engine.Database.<init>(Database.java:326)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:92)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:343)
|
||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:125)
|
||||
at org.h2.Driver.connect(Driver.java:59)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100)
|
||||
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
|
||||
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:428)
|
||||
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcIsolationDelegate.delegateWork(JdbcIsolationDelegate.java:61)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata(JdbcEnvironmentInitiator.java:276)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:107)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68)
|
||||
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:130)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:238)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215)
|
||||
at org.hibernate.boot.model.relational.Database.<init>(Database.java:45)
|
||||
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:223)
|
||||
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:191)
|
||||
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:170)
|
||||
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1432)
|
||||
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1503)
|
||||
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75)
|
||||
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:390)
|
||||
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
|
||||
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396)
|
||||
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:366)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1833)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
|
||||
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1234)
|
||||
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:952)
|
||||
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
|
||||
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
|
||||
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:334)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
|
||||
at com.example.backend.BackendApplication.main(BackendApplication.java:32)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)
|
||||
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]"
|
||||
General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]" [50000-224]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:566)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
|
||||
... 66 more
|
||||
Caused by: org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]
|
||||
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)
|
||||
at org.h2.mvstore.SingleFileStore.lockFileChannel(SingleFileStore.java:143)
|
||||
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:117)
|
||||
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:286)
|
||||
... 60 more
|
||||
2024-05-12 21:34:34.174331+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Значение слишком длинное для поля "PASSWORD CHARACTER VARYING(5)": "'$2a$10$Rf07keY4Z/WhQLBEqbMbyu56QuCA5xbmHeAVPNg/odAvY47yE8GjC' (60)"
|
||||
Value too long for column "PASSWORD CHARACTER VARYING(5)": "'$2a$10$Rf07keY4Z/WhQLBEqbMbyu56QuCA5xbmHeAVPNg/odAvY47yE8GjC' (60)"; SQL statement:
|
||||
insert into users (is_admin,login,password,role,id) values (?,?,?,?,?) [22001-224]
|
||||
2024-05-12 21:38:56.147601+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Значение слишком длинное для поля "PASSWORD CHARACTER VARYING(20)": "'$2a$10$7XkFYCPQBOF7yXXQ6kEkO.0QBBtiCOPDjxucmGsrxBXHXfoaAP8Tu' (60)"
|
||||
Value too long for column "PASSWORD CHARACTER VARYING(20)": "'$2a$10$7XkFYCPQBOF7yXXQ6kEkO.0QBBtiCOPDjxucmGsrxBXHXfoaAP8Tu' (60)"; SQL statement:
|
||||
insert into users (is_admin,login,password,role,id) values (?,?,?,?,?) [22001-224]
|
||||
2024-05-12 21:39:04.953731+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Значение слишком длинное для поля "PASSWORD CHARACTER VARYING(20)": "'$2a$10$ZAbf6WfHePM5ns4r4DZWmuj9yTPKjm.VfT4q95Tc3qiROTPzlb6Sq' (60)"
|
||||
Value too long for column "PASSWORD CHARACTER VARYING(20)": "'$2a$10$ZAbf6WfHePM5ns4r4DZWmuj9yTPKjm.VfT4q95Tc3qiROTPzlb6Sq' (60)"; SQL statement:
|
||||
insert into users (is_admin,login,password,role,id) values (?,?,?,?,?) [22001-224]
|
||||
2024-05-12 21:39:08.584296+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Значение слишком длинное для поля "PASSWORD CHARACTER VARYING(20)": "'$2a$10$abhWyp7BEpM/f5iR8lbXJ.1TtCLvd7ZR48Z.oJZFQfDeJqkCaEPQi' (60)"
|
||||
Value too long for column "PASSWORD CHARACTER VARYING(20)": "'$2a$10$abhWyp7BEpM/f5iR8lbXJ.1TtCLvd7ZR48Z.oJZFQfDeJqkCaEPQi' (60)"; SQL statement:
|
||||
insert into users (is_admin,login,password,role,id) values (?,?,?,?,?) [22001-224]
|
||||
2024-05-12 21:39:30.388688+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Значение слишком длинное для поля "PASSWORD CHARACTER VARYING(20)": "'$2a$10$wO/abVNIh838IC9VTQLrB.JfG7qsWsAxTebHZXXTVK8ln7jkMpxiK' (60)"
|
||||
Value too long for column "PASSWORD CHARACTER VARYING(20)": "'$2a$10$wO/abVNIh838IC9VTQLrB.JfG7qsWsAxTebHZXXTVK8ln7jkMpxiK' (60)"; SQL statement:
|
||||
insert into users (is_admin,login,password,role,id) values (?,?,?,?,?) [22001-224]
|
||||
2024-05-12 21:43:25.051363+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Значение слишком длинное для поля "PASSWORD CHARACTER VARYING(20)": "'$2a$10$gqXogx6wGIIbkYL9tAA83uSWNioogg6sxNo./nPbW5EAt/K2R2AFm' (60)"
|
||||
Value too long for column "PASSWORD CHARACTER VARYING(20)": "'$2a$10$gqXogx6wGIIbkYL9tAA83uSWNioogg6sxNo./nPbW5EAt/K2R2AFm' (60)"; SQL statement:
|
||||
insert into users (is_admin,login,password,role,id) values (?,?,?,?,?) [22001-224]
|
||||
2024-05-12 21:45:41.743220+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Значение слишком длинное для поля "PASSWORD CHARACTER VARYING(20)": "'$2a$10$KxYCFqPHmoXVKChGwJA5AOiZqYiIwLs9sVLimM8jR2mGIcSyuJmvO' (60)"
|
||||
Value too long for column "PASSWORD CHARACTER VARYING(20)": "'$2a$10$KxYCFqPHmoXVKChGwJA5AOiZqYiIwLs9sVLimM8jR2mGIcSyuJmvO' (60)"; SQL statement:
|
||||
insert into users (is_admin,login,password,role,id) values (?,?,?,?,?) [22001-224]
|
||||
2024-05-13 16:34:28.838591+04:00 database: flush
|
||||
org.h2.message.DbException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]"
|
||||
General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]" [50000-224]
|
||||
at org.h2.message.DbException.get(DbException.java:212)
|
||||
at org.h2.message.DbException.convert(DbException.java:407)
|
||||
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:122)
|
||||
at org.h2.mvstore.MVStore.handleException(MVStore.java:1546)
|
||||
at org.h2.mvstore.MVStore.panic(MVStore.java:371)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:291)
|
||||
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035)
|
||||
at org.h2.mvstore.db.Store.<init>(Store.java:133)
|
||||
at org.h2.engine.Database.<init>(Database.java:326)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:92)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:343)
|
||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:125)
|
||||
at org.h2.Driver.connect(Driver.java:59)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100)
|
||||
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.getConnectionUrl(H2ConsoleAutoConfiguration.java:94)
|
||||
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
|
||||
at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
|
||||
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
|
||||
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
|
||||
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
|
||||
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
|
||||
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
|
||||
at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
|
||||
at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
|
||||
at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)
|
||||
at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.logDataSources(H2ConsoleAutoConfiguration.java:86)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.lambda$h2Console$0(H2ConsoleAutoConfiguration.java:69)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.withThreadContextClassLoader(H2ConsoleAutoConfiguration.java:78)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.h2Console(H2ConsoleAutoConfiguration.java:69)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140)
|
||||
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644)
|
||||
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1335)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1165)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:210)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:201)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:96)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:85)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:266)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:240)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:52)
|
||||
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4880)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
|
||||
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
|
||||
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
|
||||
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
|
||||
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
|
||||
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:845)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
|
||||
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
|
||||
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
|
||||
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
|
||||
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
|
||||
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:240)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:921)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:437)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:105)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:499)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:218)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:188)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162)
|
||||
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:618)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
|
||||
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
|
||||
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:334)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
|
||||
at com.example.backend.BackendApplication.main(BackendApplication.java:26)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)
|
||||
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]"
|
||||
General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]" [50000-224]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:566)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
|
||||
... 103 more
|
||||
Caused by: org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]
|
||||
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)
|
||||
at org.h2.mvstore.SingleFileStore.lockFileChannel(SingleFileStore.java:143)
|
||||
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:117)
|
||||
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:286)
|
||||
... 97 more
|
||||
2024-05-13 16:36:51.388577+04:00 database: flush
|
||||
org.h2.message.DbException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]"
|
||||
General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]" [50000-224]
|
||||
at org.h2.message.DbException.get(DbException.java:212)
|
||||
at org.h2.message.DbException.convert(DbException.java:407)
|
||||
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:122)
|
||||
at org.h2.mvstore.MVStore.handleException(MVStore.java:1546)
|
||||
at org.h2.mvstore.MVStore.panic(MVStore.java:371)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:291)
|
||||
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035)
|
||||
at org.h2.mvstore.db.Store.<init>(Store.java:133)
|
||||
at org.h2.engine.Database.<init>(Database.java:326)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:92)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:343)
|
||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:125)
|
||||
at org.h2.Driver.connect(Driver.java:59)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100)
|
||||
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.getConnectionUrl(H2ConsoleAutoConfiguration.java:94)
|
||||
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
|
||||
at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
|
||||
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
|
||||
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
|
||||
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
|
||||
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
|
||||
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
|
||||
at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
|
||||
at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
|
||||
at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)
|
||||
at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.logDataSources(H2ConsoleAutoConfiguration.java:86)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.lambda$h2Console$0(H2ConsoleAutoConfiguration.java:69)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.withThreadContextClassLoader(H2ConsoleAutoConfiguration.java:78)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.h2Console(H2ConsoleAutoConfiguration.java:69)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140)
|
||||
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644)
|
||||
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1335)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1165)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:210)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:201)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:96)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:85)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:266)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:240)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:52)
|
||||
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4880)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
|
||||
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
|
||||
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
|
||||
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
|
||||
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
|
||||
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:845)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
|
||||
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
|
||||
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
|
||||
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
|
||||
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
|
||||
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:240)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:921)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:437)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:105)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:499)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:218)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:188)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162)
|
||||
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:618)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
|
||||
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
|
||||
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:334)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
|
||||
at com.example.backend.BackendApplication.main(BackendApplication.java:26)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)
|
||||
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]"
|
||||
General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]" [50000-224]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:566)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
|
||||
... 103 more
|
||||
Caused by: org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]
|
||||
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)
|
||||
at org.h2.mvstore.SingleFileStore.lockFileChannel(SingleFileStore.java:143)
|
||||
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:117)
|
||||
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:286)
|
||||
... 97 more
|
||||
2024-05-13 16:36:53.026985+04:00 database: flush
|
||||
org.h2.message.DbException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]"
|
||||
General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]" [50000-224]
|
||||
at org.h2.message.DbException.get(DbException.java:212)
|
||||
at org.h2.message.DbException.convert(DbException.java:407)
|
||||
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:122)
|
||||
at org.h2.mvstore.MVStore.handleException(MVStore.java:1546)
|
||||
at org.h2.mvstore.MVStore.panic(MVStore.java:371)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:291)
|
||||
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035)
|
||||
at org.h2.mvstore.db.Store.<init>(Store.java:133)
|
||||
at org.h2.engine.Database.<init>(Database.java:326)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:92)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:343)
|
||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:125)
|
||||
at org.h2.Driver.connect(Driver.java:59)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100)
|
||||
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
|
||||
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:428)
|
||||
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcIsolationDelegate.delegateWork(JdbcIsolationDelegate.java:61)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata(JdbcEnvironmentInitiator.java:276)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:107)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68)
|
||||
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:130)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:238)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215)
|
||||
at org.hibernate.boot.model.relational.Database.<init>(Database.java:45)
|
||||
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:223)
|
||||
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:191)
|
||||
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:170)
|
||||
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1432)
|
||||
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1503)
|
||||
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75)
|
||||
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:390)
|
||||
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
|
||||
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396)
|
||||
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:366)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1833)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
|
||||
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1234)
|
||||
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:952)
|
||||
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
|
||||
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
|
||||
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:334)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
|
||||
at com.example.backend.BackendApplication.main(BackendApplication.java:26)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)
|
||||
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]"
|
||||
General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]" [50000-224]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:566)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
|
||||
... 66 more
|
||||
Caused by: org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]
|
||||
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)
|
||||
at org.h2.mvstore.SingleFileStore.lockFileChannel(SingleFileStore.java:143)
|
||||
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:117)
|
||||
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:286)
|
||||
... 60 more
|
||||
2024-05-13 16:41:37.478545+04:00 database: flush
|
||||
org.h2.message.DbException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]"
|
||||
General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]" [50000-224]
|
||||
at org.h2.message.DbException.get(DbException.java:212)
|
||||
at org.h2.message.DbException.convert(DbException.java:407)
|
||||
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:122)
|
||||
at org.h2.mvstore.MVStore.handleException(MVStore.java:1546)
|
||||
at org.h2.mvstore.MVStore.panic(MVStore.java:371)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:291)
|
||||
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035)
|
||||
at org.h2.mvstore.db.Store.<init>(Store.java:133)
|
||||
at org.h2.engine.Database.<init>(Database.java:326)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:92)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:343)
|
||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:125)
|
||||
at org.h2.Driver.connect(Driver.java:59)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100)
|
||||
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.getConnectionUrl(H2ConsoleAutoConfiguration.java:94)
|
||||
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
|
||||
at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
|
||||
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
|
||||
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
|
||||
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
|
||||
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
|
||||
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
|
||||
at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
|
||||
at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
|
||||
at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)
|
||||
at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.logDataSources(H2ConsoleAutoConfiguration.java:86)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.lambda$h2Console$0(H2ConsoleAutoConfiguration.java:69)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.withThreadContextClassLoader(H2ConsoleAutoConfiguration.java:78)
|
||||
at org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration.h2Console(H2ConsoleAutoConfiguration.java:69)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140)
|
||||
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644)
|
||||
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1335)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1165)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:210)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:201)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:96)
|
||||
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:85)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:266)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:240)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:52)
|
||||
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4880)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
|
||||
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
|
||||
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
|
||||
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
|
||||
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
|
||||
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:845)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
|
||||
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
|
||||
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
|
||||
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
|
||||
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
|
||||
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
|
||||
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:240)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:921)
|
||||
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
|
||||
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:437)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:105)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:499)
|
||||
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:218)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:188)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162)
|
||||
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:618)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
|
||||
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
|
||||
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:334)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
|
||||
at com.example.backend.BackendApplication.main(BackendApplication.java:26)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)
|
||||
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]"
|
||||
General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]" [50000-224]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:566)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
|
||||
... 103 more
|
||||
Caused by: org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]
|
||||
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)
|
||||
at org.h2.mvstore.SingleFileStore.lockFileChannel(SingleFileStore.java:143)
|
||||
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:117)
|
||||
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:286)
|
||||
... 97 more
|
||||
2024-05-13 16:41:39.123320+04:00 database: flush
|
||||
org.h2.message.DbException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]"
|
||||
General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]" [50000-224]
|
||||
at org.h2.message.DbException.get(DbException.java:212)
|
||||
at org.h2.message.DbException.convert(DbException.java:407)
|
||||
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:122)
|
||||
at org.h2.mvstore.MVStore.handleException(MVStore.java:1546)
|
||||
at org.h2.mvstore.MVStore.panic(MVStore.java:371)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:291)
|
||||
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035)
|
||||
at org.h2.mvstore.db.Store.<init>(Store.java:133)
|
||||
at org.h2.engine.Database.<init>(Database.java:326)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:92)
|
||||
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:343)
|
||||
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:125)
|
||||
at org.h2.Driver.connect(Driver.java:59)
|
||||
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359)
|
||||
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
|
||||
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470)
|
||||
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
|
||||
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100)
|
||||
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
|
||||
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:428)
|
||||
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcIsolationDelegate.delegateWork(JdbcIsolationDelegate.java:61)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata(JdbcEnvironmentInitiator.java:276)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:107)
|
||||
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68)
|
||||
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:130)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:238)
|
||||
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215)
|
||||
at org.hibernate.boot.model.relational.Database.<init>(Database.java:45)
|
||||
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:223)
|
||||
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:191)
|
||||
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:170)
|
||||
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1432)
|
||||
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1503)
|
||||
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75)
|
||||
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:390)
|
||||
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
|
||||
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396)
|
||||
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:366)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1833)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600)
|
||||
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
|
||||
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
|
||||
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1234)
|
||||
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:952)
|
||||
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624)
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
|
||||
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
|
||||
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:334)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
|
||||
at com.example.backend.BackendApplication.main(BackendApplication.java:26)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)
|
||||
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Внутренняя ошибка: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]"
|
||||
General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]" [50000-224]
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:566)
|
||||
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
|
||||
... 66 more
|
||||
Caused by: org.h2.mvstore.MVStoreException: The file is locked: D:/code/PIbd-21_Bakalskaya_E.D._INTERNET_PROGRAMMING_BACKEND/data.mv.db [2.2.224/7]
|
||||
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)
|
||||
at org.h2.mvstore.SingleFileStore.lockFileChannel(SingleFileStore.java:143)
|
||||
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:117)
|
||||
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81)
|
||||
at org.h2.mvstore.MVStore.<init>(MVStore.java:286)
|
||||
... 60 more
|
||||
2024-06-17 23:16:01.589022+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 10 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"
|
||||
Data conversion error converting "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 10 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"; SQL statement:
|
||||
INSERT INTO "PUBLIC"."CATEGORIES_COPY_3_0"("ID", "NAME", "IMAGE") OVERRIDING SYSTEM VALUE SELECT "ID", "NAME", "IMAGE" FROM "PUBLIC"."CATEGORIES" [22018-224]
|
||||
2024-06-17 23:17:44.595115+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 9 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"
|
||||
Data conversion error converting "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 9 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"; SQL statement:
|
||||
INSERT INTO "PUBLIC"."CATEGORIES_COPY_3_0"("ID", "NAME", "IMAGE") OVERRIDING SYSTEM VALUE SELECT "ID", "NAME", "IMAGE" FROM "PUBLIC"."CATEGORIES" [22018-224]
|
||||
2024-06-17 23:20:54.688760+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 9 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"
|
||||
Data conversion error converting "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 9 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"; SQL statement:
|
||||
INSERT INTO "PUBLIC"."CATEGORIES_COPY_3_0"("ID", "NAME", "IMAGE") OVERRIDING SYSTEM VALUE SELECT "ID", "NAME", "IMAGE" FROM "PUBLIC"."CATEGORIES" [22018-224]
|
||||
2024-06-17 23:22:52.663341+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 13 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"
|
||||
Data conversion error converting "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 13 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"; SQL statement:
|
||||
INSERT INTO "PUBLIC"."CATEGORIES_COPY_3_0"("ID", "NAME", "IMAGE") OVERRIDING SYSTEM VALUE SELECT "ID", "NAME", "IMAGE" FROM "PUBLIC"."CATEGORIES" [22018-224]
|
||||
2024-06-18 20:37:32.784955+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 9 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"
|
||||
Data conversion error converting "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 9 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"; SQL statement:
|
||||
INSERT INTO "PUBLIC"."CATEGORIES_COPY_3_0"("ID", "NAME", "IMAGE") OVERRIDING SYSTEM VALUE SELECT "ID", "NAME", "IMAGE" FROM "PUBLIC"."CATEGORIES" [22018-224]
|
||||
2024-06-18 20:44:02.945094+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 14 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"
|
||||
Data conversion error converting "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 14 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"; SQL statement:
|
||||
INSERT INTO "PUBLIC"."CATEGORIES_COPY_3_0"("ID", "NAME", "IMAGE") OVERRIDING SYSTEM VALUE SELECT "ID", "NAME", "IMAGE" FROM "PUBLIC"."CATEGORIES" [22018-224]
|
||||
2024-06-18 20:52:02.831015+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 20 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"
|
||||
Data conversion error converting "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 20 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"; SQL statement:
|
||||
INSERT INTO "PUBLIC"."CATEGORIES_COPY_3_0"("ID", "NAME", "IMAGE") OVERRIDING SYSTEM VALUE SELECT "ID", "NAME", "IMAGE" FROM "PUBLIC"."CATEGORIES" [22018-224]
|
||||
2024-06-18 20:52:23.440573+04:00 jdbc[3]: exception
|
||||
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 21 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"
|
||||
Data conversion error converting "CAST(REPEAT(CHAR(0), 9861) AS BINARY VARYING /* table: -3 id: 21 */) (CATEGORIES_COPY_3_0: ""IMAGE"" CHARACTER VARYING(255))"; SQL statement:
|
||||
INSERT INTO "PUBLIC"."CATEGORIES_COPY_3_0"("ID", "NAME", "IMAGE") OVERRIDING SYSTEM VALUE SELECT "ID", "NAME", "IMAGE" FROM "PUBLIC"."CATEGORIES" [22018-224]
|
||||
2024-06-21 16:19:57.086526+04:00 jdbc[13]: exception
|
||||
org.h2.jdbc.JdbcSQLSyntaxErrorException: Синтаксическая ошибка в выражении SQL "select * from movies m join [*]left favorites f on m.id == f.movie_id"; ожидалось "identifier"
|
||||
Syntax error in SQL statement "select * from movies m join [*]left favorites f on m.id == f.movie_id"; expected "identifier"; SQL statement:
|
||||
select * from movies m join left favorites f on m.id == f.movie_id [42001-224]
|
||||
2024-06-21 16:20:14.022117+04:00 jdbc[13]: exception
|
||||
org.h2.jdbc.JdbcSQLSyntaxErrorException: Синтаксическая ошибка в выражении SQL "select * from movies m join [*]left favorites f on m.id = f.movie_id"; ожидалось "identifier"
|
||||
Syntax error in SQL statement "select * from movies m join [*]left favorites f on m.id = f.movie_id"; expected "identifier"; SQL statement:
|
||||
select * from movies m join left favorites f on m.id = f.movie_id [42001-224]
|
||||
2024-06-21 16:35:31.277808+04:00 jdbc[13]: exception
|
||||
org.h2.jdbc.JdbcSQLSyntaxErrorException: Синтаксическая ошибка в выражении SQL "select * from movies m left join [*]left favorites f on m.id == f.movie_id"; ожидалось "identifier"
|
||||
Syntax error in SQL statement "select * from movies m left join [*]left favorites f on m.id == f.movie_id"; expected "identifier"; SQL statement:
|
||||
select * from movies m left join left favorites f on m.id == f.movie_id [42001-224]
|
||||
2024-06-21 16:35:37.602519+04:00 jdbc[13]: exception
|
||||
org.h2.jdbc.JdbcSQLSyntaxErrorException: Синтаксическая ошибка в выражении SQL "select * from movies m left join favorites f on m.id =[*]= f.movie_id"; ожидалось "ALL (, ANY (, SOME ("
|
||||
Syntax error in SQL statement "select * from movies m left join favorites f on m.id =[*]= f.movie_id"; expected "ALL (, ANY (, SOME ("; SQL statement:
|
||||
select * from movies m left join favorites f on m.id == f.movie_id [42001-224]
|
Loading…
Reference in New Issue
Block a user