From f80db06adf31e450018cb6c56b3fad3b506d3b93 Mon Sep 17 00:00:00 2001 From: Maksim Skobaro Date: Sun, 2 Feb 2025 03:10:17 +0300 Subject: [PATCH] refactoring --- .gitignore | 1 + .mvn/wrapper/maven-wrapper.properties | 19 -- configurations/Build & Run.run.xml | 11 - configurations/Clean, Build & Run.run.xml | 11 - configurations/Run.run.xml | 8 - configurations/Start RDBMS.run.xml | 11 - .../docker-compose.yml => docker-compose.yml | 4 +- mvnw | 259 ------------------ mvnw.cmd | 149 ---------- .../tdms/config/SecurityConfiguration.java | 94 ++++--- .../tdms/controller/UserController.java | 5 +- .../ru/tubryansk/tdms/dto/ErrorResponse.java | 2 +- .../java/ru/tubryansk/tdms/dto/GroupDTO.java | 4 +- .../ru/tubryansk/tdms/dto/StudentDTO.java | 32 +-- .../java/ru/tubryansk/tdms/dto/UserDTO.java | 42 +-- .../tubryansk/tdms/entity/DiplomaTopic.java | 8 +- .../java/ru/tubryansk/tdms/entity/Group.java | 8 +- .../java/ru/tubryansk/tdms/entity/Role.java | 8 +- .../ru/tubryansk/tdms/entity/Student.java | 22 +- .../java/ru/tubryansk/tdms/entity/User.java | 23 +- .../tubryansk/tdms/service/CallerService.java | 21 ++ .../tdms/service/StudentService.java | 4 +- .../tubryansk/tdms/service/UserService.java | 9 - server/src/main/resources/application-dev.yml | 2 - server/src/main/resources/application.yml | 13 +- .../V00001__Create__role_table.sql | 6 - .../V00010__Create__user_table.sql | 12 - .../V00020__Create__user_role_table.sql | 9 - .../V00030__Create__diploma_topic_table.sql | 5 - .../V00040__Create__group_table.sql | 9 - .../V00050__Create__student_table.sql | 24 -- .../V0060__Insert_base_cases_in__user.sql | 96 ------- .../V0061__Update_test_passwords_in__user.sql | 1 - .../V0065__Insert_base_cases_in__group.sql | 2 - .../V0070__Insert_base_cases_in__role.sql | 2 - .../V0075__Insert_base_cases_in__student.sql | 73 ----- ...V0080__Insert_base_cases_in__user_role.sql | 55 ---- .../migration/V00010__Create__role_table.sql | 10 + .../migration/V00020__Create__user_table.sql | 20 ++ .../V00030__Create__user_role_table.sql | 18 ++ .../V00040__Create__diploma_topic_table.sql | 8 + .../migration/V00050__Create__group_table.sql | 16 ++ .../V00060__Create__student_table.sql | 58 ++++ .../V00500__Insert_default_roles__role.sql | 6 + .../V00510__Insert_administrator.sql | 8 + .../V00070__Create__defence_table.sql | 7 + .../test-data/diploma_topic.sql} | 2 +- .../src/main/resources/db/test-data/group.sql | 3 + .../main/resources/db/test-data/student.sql | 98 +++++++ .../src/main/resources/db/test-data/user.sql | 82 ++++++ .../main/resources/db/test-data/user_role.sql | 58 ++++ server/src/main/resources/logback.xml | 22 ++ 52 files changed, 574 insertions(+), 906 deletions(-) delete mode 100644 .mvn/wrapper/maven-wrapper.properties delete mode 100644 configurations/Build & Run.run.xml delete mode 100644 configurations/Clean, Build & Run.run.xml delete mode 100644 configurations/Run.run.xml delete mode 100644 configurations/Start RDBMS.run.xml rename server/docker-compose.yml => docker-compose.yml (75%) delete mode 100755 mvnw delete mode 100644 mvnw.cmd create mode 100644 server/src/main/java/ru/tubryansk/tdms/service/CallerService.java delete mode 100644 server/src/main/resources/db.migration/V00001__Create__role_table.sql delete mode 100644 server/src/main/resources/db.migration/V00010__Create__user_table.sql delete mode 100644 server/src/main/resources/db.migration/V00020__Create__user_role_table.sql delete mode 100644 server/src/main/resources/db.migration/V00030__Create__diploma_topic_table.sql delete mode 100644 server/src/main/resources/db.migration/V00040__Create__group_table.sql delete mode 100644 server/src/main/resources/db.migration/V00050__Create__student_table.sql delete mode 100644 server/src/main/resources/db.migration/V0060__Insert_base_cases_in__user.sql delete mode 100644 server/src/main/resources/db.migration/V0061__Update_test_passwords_in__user.sql delete mode 100644 server/src/main/resources/db.migration/V0065__Insert_base_cases_in__group.sql delete mode 100644 server/src/main/resources/db.migration/V0070__Insert_base_cases_in__role.sql delete mode 100644 server/src/main/resources/db.migration/V0075__Insert_base_cases_in__student.sql delete mode 100644 server/src/main/resources/db.migration/V0080__Insert_base_cases_in__user_role.sql create mode 100644 server/src/main/resources/db/migration/V00010__Create__role_table.sql create mode 100644 server/src/main/resources/db/migration/V00020__Create__user_table.sql create mode 100644 server/src/main/resources/db/migration/V00030__Create__user_role_table.sql create mode 100644 server/src/main/resources/db/migration/V00040__Create__diploma_topic_table.sql create mode 100644 server/src/main/resources/db/migration/V00050__Create__group_table.sql create mode 100644 server/src/main/resources/db/migration/V00060__Create__student_table.sql create mode 100644 server/src/main/resources/db/migration/V00500__Insert_default_roles__role.sql create mode 100644 server/src/main/resources/db/migration/V00510__Insert_administrator.sql create mode 100644 server/src/main/resources/db/test-data/V00070__Create__defence_table.sql rename server/src/main/resources/{db.migration/V0055__Insert_base_cases_in__diploma_topic.sql => db/test-data/diploma_topic.sql} (99%) create mode 100644 server/src/main/resources/db/test-data/group.sql create mode 100644 server/src/main/resources/db/test-data/student.sql create mode 100644 server/src/main/resources/db/test-data/user.sql create mode 100644 server/src/main/resources/db/test-data/user_role.sql create mode 100644 server/src/main/resources/logback.xml diff --git a/.gitignore b/.gitignore index 7ed0d6b..7772781 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ build/ ### VS Code ### .vscode/ +/logs/app.log diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 8f96f52..0000000 --- a/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -wrapperVersion=3.3.2 -distributionType=only-script -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip diff --git a/configurations/Build & Run.run.xml b/configurations/Build & Run.run.xml deleted file mode 100644 index 24cf027..0000000 --- a/configurations/Build & Run.run.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - \ No newline at end of file diff --git a/configurations/Clean, Build & Run.run.xml b/configurations/Clean, Build & Run.run.xml deleted file mode 100644 index c16b1a7..0000000 --- a/configurations/Clean, Build & Run.run.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - \ No newline at end of file diff --git a/configurations/Run.run.xml b/configurations/Run.run.xml deleted file mode 100644 index b7019a7..0000000 --- a/configurations/Run.run.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/configurations/Start RDBMS.run.xml b/configurations/Start RDBMS.run.xml deleted file mode 100644 index 0a6c22b..0000000 --- a/configurations/Start RDBMS.run.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/server/docker-compose.yml b/docker-compose.yml similarity index 75% rename from server/docker-compose.yml rename to docker-compose.yml index 80f507b..d89bc5a 100644 --- a/server/docker-compose.yml +++ b/docker-compose.yml @@ -2,8 +2,8 @@ services: db: image: postgres:16.2-alpine3.19 environment: - - "POSTGRES_DB=db" + - "POSTGRES_DB=tdms" - "POSTGRES_PASSWORD=root" - "POSTGRES_USER=root" ports: - - "5432:5432" + - "5400:5432" diff --git a/mvnw b/mvnw deleted file mode 100755 index d7c358e..0000000 --- a/mvnw +++ /dev/null @@ -1,259 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Apache Maven Wrapper startup batch script, version 3.3.2 -# -# Optional ENV vars -# ----------------- -# JAVA_HOME - location of a JDK home dir, required when download maven via java source -# MVNW_REPOURL - repo url base for downloading maven distribution -# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven -# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output -# ---------------------------------------------------------------------------- - -set -euf -[ "${MVNW_VERBOSE-}" != debug ] || set -x - -# OS specific support. -native_path() { printf %s\\n "$1"; } -case "$(uname)" in -CYGWIN* | MINGW*) - [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" - native_path() { cygpath --path --windows "$1"; } - ;; -esac - -# set JAVACMD and JAVACCMD -set_java_home() { - # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched - 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" - JAVACCMD="$JAVA_HOME/jre/sh/javac" - else - JAVACMD="$JAVA_HOME/bin/java" - JAVACCMD="$JAVA_HOME/bin/javac" - - if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then - echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 - echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 - return 1 - fi - fi - else - JAVACMD="$( - 'set' +e - 'unset' -f command 2>/dev/null - 'command' -v java - )" || : - JAVACCMD="$( - 'set' +e - 'unset' -f command 2>/dev/null - 'command' -v javac - )" || : - - if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then - echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 - return 1 - fi - fi -} - -# hash string like Java String::hashCode -hash_string() { - str="${1:-}" h=0 - while [ -n "$str" ]; do - char="${str%"${str#?}"}" - h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) - str="${str#?}" - done - printf %x\\n $h -} - -verbose() { :; } -[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } - -die() { - printf %s\\n "$1" >&2 - exit 1 -} - -trim() { - # MWRAPPER-139: - # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. - # Needed for removing poorly interpreted newline sequences when running in more - # exotic environments such as mingw bash on Windows. - printf "%s" "${1}" | tr -d '[:space:]' -} - -# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties -while IFS="=" read -r key value; do - case "${key-}" in - distributionUrl) distributionUrl=$(trim "${value-}") ;; - distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; - esac -done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" -[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" - -case "${distributionUrl##*/}" in -maven-mvnd-*bin.*) - MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ - case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in - *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; - :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; - :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; - :Linux*x86_64*) distributionPlatform=linux-amd64 ;; - *) - echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 - distributionPlatform=linux-amd64 - ;; - esac - distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" - ;; -maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; -*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; -esac - -# apply MVNW_REPOURL and calculate MAVEN_HOME -# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ -[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" -distributionUrlName="${distributionUrl##*/}" -distributionUrlNameMain="${distributionUrlName%.*}" -distributionUrlNameMain="${distributionUrlNameMain%-bin}" -MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" -MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" - -exec_maven() { - unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : - exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" -} - -if [ -d "$MAVEN_HOME" ]; then - verbose "found existing MAVEN_HOME at $MAVEN_HOME" - exec_maven "$@" -fi - -case "${distributionUrl-}" in -*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; -*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; -esac - -# prepare tmp dir -if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then - clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } - trap clean HUP INT TERM EXIT -else - die "cannot create temp dir" -fi - -mkdir -p -- "${MAVEN_HOME%/*}" - -# Download and Install Apache Maven -verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." -verbose "Downloading from: $distributionUrl" -verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" - -# select .zip or .tar.gz -if ! command -v unzip >/dev/null; then - distributionUrl="${distributionUrl%.zip}.tar.gz" - distributionUrlName="${distributionUrl##*/}" -fi - -# verbose opt -__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' -[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v - -# normalize http auth -case "${MVNW_PASSWORD:+has-password}" in -'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; -has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; -esac - -if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then - verbose "Found wget ... using wget" - wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" -elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then - verbose "Found curl ... using curl" - curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" -elif set_java_home; then - verbose "Falling back to use Java to download" - javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" - targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" - cat >"$javaSource" <<-END - public class Downloader extends java.net.Authenticator - { - protected java.net.PasswordAuthentication getPasswordAuthentication() - { - return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); - } - public static void main( String[] args ) throws Exception - { - setDefault( new Downloader() ); - java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); - } - } - END - # For Cygwin/MinGW, switch paths to Windows format before running javac and java - verbose " - Compiling Downloader.java ..." - "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" - verbose " - Running Downloader.java ..." - "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" -fi - -# If specified, validate the SHA-256 sum of the Maven distribution zip file -if [ -n "${distributionSha256Sum-}" ]; then - distributionSha256Result=false - if [ "$MVN_CMD" = mvnd.sh ]; then - echo "Checksum validation is not supported for maven-mvnd." >&2 - echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 - exit 1 - elif command -v sha256sum >/dev/null; then - if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then - distributionSha256Result=true - fi - elif command -v shasum >/dev/null; then - if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then - distributionSha256Result=true - fi - else - echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 - echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 - exit 1 - fi - if [ $distributionSha256Result = false ]; then - echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 - echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 - exit 1 - fi -fi - -# unzip and move -if command -v unzip >/dev/null; then - unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" -else - tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" -fi -printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" -mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" - -clean || : -exec_maven "$@" diff --git a/mvnw.cmd b/mvnw.cmd deleted file mode 100644 index 200f22a..0000000 --- a/mvnw.cmd +++ /dev/null @@ -1,149 +0,0 @@ -<# : batch portion -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. 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, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Apache Maven Wrapper startup batch script, version 3.3.2 -@REM -@REM Optional ENV vars -@REM MVNW_REPOURL - repo url base for downloading maven distribution -@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven -@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output -@REM ---------------------------------------------------------------------------- - -@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) -@SET __MVNW_CMD__= -@SET __MVNW_ERROR__= -@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% -@SET PSModulePath= -@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-PageContent -Raw '%~f0'))) -NoNewScope}"`) DO @( - IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) -) -@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% -@SET __MVNW_PSMODULEP_SAVE= -@SET __MVNW_ARG0_NAME__= -@SET MVNW_USERNAME= -@SET MVNW_PASSWORD= -@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) -@echo Cannot start maven from wrapper >&2 && exit /b 1 -@GOTO :EOF -: end batch / begin powershell #> - -$ErrorActionPreference = "Stop" -if ($env:MVNW_VERBOSE -eq "true") { - $VerbosePreference = "Continue" -} - -# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties -$distributionUrl = (Get-PageContent -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl -if (!$distributionUrl) { - Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" -} - -switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { - "maven-mvnd-*" { - $USE_MVND = $true - $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" - $MVN_CMD = "mvnd.cmd" - break - } - default { - $USE_MVND = $false - $MVN_CMD = $script -replace '^mvnw','mvn' - break - } -} - -# apply MVNW_REPOURL and calculate MAVEN_HOME -# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ -if ($env:MVNW_REPOURL) { - $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } - $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" -} -$distributionUrlName = $distributionUrl -replace '^.*/','' -$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' -$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" -if ($env:MAVEN_USER_HOME) { - $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" -} -$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' -$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" - -if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { - Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" - Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" - exit $? -} - -if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { - Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" -} - -# prepare tmp dir -$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile -$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" -$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null -trap { - if ($TMP_DOWNLOAD_DIR.Exists) { - try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } - catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } - } -} - -New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null - -# Download and Install Apache Maven -Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." -Write-Verbose "Downloading from: $distributionUrl" -Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" - -$webclient = New-Object System.Net.WebClient -if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { - $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) -} -[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null - -# If specified, validate the SHA-256 sum of the Maven distribution zip file -$distributionSha256Sum = (Get-PageContent -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum -if ($distributionSha256Sum) { - if ($USE_MVND) { - Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." - } - Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash - if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { - Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." - } -} - -# unzip and move -Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null -Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null -try { - Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null -} catch { - if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { - Write-Error "fail to move MAVEN_HOME" - } -} finally { - try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } - catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } -} - -Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/server/src/main/java/ru/tubryansk/tdms/config/SecurityConfiguration.java b/server/src/main/java/ru/tubryansk/tdms/config/SecurityConfiguration.java index 443463e..c636afc 100644 --- a/server/src/main/java/ru/tubryansk/tdms/config/SecurityConfiguration.java +++ b/server/src/main/java/ru/tubryansk/tdms/config/SecurityConfiguration.java @@ -40,16 +40,18 @@ import static org.springframework.security.web.context.HttpSessionSecurityContex @Configuration public class SecurityConfiguration { @Bean - public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity, - AuthenticationManager authenticationManager, - @Qualifier("corsConfig") CorsConfigurationSource cors) throws Exception { + public SecurityFilterChain securityFilterChain( + HttpSecurity httpSecurity, + AuthenticationManager authenticationManager, + @Qualifier("corsConfig") CorsConfigurationSource cors + ) throws Exception { return httpSecurity - .authorizeHttpRequests(this::configureHttpAuthorization) - .csrf(AbstractHttpConfigurer::disable) - .cors(a -> a.configurationSource(cors)) - .authenticationManager(authenticationManager) - .sessionManagement(this::configureSessionManagement) - .build(); + .authorizeHttpRequests(this::configureHttpAuthorization) + .csrf(AbstractHttpConfigurer::disable) + .cors(a -> a.configurationSource(cors)) + .authenticationManager(authenticationManager) + .sessionManagement(this::configureSessionManagement) + .build(); } @Bean @@ -69,9 +71,11 @@ public class SecurityConfiguration { @Bean @Profile("!dev") @Qualifier("corsConfig") - public CorsConfigurationSource corsConfigurationProd(@Value("${application.domain}") String domain, - @Value("${application.port}") String port, - @Value("${application.protocol}") String protocol) { + public CorsConfigurationSource corsConfigurationProd( + @Value("${application.domain}") String domain, + @Value("${application.port}") String port, + @Value("${application.protocol}") String protocol + ) { return request -> { String url = StringUtils.join(protocol, "://", domain, ":", port); CorsConfiguration corsConfiguration = new CorsConfiguration(); @@ -83,6 +87,39 @@ public class SecurityConfiguration { }; } + @Bean + public AuthenticationManager authenticationManager(UserDetailsService userDetailsService) { + return new ProviderManager(authenticationProvider(userDetailsService)); + } + + @Bean + public PasswordEncoder passwordEncoder() { + return PasswordEncoderFactories.createDelegatingPasswordEncoder(); + } + + // @Bean + // @Profile("dev") + // public HttpSessionListener autoAuthenticateUnderAdmin(AuthenticationManager authenticationManager) { + // return new HttpSessionListener() { + // @Override + // public void sessionCreated(HttpSessionEvent se) { + // String username = "admin"; + // LoggerFactory.getLogger(this.getClass()).info("Session created {}. Authenticated, as {}", se.getSession().getId(), username); + // SecurityContext context = SecurityContextHolder.createEmptyContext(); + // UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(username, "1"); + // Authentication authenticated = authenticationManager.authenticate(authentication); + // context.setAuthentication(authenticated); + // SecurityContextHolder.setContext(context); + // se.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, context); + // } + // }; + // } + + // todo: remove when login/logout is implemented, since we do not need automatically created session with no authentication + private void configureSessionManagement(SessionManagementConfigurer sessionManagement) { + sessionManagement.sessionCreationPolicy(SessionCreationPolicy.ALWAYS); + } + private void configureHttpAuthorization(AuthorizeHttpRequestsConfigurer.AuthorizationManagerRequestMatcherRegistry httpAuthorization) { /* API ROUTES */ httpAuthorization.requestMatchers("/api/v1/user/logout").authenticated(); @@ -96,42 +133,9 @@ public class SecurityConfiguration { httpAuthorization.requestMatchers("/**").permitAll(); } - @Bean - public AuthenticationManager authenticationManager(UserDetailsService userDetailsService) { - return new ProviderManager(authenticationProvider(userDetailsService)); - } - private AuthenticationProvider authenticationProvider(UserDetailsService userDetailsService) { DaoAuthenticationProvider provider = new DaoAuthenticationProvider(passwordEncoder()); provider.setUserDetailsService(userDetailsService); return provider; } - - @Bean - public PasswordEncoder passwordEncoder() { - return PasswordEncoderFactories.createDelegatingPasswordEncoder(); - } - - @Bean - @Profile("dev") - public HttpSessionListener autoAuthenticateUnderAdmin(AuthenticationManager authenticationManager) { - return new HttpSessionListener() { - @Override - public void sessionCreated(HttpSessionEvent se) { - String username = "akulenko_mikhail"; - LoggerFactory.getLogger(this.getClass()).info("Session created {}. Authenticated, as {}", se.getSession().getId(), username); - SecurityContext context = SecurityContextHolder.createEmptyContext(); - UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(username, "1"); - Authentication authenticated = authenticationManager.authenticate(authentication); - context.setAuthentication(authenticated); - SecurityContextHolder.setContext(context); - se.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, context); - } - }; - } - - // todo: remove when login/logout is implemented, since we do not need automatically created session with no authentication - private void configureSessionManagement(SessionManagementConfigurer sessionManagement) { - sessionManagement.sessionCreationPolicy(SessionCreationPolicy.ALWAYS); - } } diff --git a/server/src/main/java/ru/tubryansk/tdms/controller/UserController.java b/server/src/main/java/ru/tubryansk/tdms/controller/UserController.java index cfcf057..1e5bfc9 100644 --- a/server/src/main/java/ru/tubryansk/tdms/controller/UserController.java +++ b/server/src/main/java/ru/tubryansk/tdms/controller/UserController.java @@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import ru.tubryansk.tdms.dto.UserDTO; import ru.tubryansk.tdms.service.AuthenticationService; +import ru.tubryansk.tdms.service.CallerService; import ru.tubryansk.tdms.service.UserService; @RestController @@ -14,11 +15,11 @@ public class UserController { @Autowired private AuthenticationService authenticationService; @Autowired - private UserService userService; + private CallerService callerService; @GetMapping("/current") public UserDTO getCurrentUser() { - return userService.getCallerUser().map(user -> UserDTO.from(user, true)).orElse(UserDTO.unauthenticated()); + return callerService.getCallerUser().map(user -> UserDTO.from(user, true)).orElse(UserDTO.unauthenticated()); } @PostMapping("/logout") diff --git a/server/src/main/java/ru/tubryansk/tdms/dto/ErrorResponse.java b/server/src/main/java/ru/tubryansk/tdms/dto/ErrorResponse.java index c993f8e..8981986 100644 --- a/server/src/main/java/ru/tubryansk/tdms/dto/ErrorResponse.java +++ b/server/src/main/java/ru/tubryansk/tdms/dto/ErrorResponse.java @@ -12,7 +12,7 @@ public record ErrorResponse(String message, ErrorCode errorCode) { VALIDATION_ERROR(HttpStatus.BAD_REQUEST), INTERNAL_ERROR(HttpStatus.INTERNAL_SERVER_ERROR), NOT_FOUND(HttpStatus.NOT_FOUND), - ACCESS_DENIED(HttpStatus.FORBIDDEN) + ACCESS_DENIED(HttpStatus.FORBIDDEN), ; private final HttpStatus httpStatus; diff --git a/server/src/main/java/ru/tubryansk/tdms/dto/GroupDTO.java b/server/src/main/java/ru/tubryansk/tdms/dto/GroupDTO.java index 649cf1d..9458955 100644 --- a/server/src/main/java/ru/tubryansk/tdms/dto/GroupDTO.java +++ b/server/src/main/java/ru/tubryansk/tdms/dto/GroupDTO.java @@ -6,8 +6,8 @@ public record GroupDTO(String name, UserDTO principalUser) { public static GroupDTO from(Group group) { return new GroupDTO( - group.getName(), - UserDTO.from(group.getPrincipalUser(), true) + group.getName(), + UserDTO.from(group.getPrincipalUser(), true) ); } } diff --git a/server/src/main/java/ru/tubryansk/tdms/dto/StudentDTO.java b/server/src/main/java/ru/tubryansk/tdms/dto/StudentDTO.java index ddea302..726d623 100644 --- a/server/src/main/java/ru/tubryansk/tdms/dto/StudentDTO.java +++ b/server/src/main/java/ru/tubryansk/tdms/dto/StudentDTO.java @@ -30,22 +30,22 @@ public class StudentDTO { public static StudentDTO from(Student student) { return new StudentDTO( - student.getForm(), - student.getProtectionOrder(), - student.getMagistracy(), - student.getDigitalFormatPresent(), - student.getMarkComment(), - student.getMarkPractice(), - student.getPredefenceComment(), - student.getNormalControl(), - student.getAntiPlagiarism(), - student.getNote(), - student.getRecordBookReturned(), - student.getWork(), - UserDTO.from(student.getUser(), true), - student.getDiplomaTopic().getName(), - UserDTO.from(student.getMentorUser(), true), - GroupDTO.from(student.getGroup()) + student.getForm(), + student.getProtectionOrder(), + student.getMagistracy(), + student.getDigitalFormatPresent(), + student.getMarkComment(), + student.getMarkPractice(), + student.getPredefenceComment(), + student.getNormalControl(), + student.getAntiPlagiarism(), + student.getNote(), + student.getRecordBookReturned(), + student.getWork(), + UserDTO.from(student.getUser(), true), + student.getDiplomaTopic().getName(), + UserDTO.from(student.getMentorUser(), true), + GroupDTO.from(student.getGroup()) ); } } diff --git a/server/src/main/java/ru/tubryansk/tdms/dto/UserDTO.java b/server/src/main/java/ru/tubryansk/tdms/dto/UserDTO.java index cb2f0b2..9a24e53 100644 --- a/server/src/main/java/ru/tubryansk/tdms/dto/UserDTO.java +++ b/server/src/main/java/ru/tubryansk/tdms/dto/UserDTO.java @@ -12,33 +12,33 @@ import java.util.List; @Builder @JsonInclude(JsonInclude.Include.NON_ABSENT) public record UserDTO( - boolean authenticated, - String login, - String password, - String fullName, - String email, - String phone, - ZonedDateTime createdAt, - ZonedDateTime updatedAt, - List authorities) { + boolean authenticated, + String login, + String password, + String fullName, + String email, + String phone, + ZonedDateTime createdAt, + ZonedDateTime updatedAt, + List authorities) { public static UserDTO unauthenticated() { return UserDTO.builder() - .authenticated(false) - .build(); + .authenticated(false) + .build(); } public static UserDTO from(User user, boolean anonymize) { return UserDTO.builder() - .authenticated(true) - .login(user.getLogin()) - .password(anonymize ? "" : user.getPassword()) - .fullName(user.getFullName()) - .email(user.getMail()) - .phone(user.getNumberPhone()) - .createdAt(user.getCreatedAt()) - .updatedAt(user.getUpdatedAt()) - .authorities(RoleDTO.from(user)) - .build(); + .authenticated(true) + .login(user.getLogin()) + .password(anonymize ? "" : user.getPassword()) + .fullName(user.getFullName()) + .email(user.getMail()) + .phone(user.getNumberPhone()) + .createdAt(user.getCreatedAt()) + .updatedAt(user.getUpdatedAt()) + .authorities(RoleDTO.from(user)) + .build(); } } diff --git a/server/src/main/java/ru/tubryansk/tdms/entity/DiplomaTopic.java b/server/src/main/java/ru/tubryansk/tdms/entity/DiplomaTopic.java index 742202c..616a46e 100644 --- a/server/src/main/java/ru/tubryansk/tdms/entity/DiplomaTopic.java +++ b/server/src/main/java/ru/tubryansk/tdms/entity/DiplomaTopic.java @@ -13,12 +13,12 @@ import lombok.Setter; @Setter @NoArgsConstructor @AllArgsConstructor -@Table(name = "diploma_topic", schema = "vkr") +@Table(name = "diploma_topic") public class DiplomaTopic { @Id @Column(name = "id") - @GeneratedValue(strategy = GenerationType.IDENTITY)//Макс из-за SEQUENCE прога лежит, если хочешь, можешь менять я не понял что не нравиться при сборке - private Integer id; - @Column(name = "name", nullable = false) + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + @Column(name = "name") private String name; } diff --git a/server/src/main/java/ru/tubryansk/tdms/entity/Group.java b/server/src/main/java/ru/tubryansk/tdms/entity/Group.java index 4293d27..218c15d 100644 --- a/server/src/main/java/ru/tubryansk/tdms/entity/Group.java +++ b/server/src/main/java/ru/tubryansk/tdms/entity/Group.java @@ -13,15 +13,15 @@ import lombok.Setter; @Setter @NoArgsConstructor @AllArgsConstructor -@Table(name = "group", schema = "vkr") +@Table(name = "group") public class Group { @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - @Column(name = "name", nullable = false) + private Long id; + @Column(name = "name") private String name; @ManyToOne() - @JoinColumn(name = "principal_user_id", nullable = false) + @JoinColumn(name = "principal_user_id") private User principalUser; } diff --git a/server/src/main/java/ru/tubryansk/tdms/entity/Role.java b/server/src/main/java/ru/tubryansk/tdms/entity/Role.java index 357f3e1..7cd51b1 100644 --- a/server/src/main/java/ru/tubryansk/tdms/entity/Role.java +++ b/server/src/main/java/ru/tubryansk/tdms/entity/Role.java @@ -15,14 +15,14 @@ import org.springframework.security.core.GrantedAuthority; @Setter @NoArgsConstructor @AllArgsConstructor -@Table(name = "role", schema = "vkr") +@Table(name = "role") public class Role implements GrantedAuthority { @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - @Column(name = "name", nullable = false) + private Long id; + @Column(name = "name") private String name; - @Column(name = "authority", nullable = false) + @Column(name = "authority") private String authority; } diff --git a/server/src/main/java/ru/tubryansk/tdms/entity/Student.java b/server/src/main/java/ru/tubryansk/tdms/entity/Student.java index 8c5ceef..720b2b0 100644 --- a/server/src/main/java/ru/tubryansk/tdms/entity/Student.java +++ b/server/src/main/java/ru/tubryansk/tdms/entity/Student.java @@ -3,23 +3,21 @@ package ru.tubryansk.tdms.entity; import jakarta.persistence.*; import lombok.Data; -import org.springframework.context.annotation.Scope; -import org.springframework.web.context.annotation.SessionScope; @Data @Entity -@Table(name = "student", schema = "vkr") +@Table(name = "student") public class Student { @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; + private Long id; @Column(name = "form") private Boolean form; - @Column(name = "protection_order" , nullable = false) + @Column(name = "protection_order") private Integer protectionOrder; - @Column(name = "magistracy" ) + @Column(name = "magistracy") private String magistracy; @Column(name = "digital_format_present") private Boolean digitalFormatPresent; @@ -38,17 +36,17 @@ public class Student { @Column(name = "record_book_returned") private Boolean recordBookReturned; @Column(name = "work") - private String work; + private String work; @OneToOne - @JoinColumn(name = "user_id", nullable = false) + @JoinColumn(name = "user_id") private User user; @ManyToOne - @JoinColumn(name = "diploma_topic_id", nullable = false) - private DiplomaTopic diplomaTopic; + @JoinColumn(name = "diploma_topic_id") + private DiplomaTopic diplomaTopic; @ManyToOne - @JoinColumn(name = "mentor_user_id", nullable = false) + @JoinColumn(name = "mentor_user_id") private User mentorUser; @ManyToOne - @JoinColumn(name = "group_id", nullable = false) + @JoinColumn(name = "group_id") private Group group; } diff --git a/server/src/main/java/ru/tubryansk/tdms/entity/User.java b/server/src/main/java/ru/tubryansk/tdms/entity/User.java index 99edcc2..9236f14 100644 --- a/server/src/main/java/ru/tubryansk/tdms/entity/User.java +++ b/server/src/main/java/ru/tubryansk/tdms/entity/User.java @@ -20,35 +20,38 @@ import java.util.List; @Setter @NoArgsConstructor @AllArgsConstructor -@Table(name = "user", schema = "vkr") +@Table(name = "user") public class User implements UserDetails { @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - @Column(name = "login", nullable = false, unique = true) + private Long id; + @Column(name = "login") private String login; - @Column(name = "password", nullable = false) + @Column(name = "password") private String password; - @Column(name = "full_name", nullable = false) + @Column(name = "full_name") private String fullName; - @Column(name = "mail", nullable = false, unique = true) + @Column(name = "mail") private String mail; - @Column(name = "number_phone", nullable = false, unique = true) + @Column(name = "number_phone") private String numberPhone; - @Column(name = "created_at", nullable = false) + @Column(name = "created_at") private ZonedDateTime createdAt; @Column(name = "updated_at") private ZonedDateTime updatedAt; @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) - @JoinTable(name = "user_role",schema = "vkr", + @JoinTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id")) private List roles; @Override public Collection getAuthorities() { - return roles.stream().map(Role::getAuthority).map(SimpleGrantedAuthority::new).toList(); + return roles.stream() + .map(Role::getAuthority) + .map(SimpleGrantedAuthority::new) + .toList(); } @Override diff --git a/server/src/main/java/ru/tubryansk/tdms/service/CallerService.java b/server/src/main/java/ru/tubryansk/tdms/service/CallerService.java new file mode 100644 index 0000000..4fdebb5 --- /dev/null +++ b/server/src/main/java/ru/tubryansk/tdms/service/CallerService.java @@ -0,0 +1,21 @@ +package ru.tubryansk.tdms.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Service; +import ru.tubryansk.tdms.entity.User; + +import java.util.Optional; + +@Service +public class CallerService { + @Autowired + private AuthenticationService authenticationService; + + public Optional getCallerUser() { + if(authenticationService.authenticated()) { + return Optional.of((User) SecurityContextHolder.getContext().getAuthentication().getPrincipal()); + } + return Optional.empty(); + } +} diff --git a/server/src/main/java/ru/tubryansk/tdms/service/StudentService.java b/server/src/main/java/ru/tubryansk/tdms/service/StudentService.java index 2b61f9a..1117798 100644 --- a/server/src/main/java/ru/tubryansk/tdms/service/StudentService.java +++ b/server/src/main/java/ru/tubryansk/tdms/service/StudentService.java @@ -22,7 +22,7 @@ public class StudentService { @Autowired private Optional student; @Autowired - private UserService userService; + private CallerService callerService; /** @param studentToDiplomaTopic Map of @{@link Student} id and @{@link DiplomaTopic} id */ public void changeDiplomaTopic(Map studentToDiplomaTopic) { @@ -41,6 +41,6 @@ public class StudentService { } public Optional getCallerStudent() { - return studentRepository.findByUser(userService.getCallerUser().orElse(null)); + return studentRepository.findByUser(callerService.getCallerUser().orElse(null)); } } diff --git a/server/src/main/java/ru/tubryansk/tdms/service/UserService.java b/server/src/main/java/ru/tubryansk/tdms/service/UserService.java index 1c9f934..b6d4b71 100644 --- a/server/src/main/java/ru/tubryansk/tdms/service/UserService.java +++ b/server/src/main/java/ru/tubryansk/tdms/service/UserService.java @@ -18,19 +18,10 @@ import java.util.Optional; public class UserService implements UserDetailsService { @Autowired private UserRepository userRepository; - @Autowired - private AuthenticationService authenticationService; @Override public User loadUserByUsername(String username) throws UsernameNotFoundException { return userRepository.findUserByLogin(username) .orElseThrow(() -> new UsernameNotFoundException("User not found")); } - - public Optional getCallerUser() { - if(authenticationService.authenticated()) { - return Optional.of((User) SecurityContextHolder.getContext().getAuthentication().getPrincipal()); - } - return Optional.empty(); - } } diff --git a/server/src/main/resources/application-dev.yml b/server/src/main/resources/application-dev.yml index 611b58e..9db06b5 100644 --- a/server/src/main/resources/application-dev.yml +++ b/server/src/main/resources/application-dev.yml @@ -4,8 +4,6 @@ application: domain: localhost protocol: http spring: - flyway: - out-of-order: true web: resources: static-locations: file:///${user.dir}/web/dist/ diff --git a/server/src/main/resources/application.yml b/server/src/main/resources/application.yml index 2666244..03fd8a6 100644 --- a/server/src/main/resources/application.yml +++ b/server/src/main/resources/application.yml @@ -1,21 +1,19 @@ db: - url: jdbc:postgresql://localhost:5432/db + url: jdbc:postgresql://localhost:5400/tdms + schema: public user: root password: root - schema: vkr application: name: @name@ version: @version@ type: production - port: 443 + port: 80 domain: tdms.tu-bryansk.ru - protocol: https + protocol: http spring: application: name: ${application.name} - main: - allow-circular-references: true datasource: url: ${db.url} username: ${db.user} @@ -30,7 +28,8 @@ spring: user: ${db.user} password: ${db.password} schemas: ${db.schema} - locations: db.migration + main: + banner-mode: off server: port: ${application.port} address: ${application.domain} diff --git a/server/src/main/resources/db.migration/V00001__Create__role_table.sql b/server/src/main/resources/db.migration/V00001__Create__role_table.sql deleted file mode 100644 index f36f64e..0000000 --- a/server/src/main/resources/db.migration/V00001__Create__role_table.sql +++ /dev/null @@ -1,6 +0,0 @@ -create table vkr.role -( - id integer primary key generated by default as identity, - name text not null unique, - authority text not null unique -) diff --git a/server/src/main/resources/db.migration/V00010__Create__user_table.sql b/server/src/main/resources/db.migration/V00010__Create__user_table.sql deleted file mode 100644 index 9e29fde..0000000 --- a/server/src/main/resources/db.migration/V00010__Create__user_table.sql +++ /dev/null @@ -1,12 +0,0 @@ -create table vkr.user -( - id integer primary key generated by default as identity, - login text not null unique, - password text not null, - full_name text not null, - mail text not null unique, - number_phone text not null unique, - created_at timestamp(6) with time zone not null, - updated_at timestamp(6) with time zone - -) diff --git a/server/src/main/resources/db.migration/V00020__Create__user_role_table.sql b/server/src/main/resources/db.migration/V00020__Create__user_role_table.sql deleted file mode 100644 index a4e5da3..0000000 --- a/server/src/main/resources/db.migration/V00020__Create__user_role_table.sql +++ /dev/null @@ -1,9 +0,0 @@ -create table vkr.user_role -( - user_id integer not null, - role_id integer not null, - foreign key (user_id) references vkr.user (id) - on delete cascade, - foreign key (role_id) references vkr.role (id) - on delete cascade -) diff --git a/server/src/main/resources/db.migration/V00030__Create__diploma_topic_table.sql b/server/src/main/resources/db.migration/V00030__Create__diploma_topic_table.sql deleted file mode 100644 index 03662da..0000000 --- a/server/src/main/resources/db.migration/V00030__Create__diploma_topic_table.sql +++ /dev/null @@ -1,5 +0,0 @@ -create table vkr.diploma_topic -( - id integer primary key generated by default as identity, - name text not null unique -) diff --git a/server/src/main/resources/db.migration/V00040__Create__group_table.sql b/server/src/main/resources/db.migration/V00040__Create__group_table.sql deleted file mode 100644 index 0d02d27..0000000 --- a/server/src/main/resources/db.migration/V00040__Create__group_table.sql +++ /dev/null @@ -1,9 +0,0 @@ -create table vkr.group -( - id integer primary key generated by default as identity, - name text not null unique, - principal_user_id integer not null, - foreign key (principal_user_id) references vkr.user (id) - on delete cascade - -) diff --git a/server/src/main/resources/db.migration/V00050__Create__student_table.sql b/server/src/main/resources/db.migration/V00050__Create__student_table.sql deleted file mode 100644 index 73b6224..0000000 --- a/server/src/main/resources/db.migration/V00050__Create__student_table.sql +++ /dev/null @@ -1,24 +0,0 @@ -create table vkr.student -( - id integer primary key generated by default as identity, - form boolean, - protection_order integer not null, - magistracy text, - digital_format_present boolean, - mark_comment integer, - mark_practice integer, - predefence_comment text, - normal_control text, - anti_plagiarism int, - note text, - record_book_returned boolean, - work text, - user_id integer not null, - diploma_topic_id integer not null, - mentor_user_id integer not null, - group_id integer not null, - foreign key (user_id) references vkr.user (id) on delete cascade, - foreign key (diploma_topic_id) references vkr.diploma_topic (id) on delete cascade, - foreign key (mentor_user_id) references vkr.user (id) on delete cascade, - foreign key (group_id) references vkr.group (id) on delete cascade -) diff --git a/server/src/main/resources/db.migration/V0060__Insert_base_cases_in__user.sql b/server/src/main/resources/db.migration/V0060__Insert_base_cases_in__user.sql deleted file mode 100644 index 7c73a32..0000000 --- a/server/src/main/resources/db.migration/V0060__Insert_base_cases_in__user.sql +++ /dev/null @@ -1,96 +0,0 @@ -INSERT INTO vkr.user (login, password, full_name, mail, number_phone, created_at, updated_at) -VALUES ('akulenko_mikhail', 'password123', 'Акуленко Михаил Вячеславович', 'akulenko.mikhail@example.com', - '+79110000001', NOW(), NOW()), - ('borovikov_artem', 'password123', 'Боровиков Артём Викторович', 'borovikov.artem@example.com', '+79110000002', - NOW(), NOW()), - ('bykonya_alexey', 'password123', 'Быконя Алексей Николаевич', 'bykonya.alexey@example.com', '+79110000003', - NOW(), NOW()), - ('ermakov_alexander', 'password123', 'Ермаков Александр Сергеевич', 'ermakov.alexander@example.com', - '+79110000004', NOW(), NOW()), - ('zgursky_evgeny', 'password123', 'Згурский Евгений Олегович', 'zgursky.evgeny@example.com', '+79110000005', - NOW(), NOW()), - ('ibishov_tural', 'password123', 'Ибишов Турал Садай оглы', 'ibishov.tural@example.com', '+79110000006', NOW(), - NOW()), - ('ignatenko_vladimir', 'password123', 'Игнатенко Владимир Алексеевич', 'ignatenko.vladimir@example.com', - '+79110000007', NOW(), NOW()), - ('lazukin_danila', 'password123', 'Лазукин Данила Дмитриевич', 'lazukin.danila@example.com', '+79110000008', - NOW(), NOW()), - ('mitiaev_danila', 'password123', 'Митяев Данила Алексеевич', 'mitiaev.danila@example.com', '+79110000009', - NOW(), NOW()), - ('neshkov_daniil', 'password123', 'Нешков Даниил Владимирович', 'neshkov.daniil@example.com', '+79110000010', - NOW(), NOW()), - ('petrov_pavel', 'password123', 'Петров Павел Сергеевич', 'petrov.pavel@example.com', '+79110000011', NOW(), - NOW()), - ('sazonov_andrey', 'password123', 'Сазонов Андрей Андреевич', 'sazonov.andrey@example.com', '+79110000012', - NOW(), NOW()), - ('solokhin_maxim', 'password123', 'Солохин Максим Николаевич', 'solokhin.maxim@example.com', '+79110000013', - NOW(), NOW()), - ('sochinsky_artem', 'password123', 'Сочинский Артем Александрович', 'sochinsky.artem@example.com', - '+79110000014', NOW(), NOW()), - ('trisvyatsky_kirill', 'password123', 'Трисвятский Кирилл Андреевич', 'trisvyatsky.kirill@example.com', - '+79110000015', NOW(), NOW()), - ('turov_alexander', 'password123', 'Туров Александр Сергеевич', 'turov.alexander@example.com', '+79110000016', - NOW(), NOW()), - ('shevtsova_alexandra', 'password123', 'Шевцова Александра Валерьевна', 'shevtsova.alexandra@example.com', - '+79110000017', NOW(), NOW()), - ('kibalyuk_artem', 'password123', 'Кибалюк Артем Сергеевич', 'kibalyuk.artem@example.com', '+79110000018', NOW(), - NOW()), - ('shulindin_artem', 'password123', 'Шулындин Артём Андреевич', 'shulindin.artem@example.com', '+79110000019', - NOW(), NOW()), - ('belyaev_egor', 'password123', 'Беляев Егор Андреевич', 'belyaev.egor@example.com', '+79110000020', NOW(), - NOW()), - ('berezhnoy_igor', 'password123', 'Бережной Игорь Александрович', 'berezhnoy.igor@example.com', '+79110000021', - NOW(), NOW()), - ('bogun_pavel', 'password123', 'Богун Павел Сергеевич', 'bogun.pavel@example.com', '+79110000022', NOW(), NOW()), - ('vaseykin_nikita', 'password123', 'Васейкин Никита Павлович', 'vaseykin.nikita@example.com', '+79110000023', - NOW(), NOW()), - ('gomonov_nikita', 'password123', 'Гомонов Никита Алексеевич', 'gomonov.nikita@example.com', '+79110000024', - NOW(), NOW()), - ('druyan_oleg', 'password123', 'Друян Олег Викторович', 'druyan.oleg@example.com', '+79110000025', NOW(), NOW()), - ('ivanov_kirill', 'password123', 'Иванов Кирилл Эдуардович', 'ivanov.kirill@example.com', '+79110000026', NOW(), - NOW()), - ('ivanova_veronika', 'password123', 'Иванова Вероника Евгеньевна', 'ivanova.veronika@example.com', - '+79110000027', NOW(), NOW()), - ('izotov_ivan', 'password123', 'Изотов Иван Алексеевич', 'izotov.ivan@example.com', '+79110000028', NOW(), - NOW()), - ('isakov_zahar', 'password123', 'Исаков Захар Александрович', 'isakov.zahar@example.com', '+79110000029', NOW(), - NOW()), - ('iskritsky_daniil', 'password123', 'Искрицкий Даниил Павлович', 'iskritsky.daniil@example.com', '+79110000030', - NOW(), NOW()), - ('linko_daria', 'password123', 'Линько Дарья Андреевна', 'linko.daria@example.com', '+79110000031', NOW(), - NOW()), - ('logutov_kirill', 'password123', 'Логутов Кирилл Александрович', 'logutov.kirill@example.com', '+79110000032', - NOW(), NOW()), - ('nekrassov_sergey', 'password123', 'Некрасов Сергей Игоревич', 'nekrassov.sergey@example.com', '+79110000033', - NOW(), NOW()), - ('sinyagin_ilya', 'password123', 'Синягин Илья Александрович', 'sinyagin.ilya@example.com', '+79110000034', - NOW(), NOW()), - ('sopriko_daniil', 'password123', 'Соприко Даниил Сергеевич', 'sopriko.daniil@example.com', '+79110000035', - NOW(), NOW()), - ('turovsky_ivan', 'password123', 'Туровский Иван Алексеевич', 'turovsky.ivan@example.com', '+79110000036', NOW(), - NOW()), - ('frantsev_sergey', 'password123', 'Францев Сергей Дмитриевич', 'frantsev.sergey@example.com', '+79110000037', - NOW(), NOW()), - ('chepurnoy_maxim', 'password123', 'Чепурной Максим Романович', 'chepurnoy.maxim@example.com', '+79110000038', - NOW(), NOW()), - ('schemelinin_dmitry', 'password123', 'Щемелинин Дмитрий Михайлович', 'schemelinin.dmitry@example.com', - '+79110000039', NOW(), NOW()), - ('bulatitsky_d_i_1', 'password123', 'Булатицкий Д. И.', 'bulatitsky.d.i.1@example.com', '+79110000040', NOW(), - NOW()), - ('kopeliovich_d_i_1', 'password123', 'Копелиович Д. И.', 'kopeliovich.d.i.1@example.com', '+79110000041', NOW(), - NOW()), - ('dergachev_k_v', 'password123', 'Дергачев К. В.', 'dergachev.k.v@example.com', '+79110000042', NOW(), NOW()), - ('trubakov_e_o', 'password123', 'Трубаков Е. О.', 'trubakov.e.o@example.com', '+79110000043', NOW(), NOW()), - ('radchenko_a_o', 'password123', 'Радченко А. О.', 'radchenko.a.o@example.com', '+79110000044', NOW(), NOW()), - ('zimin_s_n_1', 'password123', 'Зимин С. Н.', 'zimin.s.n.1@example.com', '+79110000045', NOW(), NOW()), - ('koptenok_e_v', 'password123', 'Коптенок Е. В.', 'koptenok.e.v@example.com', '+79110000046', NOW(), NOW()), - ('mikhaleva_o_a', 'password123', 'Михалева О. А.', 'mikhaleva.o.a@example.com', '+79110000047', NOW(), NOW()), - ('gulakov_k_v', 'password123', 'Гулаков К. В.', 'gulakov.k.v@example.com', '+79110000048', NOW(), NOW()), - ('titarev_d_v', 'password123', 'Титарёв Д. В.', 'titarev.d.v@example.com', '+79110000049', NOW(), NOW()), - ('izrailev_v_ya_1', 'password123', 'Израилев В. Я.', 'izrailev.v.ya.1@example.com', '+79110000050', NOW(), - NOW()), - ('podvesovsky_a_g_1', 'password123', 'Подвесовский А. Г.', 'podvesovsky.a.g.1@example.com', '+79110000051', - NOW(), NOW()), - ('trubakov_a_o', 'password123', 'Трубаков А. О.', 'trubakov.a.o@example.com', '+79110000059', - NOW(), NOW()), - ('lageriev_d_g', 'password123', 'Лагерев Д. Г.', 'lageriev.d.g@example.com', '+79110000052', NOW(), NOW()); diff --git a/server/src/main/resources/db.migration/V0061__Update_test_passwords_in__user.sql b/server/src/main/resources/db.migration/V0061__Update_test_passwords_in__user.sql deleted file mode 100644 index 7f91387..0000000 --- a/server/src/main/resources/db.migration/V0061__Update_test_passwords_in__user.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE vkr.user SET password = '{noop}1'; \ No newline at end of file diff --git a/server/src/main/resources/db.migration/V0065__Insert_base_cases_in__group.sql b/server/src/main/resources/db.migration/V0065__Insert_base_cases_in__group.sql deleted file mode 100644 index bbd2126..0000000 --- a/server/src/main/resources/db.migration/V0065__Insert_base_cases_in__group.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO vkr.group (name ,principal_user_id) -VALUES('ИВТ-1',40),('ИВТ-2',40); diff --git a/server/src/main/resources/db.migration/V0070__Insert_base_cases_in__role.sql b/server/src/main/resources/db.migration/V0070__Insert_base_cases_in__role.sql deleted file mode 100644 index a764327..0000000 --- a/server/src/main/resources/db.migration/V0070__Insert_base_cases_in__role.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO vkr.role (name,authority) -VALUES('Руководитель','ROLE_DIRECTOR'),('Куратор','ROLE_TUTOR'),('Студент','ROLE_STUDENT'); diff --git a/server/src/main/resources/db.migration/V0075__Insert_base_cases_in__student.sql b/server/src/main/resources/db.migration/V0075__Insert_base_cases_in__student.sql deleted file mode 100644 index ae326f6..0000000 --- a/server/src/main/resources/db.migration/V0075__Insert_base_cases_in__student.sql +++ /dev/null @@ -1,73 +0,0 @@ -INSERT INTO vkr.student (form, - protection_order, - magistracy, - digital_format_present, - mark_comment, - mark_practice, - predefence_comment, - normal_control, - anti_plagiarism, - note, - record_book_returned, - work, - user_id, - diploma_topic_id, - mentor_user_id, - group_id) -VALUES (true, 1100, 'ПРИ, ИВТ или другой вуз', true, 5, 5, 'ок', 'Подписано', 7862, 'Акт о внедрении', true, 'нет', 1, - 1, 40, 1), - (true, 1110, 'Да, но не уверен, в БГТУ ли', true, 5, 5, 'ок', 'Подписано', 8196, 'Заявка, Акт о внедрении', true, - 'ООО "ЦИРОБЗ"', 2, 2, 40, 1), - (true, 3500, 'Нет', true, 3, 3, 'Критически низкий уровень. Допущен под ответственность руководителя ВКР', - 'Подписано', 7141, 'Иниц', true, 'нет', 3, 3, 41, 1), - (true, 1800, 'Да, но не уверен, в БГТУ ли', true, 4, 5, 'Усилить работу', 'Подписано', 5381, 'Иниц', true, 'нет', - 4, 4, 42, 1), - (true, 2100, 'ИВТ, ПРИ', true, 5, 5, 'ок', 'Подписано', 8146, 'Заявка, Акт о внедрении', true, 'нет', 5, 5, 43, - 1), - (true, 1100, 'ИВТ, ПРИ', true, 5, 5, 'ок', 'Подписано', 7965, 'Иниц', true, 'нет', 6, 6, 41, 1), - (true, 1200, 'нет', true, 5, 4, 'Усилить работу', 'Подписано', 8583, Null, true, 'Газ Энерго Комплект (ГЭК)', 7, - 7, 44, 1), - (true, 1700, 'Нет', true, 5, 5, 'Критически низкий уровень. Допущен под ответственность руководителя ВКР', - 'Подписано', 6647, Null, true, 'нет', 8, 8, 45, 1), - (true, 3300, 'ИВТ, ПРИ или другой вуз', true, 5, 5, 'Усилить работу', 'Подписано', 6741, - 'Заявка, Акт о внедрении', true, 'нет', 9, 9, 46, 1), - (true, 1200, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 7645, 'Заявка, Акт о внедрении', true, 'нет', 10, 10, 40, 1), - (true, 3700, 'нет', true, 3, 3, 'Критически низкий уровень. Допущен под ответственность руководителя ВКР', '1', - 3093, 'Иниц', true, 'нет', 11, 11, 45, 1), - (true, 1900, 'Нет', true, 5, 5, 'ок', 'Подписано', 8175, 'Заявка, Акт о внедрении', true, 'нет', 12, 12, 42, 1), - (true, 3200, 'ИВТ', true, 5, 5, 'Усилить работу', 'Подписано', 7805, 'Акт', true, 'нет', 13, 13, 46, 1), - (true, 1200, 'ИВТ, ПРИ', true, 4, 4, 'ок', 'рек', 7590, 'Иниц', true, 'нет', 14, 14, 45, 1), - (true, 3900, 'нет', true, 5, 5, 'Усилить работу', 'Подписано', 6463, 'Заявка, Акт о внедрении', true, 'нет', 15, - 15, 40, 1), - (true, 2200, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 7441, Null, true, 'ООО "ЦИРОБЗ"', 16, 16, 44, 1), - (true, 1130, 'Нет', true, 5, 4, 'Критически низкий уровень. Допущен под ответственность руководителя ВКР', - 'Подписано', 7319, 'Заявка, Акт о внедрении', true, 'нет', 17, 17, 40, 1), - (true, 2400, 'ИВТ', true, 4, 5, 'ок', 'Подписано', 6436, Null, true, 'нет', 18, 18, 45, 1), - (true, 1600, 'ИВТ', true, 5, 5, 'Усилить работу', 'Подписано', 6227, 'Исслед', true, 'АО "БЭМЗ"', 19, 19, 47, 1), - (true, 1400, 'Нет', true, 5, 5, 'ок', 'Подписано', 8935, 'Иниц', true, 'ООО "ЦИРОБЗ"', 20, 20, 44, 2), - (true, 2900, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 7971, 'Заявка, Акт о внедрении', true, 'нет', 21, 21, 40, 2), - (true, 2600, 'ИВТ, ПРИ', true, 3, 3, 'ок', 'Подписано', 7284, Null, true, 'нет', 22, 22, 48, 2), - (true, 3100, 'ИВТ, ПРИ', true, 5, 5, 'Усилить работу', 'Подписано', 4966, 'Заявка, Акт о внедрении', true, 'нет', - 23, 23, 45, 2), - (true, 3110, 'Нет', true, 5, 5, 'ок', 'Подписано', 7174, Null, true, 'нет', 24, 24, 40, 2), - (true, 3800, 'Нет', true, 5, 5, 'ок', 'Подписано', 7233, Null, true, 'нет', 25, 25, 45, 2), - (true, 3300, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 7133, Null, true, 'нет', 26, 26, 43, 2), - (true, 3130, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 8083, 'Заявка, Акт о внедрении', true, 'нет', 27, 27, 49, 2), - (true, 3400, 'Нет', true, 5, 4, 'Критически низкий уровень. Допущен под ответственность руководителя ВКР', - 'Подписано', 7968, 'Иниц', true, 'нет', 28, 28, 50, 2), - (true, 3120, 'ИВТ или ПРИ', true, 5, 5, 'ок', 'Подписано', 7940, 'Исслед', true, 'ООО "ЦИРОБЗ"', 29, 29, 40, 2), - (true, 2800, 'Нет (возможно)', true, 4, 4, 'Усилить работу', 'рек', 6775, 'Заявка, Акт о внедрении', true, 'нет', - 30, 30, 40, 2), - (true, 2100, 'Нет (возможно)', true, 5, 5, 'ок', 'Подписано', 7637, 'Заявка, Акт о внедрении', true, 'нет', 31, - 31, 40, 2), - (true, 2700, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 8544, 'Заявка, Акт о внедрении', true, 'нет', 32, 32, 45, 2), - (true, 2130, 'ИВТ, ПРИ', true, 5, 5, 'ок', 'Подписано', 7166, 'Заявка, Акт о внедрении', true, 'нет', 33, 33, 51, - 2), - (true, 2110, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 6075, 'Заявка, Акт о внедрении', true, 'нет', 34, 34, 52, 2), - (true, 3100, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 7057, 'Заявка, Акт о внедрении', true, 'нет', 35, 35, 50, 2), - (true, 2120, 'В БГТУ на другой кафедре (38.04.01 Экономика или 27.04.05. Инноватика)', true, 5, 5, 'ок', - 'Подписано', 7057, 'Заявка, Акт о внедрении', true, 'нет', 36, 36, 51, 2), - (true, 2500, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 6583, 'Заявка, Акт о внедрении', true, 'нет', 37, 37, 53, 2), - (true, 1300, 'ИВТ, ПРИ', true, 5, 5, 'ок', 'Подписано', 8444, 'Заявка, Акт о внедрении', true, 'нет', 38, 38, 44, - 2), - (true, 3600, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 7631, 'Заявка, Акт о внедрении', true, 'нет', 39, 39, 45, 2); diff --git a/server/src/main/resources/db.migration/V0080__Insert_base_cases_in__user_role.sql b/server/src/main/resources/db.migration/V0080__Insert_base_cases_in__user_role.sql deleted file mode 100644 index f4fda05..0000000 --- a/server/src/main/resources/db.migration/V0080__Insert_base_cases_in__user_role.sql +++ /dev/null @@ -1,55 +0,0 @@ -INSERT INTO vkr.user_role (user_id, role_id) -VALUES (1, 3), - (2, 3), - (3, 3), - (4, 3), - (5, 3), - (6, 3), - (7, 3), - (8, 3), - (9, 3), - (10, 3), - (11, 3), - (12, 3), - (13, 3), - (14, 3), - (15, 3), - (16, 3), - (17, 3), - (18, 3), - (19, 3), - (20, 3), - (21, 3), - (22, 3), - (23, 3), - (24, 3), - (25, 3), - (26, 3), - (27, 3), - (28, 3), - (29, 3), - (30, 3), - (31, 3), - (32, 3), - (33, 3), - (34, 3), - (35, 3), - (36, 3), - (37, 3), - (38, 3), - (39, 3), - (40, 1), - (41, 1), - (42, 1), - (43, 1), - (44, 1), - (45, 1), - (46, 1), - (47, 1), - (48, 1), - (49, 1), - (50, 1), - (51, 1), - (52, 1), - (53, 1), - (40, 2); diff --git a/server/src/main/resources/db/migration/V00010__Create__role_table.sql b/server/src/main/resources/db/migration/V00010__Create__role_table.sql new file mode 100644 index 0000000..9418189 --- /dev/null +++ b/server/src/main/resources/db/migration/V00010__Create__role_table.sql @@ -0,0 +1,10 @@ +create table role +( + id bigint primary key, + name text not null unique, + authority text not null unique +); + +-- COMMENTS +comment on column role.name is 'Человекочитаемое имя роли'; +comment on column role.authority is 'Имя роли в системе'; diff --git a/server/src/main/resources/db/migration/V00020__Create__user_table.sql b/server/src/main/resources/db/migration/V00020__Create__user_table.sql new file mode 100644 index 0000000..8de350a --- /dev/null +++ b/server/src/main/resources/db/migration/V00020__Create__user_table.sql @@ -0,0 +1,20 @@ +create table "user" +( + id bigserial primary key, + login text not null unique, + password text not null, + full_name text not null, + mail text not null unique, + number_phone text not null unique, + created_at timestamptz not null, + updated_at timestamptz +); + +-- COMMENTS +comment on column "user".login is 'Логин пользователя'; +comment on column "user".password is 'Пароль пользователя'; +comment on column "user".full_name is 'Полное имя пользователя в формате Фамилия Имя Отчество'; +comment on column "user".mail is 'Почта пользователя'; +comment on column "user".number_phone is 'Номер телефона пользователя'; +comment on column "user".created_at is 'Дата создания записи'; +comment on column "user".updated_at is 'Дата последнего обновления записи'; diff --git a/server/src/main/resources/db/migration/V00030__Create__user_role_table.sql b/server/src/main/resources/db/migration/V00030__Create__user_role_table.sql new file mode 100644 index 0000000..8f60378 --- /dev/null +++ b/server/src/main/resources/db/migration/V00030__Create__user_role_table.sql @@ -0,0 +1,18 @@ +create table user_role +( + id bigserial primary key, + user_id bigint not null, + role_id bigint not null +); + +-- FOREIGN KEY +alter table user_role + add constraint fk_user_role_user_id + foreign key (user_id) references "user" (id); +alter table user_role + add constraint fk_user_role_role_id + foreign key (role_id) references role (id); + +-- COMMENTS +comment on column user_role.user_id is 'Идентификатор пользователя'; +comment on column user_role.role_id is 'Идентификатор роли'; diff --git a/server/src/main/resources/db/migration/V00040__Create__diploma_topic_table.sql b/server/src/main/resources/db/migration/V00040__Create__diploma_topic_table.sql new file mode 100644 index 0000000..3d70917 --- /dev/null +++ b/server/src/main/resources/db/migration/V00040__Create__diploma_topic_table.sql @@ -0,0 +1,8 @@ +create table diploma_topic +( + id bigserial primary key, + name text not null unique +); + +-- COMMENTS +comment on column diploma_topic.name is 'Название темы дипломной работы'; diff --git a/server/src/main/resources/db/migration/V00050__Create__group_table.sql b/server/src/main/resources/db/migration/V00050__Create__group_table.sql new file mode 100644 index 0000000..cc3e484 --- /dev/null +++ b/server/src/main/resources/db/migration/V00050__Create__group_table.sql @@ -0,0 +1,16 @@ +create table "group" +( + id bigserial primary key, + name text not null unique, + principal_user_id bigint not null +); + +-- FOREIGN KEY +alter table "group" + add constraint fk_group_principal_user_id + foreign key (principal_user_id) references "user" (id) + on delete cascade; + +-- COMMENTS +comment on column "group".name is 'Название группы'; +comment on column "group".principal_user_id is 'Идентификатор куратора группы'; diff --git a/server/src/main/resources/db/migration/V00060__Create__student_table.sql b/server/src/main/resources/db/migration/V00060__Create__student_table.sql new file mode 100644 index 0000000..edb29d0 --- /dev/null +++ b/server/src/main/resources/db/migration/V00060__Create__student_table.sql @@ -0,0 +1,58 @@ +create table student +( + id bigserial primary key, + form boolean, + protection_order integer not null, + magistracy text, + digital_format_present boolean, + mark_comment integer, + mark_practice integer, + predefence_comment text, + normal_control text, + anti_plagiarism int, + note text, + record_book_returned boolean, + work text, + user_id bigint not null, + diploma_topic_id bigint not null, + mentor_user_id bigint not null, + group_id bigint not null, + created_at timestamptz not null, + updated_at timestamptz +); + +-- FOREIGN KEY +alter table student + add constraint fk_student_user_id + foreign key (user_id) references "user" (id) + on delete cascade; +alter table student + add constraint fk_student_diploma_topic_id + foreign key (diploma_topic_id) references diploma_topic (id) + on delete cascade; +alter table student + add constraint fk_student_mentor_user_id + foreign key (mentor_user_id) references "user" (id) + on delete cascade; +alter table student + add constraint fk_student_group_id + foreign key (group_id) references "group" (id) + on delete cascade; + +-- COMMENTS +comment on column student.form is 'Форма обучения'; +comment on column student.protection_order is 'Порядок защиты'; +comment on column student.magistracy is 'Магистратура'; +comment on column student.digital_format_present is 'Предоставлен в электронном виде'; +comment on column student.mark_comment is 'Комментарий к оценке'; +comment on column student.mark_practice is 'Оценка практики'; +comment on column student.predefence_comment is 'Комментарий к защите'; +comment on column student.normal_control is 'Обычный контроль'; +comment on column student.anti_plagiarism is 'Антиплагиат'; +comment on column student.note is 'Примечание'; +comment on column student.record_book_returned is 'Ведомость возвращена'; +comment on column student.work is 'Работа'; +comment on column student.user_id is 'Идентификатор пользователя'; +comment on column student.diploma_topic_id is 'Идентификатор темы дипломной работы'; +comment on column student.mentor_user_id is 'Идентификатор научного руководителя'; +comment on column student.group_id is 'Идентификатор группы'; diff --git a/server/src/main/resources/db/migration/V00500__Insert_default_roles__role.sql b/server/src/main/resources/db/migration/V00500__Insert_default_roles__role.sql new file mode 100644 index 0000000..a108c7d --- /dev/null +++ b/server/src/main/resources/db/migration/V00500__Insert_default_roles__role.sql @@ -0,0 +1,6 @@ +insert into role (id, name, authority) +values (1, 'Преподаватель', 'ROLE_TEACHER'), + (2, 'Студент', 'ROLE_STUDENT'), + (3, 'Член комиссии ГЭК', 'ROLE_COMMISSION_MEMBER'), + (4, 'Администратор', 'ROLE_ADMINISTRATOR'), + (5, 'Секретарь', 'ROLE_SECRETARY'); diff --git a/server/src/main/resources/db/migration/V00510__Insert_administrator.sql b/server/src/main/resources/db/migration/V00510__Insert_administrator.sql new file mode 100644 index 0000000..0c23f02 --- /dev/null +++ b/server/src/main/resources/db/migration/V00510__Insert_administrator.sql @@ -0,0 +1,8 @@ +insert into "user" (id, login, password, full_name, mail, number_phone, created_at) +values (1, 'admin', '{noop}admin', 'Администратор', 'admin@localhost', '+79110000000', now()); + +insert into user_role (id, user_id, role_id) +values (1, 1, 4); + +select setval('user_id_seq', (select max(id) from "user")); +select setval('user_role_id_seq', (select max(id) from user_role)); diff --git a/server/src/main/resources/db/test-data/V00070__Create__defence_table.sql b/server/src/main/resources/db/test-data/V00070__Create__defence_table.sql new file mode 100644 index 0000000..c7e0806 --- /dev/null +++ b/server/src/main/resources/db/test-data/V00070__Create__defence_table.sql @@ -0,0 +1,7 @@ +create table defence +( + id bigserial primary key, + defence_date timestamptz, + created_at timestamptz not null, + updated_at timestamptz +); \ No newline at end of file diff --git a/server/src/main/resources/db.migration/V0055__Insert_base_cases_in__diploma_topic.sql b/server/src/main/resources/db/test-data/diploma_topic.sql similarity index 99% rename from server/src/main/resources/db.migration/V0055__Insert_base_cases_in__diploma_topic.sql rename to server/src/main/resources/db/test-data/diploma_topic.sql index 510c7f4..0294670 100644 --- a/server/src/main/resources/db.migration/V0055__Insert_base_cases_in__diploma_topic.sql +++ b/server/src/main/resources/db/test-data/diploma_topic.sql @@ -1,4 +1,4 @@ -INSERT INTO vkr.diploma_topic (name) +INSERT INTO diploma_topic (name) VALUES ('Мобильное приложение для заказа автозапчастей на платформе ABCP'), ('Подсистема уведомления пользователей для программного комплекса "РискПроф. Учебный центр"'), ('Веб-приложение "Таск-менеджер"'), diff --git a/server/src/main/resources/db/test-data/group.sql b/server/src/main/resources/db/test-data/group.sql new file mode 100644 index 0000000..2f9f72d --- /dev/null +++ b/server/src/main/resources/db/test-data/group.sql @@ -0,0 +1,3 @@ +INSERT INTO "group" (name, principal_user_id) +VALUES ('ИВТ-1', 40), + ('ИВТ-2', 40); diff --git a/server/src/main/resources/db/test-data/student.sql b/server/src/main/resources/db/test-data/student.sql new file mode 100644 index 0000000..d610ec4 --- /dev/null +++ b/server/src/main/resources/db/test-data/student.sql @@ -0,0 +1,98 @@ +do +$$ + begin + INSERT INTO student (form, + protection_order, + magistracy, + digital_format_present, + mark_comment, + mark_practice, + predefence_comment, + normal_control, + anti_plagiarism, + note, + record_book_returned, + work, + user_id, + diploma_topic_id, + mentor_user_id, + group_id, + created_at) + VALUES (true, 1100, 'ПРИ, ИВТ или другой вуз', true, 5, 5, 'ок', 'Подписано', 7862, 'Акт о внедрении', true, + 'нет', 1, 1, 40, 3, now()), + (true, 1110, 'Да, но не уверен, в БГТУ ли', true, 5, 5, 'ок', 'Подписано', 8196, + 'Заявка, Акт о внедрении', true, 'ООО "ЦИРОБЗ"', 2, 2, 40, 3, now()), + (true, 3500, 'Нет', true, 3, 3, + 'Критически низкий уровень. Допущен под ответственность руководителя ВКР', 'Подписано', 7141, 'Иниц', + true, 'нет', 3, 3, 41, 3, now()), + (true, 1800, 'Да, но не уверен, в БГТУ ли', true, 4, 5, 'Усилить работу', 'Подписано', 5381, 'Иниц', + true, 'нет', 4, 4, 42, 3, now()), + (true, 2100, 'ИВТ, ПРИ', true, 5, 5, 'ок', 'Подписано', 8146, 'Заявка, Акт о внедрении', true, 'нет', 5, + 5, 43, 3, now()), + (true, 1100, 'ИВТ, ПРИ', true, 5, 5, 'ок', 'Подписано', 7965, 'Иниц', true, 'нет', 6, 6, 41, 3, now()), + (true, 1200, 'нет', true, 5, 4, 'Усилить работу', 'Подписано', 8583, Null, true, + 'Газ Энерго Комплект (ГЭК)', 7, 7, 44, 3, now()), + (true, 1700, 'Нет', true, 5, 5, + 'Критически низкий уровень. Допущен под ответственность руководителя ВКР', 'Подписано', 6647, Null, + true, 'нет', 8, 8, 45, 3, now()), + (true, 3300, 'ИВТ, ПРИ или другой вуз', true, 5, 5, 'Усилить работу', 'Подписано', 6741, + 'Заявка, Акт о внедрении', true, 'нет', 9, 9, 46, 3, now()), + (true, 1200, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 7645, 'Заявка, Акт о внедрении', true, 'нет', 10, 10, + 40, 3, now()), + (true, 3700, 'нет', true, 3, 3, + 'Критически низкий уровень. Допущен под ответственность руководителя ВКР', '1', 3093, 'Иниц', true, + 'нет', 11, 11, 45, 3, now()), + (true, 1900, 'Нет', true, 5, 5, 'ок', 'Подписано', 8175, 'Заявка, Акт о внедрении', true, 'нет', 12, 12, + 42, 3, now()), + (true, 3200, 'ИВТ', true, 5, 5, 'Усилить работу', 'Подписано', 7805, 'Акт', true, 'нет', 13, 13, 46, 3, + now()), + (true, 1200, 'ИВТ, ПРИ', true, 4, 4, 'ок', 'рек', 7590, 'Иниц', true, 'нет', 14, 14, 45, 3, now()), + (true, 3900, 'нет', true, 5, 5, 'Усилить работу', 'Подписано', 6463, 'Заявка, Акт о внедрении', true, + 'нет', 15, 15, 40, 3, now()), + (true, 2200, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 7441, Null, true, 'ООО "ЦИРОБЗ"', 16, 16, 44, 3, + now()), + (true, 1130, 'Нет', true, 5, 4, + 'Критически низкий уровень. Допущен под ответственность руководителя ВКР', 'Подписано', 7319, + 'Заявка, Акт о внедрении', true, 'нет', 17, 17, 40, 3, now()), + (true, 2400, 'ИВТ', true, 4, 5, 'ок', 'Подписано', 6436, Null, true, 'нет', 18, 18, 45, 3, now()), + (true, 1600, 'ИВТ', true, 5, 5, 'Усилить работу', 'Подписано', 6227, 'Исслед', true, 'АО "БЭМЗ"', 19, 19, + 47, 3, now()), + (true, 1400, 'Нет', true, 5, 5, 'ок', 'Подписано', 8935, 'Иниц', true, 'ООО "ЦИРОБЗ"', 20, 20, 44, 4, + now()), + (true, 2900, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 7971, 'Заявка, Акт о внедрении', true, 'нет', 21, 21, + 40, 4, now()), + (true, 2600, 'ИВТ, ПРИ', true, 3, 3, 'ок', 'Подписано', 7284, Null, true, 'нет', 22, 22, 48, 4, now()), + (true, 3100, 'ИВТ, ПРИ', true, 5, 5, 'Усилить работу', 'Подписано', 4966, 'Заявка, Акт о внедрении', + true, 'нет', 23, 23, 45, 4, now()), + (true, 3110, 'Нет', true, 5, 5, 'ок', 'Подписано', 7174, Null, true, 'нет', 24, 24, 40, 4, now()), + (true, 3800, 'Нет', true, 5, 5, 'ок', 'Подписано', 7233, Null, true, 'нет', 25, 25, 45, 4, now()), + (true, 3300, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 7133, Null, true, 'нет', 26, 26, 43, 4, now()), + (true, 3130, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 8083, 'Заявка, Акт о внедрении', true, 'нет', 27, 27, + 49, 4, now()), + (true, 3400, 'Нет', true, 5, 4, + 'Критически низкий уровень. Допущен под ответственность руководителя ВКР', 'Подписано', 7968, 'Иниц', + true, 'нет', 28, 28, 50, 4, now()), + (true, 3120, 'ИВТ или ПРИ', true, 5, 5, 'ок', 'Подписано', 7940, 'Исслед', true, 'ООО "ЦИРОБЗ"', 29, 29, + 40, 4, now()), + (true, 2800, 'Нет (возможно)', true, 4, 4, 'Усилить работу', 'рек', 6775, 'Заявка, Акт о внедрении', + true, 'нет', 30, 30, 40, 4, now()), + (true, 2100, 'Нет (возможно)', true, 5, 5, 'ок', 'Подписано', 7637, 'Заявка, Акт о внедрении', true, + 'нет', 31, 31, 40, 4, now()), + (true, 2700, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 8544, 'Заявка, Акт о внедрении', true, 'нет', 32, 32, + 45, 4, now()), + (true, 2130, 'ИВТ, ПРИ', true, 5, 5, 'ок', 'Подписано', 7166, 'Заявка, Акт о внедрении', true, 'нет', 33, + 33, 51, 4, now()), + (true, 2110, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 6075, 'Заявка, Акт о внедрении', true, 'нет', 34, 34, + 52, 4, now()), + (true, 3100, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 7057, 'Заявка, Акт о внедрении', true, 'нет', 35, 35, + 50, 4, now()), + (true, 2120, 'В БГТУ на другой кафедре (38.04.01 Экономика или 27.04.05. Инноватика)', true, 5, 5, 'ок', + 'Подписано', 7057, 'Заявка, Акт о внедрении', true, 'нет', 36, 36, 51, 4, now()), + (true, 2500, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 6583, 'Заявка, Акт о внедрении', true, 'нет', 37, 37, + 53, 4, now()), + (true, 1300, 'ИВТ, ПРИ', true, 5, 5, 'ок', 'Подписано', 8444, 'Заявка, Акт о внедрении', true, 'нет', 38, + 38, 44, 4, now()), + (true, 3600, 'ИВТ', true, 5, 5, 'ок', 'Подписано', 7631, 'Заявка, Акт о внедрении', true, 'нет', 39, 39, + 45, 4, now()); + end +$$; \ No newline at end of file diff --git a/server/src/main/resources/db/test-data/user.sql b/server/src/main/resources/db/test-data/user.sql new file mode 100644 index 0000000..7516226 --- /dev/null +++ b/server/src/main/resources/db/test-data/user.sql @@ -0,0 +1,82 @@ +INSERT INTO "user" (login, password, full_name, mail, number_phone, created_at) +VALUES ('akulenko_mikhail', '{noop}1', 'Акуленко Михаил Вячеславович', 'akulenko.mikhail@example.com', + '+79110000001', NOW()), + ('borovikov_artem', '{noop}1', 'Боровиков Артём Викторович', 'borovikov.artem@example.com', '+79110000002', + NOW()), + ('bykonya_alexey', '{noop}1', 'Быконя Алексей Николаевич', 'bykonya.alexey@example.com', '+79110000003', + NOW()), + ('ermakov_alexander', '{noop}1', 'Ермаков Александр Сергеевич', 'ermakov.alexander@example.com', + '+79110000004', NOW()), + ('zgursky_evgeny', '{noop}1', 'Згурский Евгений Олегович', 'zgursky.evgeny@example.com', '+79110000005', + NOW()), + ('ibishov_tural', '{noop}1', 'Ибишов Турал Садай оглы', 'ibishov.tural@example.com', '+79110000006', NOW()), + ('ignatenko_vladimir', '{noop}1', 'Игнатенко Владимир Алексеевич', 'ignatenko.vladimir@example.com', + '+79110000007', NOW()), + ('lazukin_danila', '{noop}1', 'Лазукин Данила Дмитриевич', 'lazukin.danila@example.com', '+79110000008', + NOW()), + ('mitiaev_danila', '{noop}1', 'Митяев Данила Алексеевич', 'mitiaev.danila@example.com', '+79110000009', + NOW()), + ('neshkov_daniil', '{noop}1', 'Нешков Даниил Владимирович', 'neshkov.daniil@example.com', '+79110000010', + NOW()), + ('petrov_pavel', '{noop}1', 'Петров Павел Сергеевич', 'petrov.pavel@example.com', '+79110000011', NOW()), + ('sazonov_andrey', '{noop}1', 'Сазонов Андрей Андреевич', 'sazonov.andrey@example.com', '+79110000012', + NOW()), + ('solokhin_maxim', '{noop}1', 'Солохин Максим Николаевич', 'solokhin.maxim@example.com', '+79110000013', + NOW()), + ('sochinsky_artem', '{noop}1', 'Сочинский Артем Александрович', 'sochinsky.artem@example.com', + '+79110000014', NOW()), + ('trisvyatsky_kirill', '{noop}1', 'Трисвятский Кирилл Андреевич', 'trisvyatsky.kirill@example.com', + '+79110000015', NOW()), + ('turov_alexander', '{noop}1', 'Туров Александр Сергеевич', 'turov.alexander@example.com', '+79110000016', + NOW()), + ('shevtsova_alexandra', '{noop}1', 'Шевцова Александра Валерьевна', 'shevtsova.alexandra@example.com', + '+79110000017', NOW()), + ('kibalyuk_artem', '{noop}1', 'Кибалюк Артем Сергеевич', 'kibalyuk.artem@example.com', '+79110000018', NOW()), + ('shulindin_artem', '{noop}1', 'Шулындин Артём Андреевич', 'shulindin.artem@example.com', '+79110000019', + NOW()), + ('belyaev_egor', '{noop}1', 'Беляев Егор Андреевич', 'belyaev.egor@example.com', '+79110000020', NOW()), + ('berezhnoy_igor', '{noop}1', 'Бережной Игорь Александрович', 'berezhnoy.igor@example.com', '+79110000021', + NOW()), + ('bogun_pavel', '{noop}1', 'Богун Павел Сергеевич', 'bogun.pavel@example.com', '+79110000022', NOW()), + ('vaseykin_nikita', '{noop}1', 'Васейкин Никита Павлович', 'vaseykin.nikita@example.com', '+79110000023', + NOW()), + ('gomonov_nikita', '{noop}1', 'Гомонов Никита Алексеевич', 'gomonov.nikita@example.com', '+79110000024', + NOW()), + ('druyan_oleg', '{noop}1', 'Друян Олег Викторович', 'druyan.oleg@example.com', '+79110000025', NOW()), + ('ivanov_kirill', '{noop}1', 'Иванов Кирилл Эдуардович', 'ivanov.kirill@example.com', '+79110000026', NOW()), + ('ivanova_veronika', '{noop}1', 'Иванова Вероника Евгеньевна', 'ivanova.veronika@example.com', + '+79110000027', NOW()), + ('izotov_ivan', '{noop}1', 'Изотов Иван Алексеевич', 'izotov.ivan@example.com', '+79110000028', NOW()), + ('isakov_zahar', '{noop}1', 'Исаков Захар Александрович', 'isakov.zahar@example.com', '+79110000029', NOW()), + ('iskritsky_daniil', '{noop}1', 'Искрицкий Даниил Павлович', 'iskritsky.daniil@example.com', '+79110000030', + NOW()), + ('linko_daria', '{noop}1', 'Линько Дарья Андреевна', 'linko.daria@example.com', '+79110000031', NOW()), + ('logutov_kirill', '{noop}1', 'Логутов Кирилл Александрович', 'logutov.kirill@example.com', '+79110000032', + NOW()), + ('nekrassov_sergey', '{noop}1', 'Некрасов Сергей Игоревич', 'nekrassov.sergey@example.com', '+79110000033', + NOW()), + ('sinyagin_ilya', '{noop}1', 'Синягин Илья Александрович', 'sinyagin.ilya@example.com', '+79110000034', + NOW()), + ('sopriko_daniil', '{noop}1', 'Соприко Даниил Сергеевич', 'sopriko.daniil@example.com', '+79110000035', + NOW()), + ('turovsky_ivan', '{noop}1', 'Туровский Иван Алексеевич', 'turovsky.ivan@example.com', '+79110000036', NOW()), + ('frantsev_sergey', '{noop}1', 'Францев Сергей Дмитриевич', 'frantsev.sergey@example.com', '+79110000037', + NOW()), + ('chepurnoy_maxim', '{noop}1', 'Чепурной Максим Романович', 'chepurnoy.maxim@example.com', '+79110000038', + NOW()), + ('schemelinin_dmitry', '{noop}1', 'Щемелинин Дмитрий Михайлович', 'schemelinin.dmitry@example.com', + '+79110000039', NOW()), + ('bulatitsky_d_i_1', '{noop}1', 'Булатицкий Д. И.', 'bulatitsky.d.i.1@example.com', '+79110000040', NOW()), + ('kopeliovich_d_i_1', '{noop}1', 'Копелиович Д. И.', 'kopeliovich.d.i.1@example.com', '+79110000041', NOW()), + ('dergachev_k_v', '{noop}1', 'Дергачев К. В.', 'dergachev.k.v@example.com', '+79110000042', NOW()), + ('trubakov_e_o', '{noop}1', 'Трубаков Е. О.', 'trubakov.e.o@example.com', '+79110000043', NOW()), + ('radchenko_a_o', '{noop}1', 'Радченко А. О.', 'radchenko.a.o@example.com', '+79110000044', NOW()), + ('zimin_s_n_1', '{noop}1', 'Зимин С. Н.', 'zimin.s.n.1@example.com', '+79110000045', NOW()), + ('koptenok_e_v', '{noop}1', 'Коптенок Е. В.', 'koptenok.e.v@example.com', '+79110000046', NOW()), + ('mikhaleva_o_a', '{noop}1', 'Михалева О. А.', 'mikhaleva.o.a@example.com', '+79110000047', NOW()), + ('gulakov_k_v', '{noop}1', 'Гулаков К. В.', 'gulakov.k.v@example.com', '+79110000048', NOW()), + ('titarev_d_v', '{noop}1', 'Титарёв Д. В.', 'titarev.d.v@example.com', '+79110000049', NOW()), + ('izrailev_v_ya_1', '{noop}1', 'Израилев В. Я.', 'izrailev.v.ya.1@example.com', '+79110000050', NOW()), + ('podvesovsky_a_g_1', '{noop}1', 'Подвесовский А. Г.', 'podvesovsky.a.g.1@example.com', '+79110000051', NOW()), + ('trubakov_a_o', '{noop}1', 'Трубаков А. О.', 'trubakov.a.o@example.com', '+79110000059', NOW()), + ('lageriev_d_g', '{noop}1', 'Лагерев Д. Г.', 'lageriev.d.g@example.com', '+79110000052', NOW()); diff --git a/server/src/main/resources/db/test-data/user_role.sql b/server/src/main/resources/db/test-data/user_role.sql new file mode 100644 index 0000000..4b00ae0 --- /dev/null +++ b/server/src/main/resources/db/test-data/user_role.sql @@ -0,0 +1,58 @@ +do +$$ + declare + teacher_id bigint := 1; + student_id bigint := 2; + commission_member_id bigint := 3; + administrator_id bigint := 4; + secretary_id bigint := 5; + begin + INSERT INTO user_role (user_id, role_id) + VALUES (1, student_id), + (2, student_id), + (3, student_id), + (4, student_id), + (5, student_id), + (6, student_id), + (7, student_id), + (8, student_id), + (9, student_id), + (10, student_id), + (11, student_id), + (12, student_id), + (13, student_id), + (14, student_id), + (15, student_id), + (16, student_id), + (17, student_id), + (18, student_id), + (19, student_id), + (20, student_id), + (21, student_id), + (22, student_id), + (23, student_id), + (24, student_id), + (25, student_id), + (26, student_id), + (27, student_id), + (28, student_id), + (29, student_id), + (30, student_id), + (31, student_id), + (32, student_id), + (33, student_id), + (34, student_id), + (35, student_id), + (36, student_id), + (37, teacher_id), + (37, administrator_id), + (38, commission_member_id), + (39, teacher_id), + (40, teacher_id), + (41, teacher_id), + (42, teacher_id), + (43, teacher_id), + (44, secretary_id), + (45, secretary_id); + end +$$; \ No newline at end of file diff --git a/server/src/main/resources/logback.xml b/server/src/main/resources/logback.xml new file mode 100644 index 0000000..0c3d24d --- /dev/null +++ b/server/src/main/resources/logback.xml @@ -0,0 +1,22 @@ + + + + %d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n + + + + + logs/app.log + false + + %d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n + + + + + + + + + +