commit a3e8bbfcffeab423e47cc5fbb8ab6ac84794cd52 Author: PhatPhuckDave Date: Mon Apr 28 13:31:00 2025 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..d8bc321 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar diff --git a/README.md b/README.md new file mode 100644 index 0000000..0db4a8d --- /dev/null +++ b/README.md @@ -0,0 +1,59 @@ +Zadatak: Aplikaciju za Auto servise. + +- Tehnologije: Springboot, Thymeleaf, PostgresSQl baza (tocno te tehnologije, bez javascripta) + +U aplikaciji treba moći: + +1. Dodavati/brisati/editirati klijente. + - Osim forme za editiranje podataka klijenta, treba napraviti i prikaz detalja klijenta, koji nije u obliku forme, vec samo tekstualno prikazani podaci (moze kao tablica da bi sve bilo lijepo poravnato) + : + - OIB + - Ime i Prezime + - Adresa (Ulica i broj, poštanski broj , Grad, Država) + (hint: pokušajte to napraviti kao Embedable, ) + https://en.wikibooks.org/wiki/Java_Persistence/Embeddables#Example_of_an_embedded_relationship_annotations + - Lista automobila + - Nakon sto se unese novi klijent ili editira postojeci, treba prikazati stranicu sa detaljima klijenta. + Naslov iznad forme neka bude "Uređivanje klijenta" + + - Napraviti stranicu sa izlistom klijenata + - U listi su prezimena i imena klijenata, abecedno po prezimenu + - klik na ime vodi na stranicu s detaljima klijenta + - pored imena klijenta su buttoni "Uredi" (vodi na formu za editiranje klijenta) i "Obriši" (briše klijenta i sve njegove automobile) + - ispod liste button za dodavanje novog klijenta + pored pojedinog klijenta, buttoni za ) + + +2. Dodavanje automobila + + - Na prikazu detalja klijenta (definirano u tocki 1) treba prikazati i listu automobila koje klijent posjeduje i servisira. Ispod liste (koja ce inicijalno biti prazna) treba biti button "Dodaj automobil", a klik na taj biuton otvara novu stranicu (formu ) za unos podataka automobla. + - Automobil mora imati sljedeće podatke + - Klijent kojem pripada (dropdown lista, inicijalno odabran onaj klijent s cijih detalja je klinuto na "Dodaj automobi", ali moze se promjeniti) + - Tip automobila (tipove automobila ne morate spremati u bazu, dovoljno je imati enum sa listom tipova (dodajte 10-ak komada)) + enum vrijednosti za tip automobila neka budu skraceni nazivi, npr: TOYOTA_AURIS, s time da ima property-e manufacturer i model koji imaju gettere/settere a u ovom slucaju bi vrijednosti bile za manufacturer "Toyota" a za model "Auris" + - Godina proizvodnje + - Registracijska oznaka + - Boja + - Naslov iznad forme neka bude "Uređivanje automobila" + - Kada se doda automobil (submita se forma), neka se vraća na stranicu detalja klijenta za kojeg smo dodali taj automobil. + Tada se na toj stranici, u listi automobila klijenta treba vidjeti unešeni automobil. + - Na toj listi automobila ispisivati proizvođača i model (iz onog enuma za tip automobila), to neka ujedno bude i link na stranicu sa detaljima automobila. Pokraj tog linka dodati dva buttona: "Uredi" i "Obriši". Uredi otvara formu za editiranje podataka automobila, a Briši ga briše. + - RELACIJU AUTOMOBIL-KLIJENT NAPRAVITE BIDIRECTIONAL (DA KLIJENT ENTITY IMA LISTU AUTOMOBILA A AUTOMOBIL IMA REFERENCU NA KLIJENTA KOJEM PRIPADA) + + +3. Dodavanje servisa + - Na stranici detalja automobila (definiranoj u točki 2) uz podatke o automobilu treba dodati i listu napravljenih servisa. Ispod liste (koja je inicijalno prazna) imamo button "Dodaj servis info" + - Klik na taj button otvara formu za dodavanje Servisa koji treba imati sljedeće podatke: + - Datum i vrijeme servisa + - Ime i prezime radnika koji je napravio servis + - Opis radova + - Cijena + - Informacija da li je plaćeno ili ne (checkbox) + - Naslov iznad forme neka bude "Servis za automobil XXXXX , YYYYY". XXXXX neka bude tip automobila (proizvođać i model), a YYYYY ime i prezime klijenta + - Nakon submita forme treba se vratiti na stranicu detalja automobila. + - Dodani servis se treba prikazati na toj stranici u listi servisa. Za svaki servis u listi ispisati Datum i vrijeme kad je napravljen i ime radika koji je obavio servis. Svaki taj item u listi ujedno je i link na stranicu detalja servisa gdje se ispisutu svi podaci o servisu (tablica s tekstom) + - Pokraj linka treba dodati buttone "Uredi" (vodi na edit formu za servis) i "Obriši" (briše servis iz baze) + - RELACIJU SERVIS-AUTOMOBIL NAPRAVITE BIDIRECTIONAL (DA AUTOMOBIL ENTITY IMA LISTU SERVVISA A SERVIS IMA REFERENCU NA AUTOMOBIL ZA KOJI JE NAPRAVLJEN) +4. Napravity Homepage na kojem će se prikazati zadnjih 10 napravljeni servisa (po vremenu, najnoviji na vrhu) + +5. (OPCIONALNO) Na svim stranicama includati na vrhu header sa glavnom navigacijom (potrazite kako se to radi sa thymeleafom, hint --> th:include) diff --git a/mvnw b/mvnw new file mode 100644 index 0000000..8a8fb22 --- /dev/null +++ b/mvnw @@ -0,0 +1,316 @@ +#!/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. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + 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 + else + JAVACMD="`\\unset -f command; \\command -v java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..1d8ab01 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,188 @@ +@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 Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..81d8d4d --- /dev/null +++ b/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.6.2 + + + com.carService + demo + 0.0.1-SNAPSHOT + demo + Demo project for Spring Boot + + 11 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-web + + + + org.postgresql + postgresql + runtime + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/src/main/java/com/carService/demo/DemoApplication.java b/src/main/java/com/carService/demo/DemoApplication.java new file mode 100644 index 0000000..6eeeab8 --- /dev/null +++ b/src/main/java/com/carService/demo/DemoApplication.java @@ -0,0 +1,13 @@ +package com.carService.demo; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class DemoApplication { + + public static void main(String[] args) { + SpringApplication.run(DemoApplication.class, args); + } + +} diff --git a/src/main/java/com/carService/demo/controller/CarController.java b/src/main/java/com/carService/demo/controller/CarController.java new file mode 100644 index 0000000..bc7323f --- /dev/null +++ b/src/main/java/com/carService/demo/controller/CarController.java @@ -0,0 +1,75 @@ +package com.carService.demo.controller; + +import com.carService.demo.domain.Car; +import com.carService.demo.domain.enums.CarManufacturerModel; +import com.carService.demo.manager.CarManager; +import com.carService.demo.manager.CarServiceManager; +import com.carService.demo.manager.UserManager; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.*; + +import java.util.Optional; + +@Controller +@RequestMapping("/car") +@SessionAttributes("car") +@RequiredArgsConstructor +public class CarController { + private final CarManager carManager; + private final UserManager userManager; + private final CarServiceManager carServiceManager; + + @GetMapping("/add") + private String addCar(Model model) { + var users = userManager.getAllUsers(); + + model.addAttribute("car", new Car()); + model.addAttribute("users", users); + model.addAttribute("manufacturers", CarManufacturerModel.values()); + return "car/car-add"; + } + @GetMapping("/edit/{carId}") + private String editCar(Model model, @PathVariable long carId) { + Optional car = carManager.getCarById(carId); + if (car.isPresent()) { + var carObject = car.get(); + var users = userManager.getAllUsers(); + users.remove(carObject.getUser()); + + model.addAttribute("car", carObject); + model.addAttribute("users", users); + model.addAttribute("manufacturers", CarManufacturerModel.values()); + model.addAttribute("editMode", true); + return "car/car-add"; + } + return "redirect:/user/list"; + } + @PostMapping("/add") + private String submitCarForm(@ModelAttribute Car car) { + carManager.createCar(car); + return "redirect:/car/info/" + car.getId(); + } + + @RequestMapping("/delete/{carId}") + private String deleteCar(@PathVariable("carId") Long carId) { + var car = carManager.getCarById(carId).get(); + var user = car.getUser(); + carManager.deleteCarByID(carId); + return "redirect:/user/info/" + user.getId(); + } + + @RequestMapping("/info/{carId}") + private String carInfo(Model model, @PathVariable("carId") Long carId) { + var car = carManager.getCarById(carId); + if (car.isPresent()) { + var carObj = car.get(); + var services = carServiceManager.getServicesByCarId(carObj.getId()); + model.addAttribute("car", carObj); + model.addAttribute("services", services); + return "car/car-info"; + } + return "redirect:/user/list"; + } +} diff --git a/src/main/java/com/carService/demo/controller/CarServiceController.java b/src/main/java/com/carService/demo/controller/CarServiceController.java new file mode 100644 index 0000000..48b97ac --- /dev/null +++ b/src/main/java/com/carService/demo/controller/CarServiceController.java @@ -0,0 +1,68 @@ +package com.carService.demo.controller; + +import com.carService.demo.domain.CarService; +import com.carService.demo.manager.CarManager; +import com.carService.demo.manager.CarServiceManager; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.*; + +import java.util.Optional; + +@Controller +@RequestMapping("/service") +@SessionAttributes("carService") +@RequiredArgsConstructor +public class CarServiceController { + private final CarServiceManager serviceManager; + private final CarManager carManager; + + @GetMapping("/add") + private String addService(Model model) { + var cars = carManager.getAllCars(); + + model.addAttribute("carService", new CarService()); + model.addAttribute("cars", cars); + return "service/service-add"; + } + @GetMapping("/edit/{serviceId}") + private String editService(Model model, @PathVariable long serviceId) { + Optional service = serviceManager.getServiceById(serviceId); + if (service.isPresent()) { + var serviceObject = service.get(); + var cars = carManager.getAllCars(); + cars.remove(serviceObject.getCar()); + + model.addAttribute("carService", serviceObject); + model.addAttribute("cars", cars); + model.addAttribute("editMode", true); + return "service/service-add"; + } + return "redirect:/user/list"; + } + @PostMapping("/add") + private String submitServiceForm(@ModelAttribute CarService service) { + serviceManager.createService(service); + return "redirect:/service/info/" + service.getId(); + } + + @RequestMapping("/delete/{serviceId}") + private String deleteService(@PathVariable("serviceId") Long serviceId) { + var service = serviceManager.getServiceById(serviceId).get(); + var car = service.getCar(); + serviceManager.deleteServiceById(serviceId); + return "redirect:/car/info/" + car.getId(); + } + + @RequestMapping("/info/{serviceId}") + private String serviceInfo(Model model, @PathVariable("serviceId") Long serviceId) { + var service = serviceManager.getServiceById(serviceId); + if (service.isPresent()) { + var serviceObj = service.get(); + model.addAttribute("carService", serviceObj); + return "service/service-info"; + } + return "redirect:/user/list"; + } +} \ No newline at end of file diff --git a/src/main/java/com/carService/demo/controller/IndexController.java b/src/main/java/com/carService/demo/controller/IndexController.java new file mode 100644 index 0000000..a22cba9 --- /dev/null +++ b/src/main/java/com/carService/demo/controller/IndexController.java @@ -0,0 +1,21 @@ +package com.carService.demo.controller; + +import com.carService.demo.manager.CarServiceManager; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping("/") +@RequiredArgsConstructor +public class IndexController { + private final CarServiceManager carServiceManager; + + @RequestMapping("/") + private String getIndex(Model model) { + var services = carServiceManager.getRecentServices(10); + model.addAttribute("services", services); + return "index"; + } +} diff --git a/src/main/java/com/carService/demo/controller/UserController.java b/src/main/java/com/carService/demo/controller/UserController.java new file mode 100644 index 0000000..94d72d1 --- /dev/null +++ b/src/main/java/com/carService/demo/controller/UserController.java @@ -0,0 +1,70 @@ +package com.carService.demo.controller; + +import com.carService.demo.domain.User; +import com.carService.demo.manager.CarManager; +import com.carService.demo.manager.UserManager; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Optional; + +@Controller +@RequestMapping("/user") +@SessionAttributes("user") +@RequiredArgsConstructor +public class UserController { + private final UserManager userManager; + private final CarManager carManager; + + @GetMapping("/edit/{userID}") + private String getEditUserForm(Model model, @PathVariable Long userID) { + Optional user = userManager.getUser(userID); + if (user.isPresent()) { + model.addAttribute("user", user.get()); + model.addAttribute("editMode", true); + return "user/user-add"; + } + return "redirect:/user/list"; + } + + @GetMapping("/add") + private String getRegisterForm(Model model) { + model.addAttribute("user", new User()); + return "user/user-add"; + } + + @PostMapping("/add") + private String registerUser(@ModelAttribute User user) { + userManager.createUser(user); + return "redirect:/user/info/" + user.getId(); + } + + @GetMapping("/list") + private String listUsers(Model model) { + List users = userManager.getAllUsersSortedByLastName(); + model.addAttribute("users", users); + return "user/user-list"; + } + + @GetMapping("/info/{userID}") + private String userInfo(Model model, @PathVariable Long userID) { + var user = userManager.getUser(userID); + if (user.isPresent()) { + User userObject = user.get(); + var cars = carManager.getCarsByUserId(userObject.getId()); + model.addAttribute("user", userObject); + model.addAttribute("cars", cars); + return "user/user-info"; + } + return "redirect:/user/list"; + } + + @GetMapping("/delete/{userID}") + private String userDelete(@PathVariable Long userID) { + userManager.deleteUserByID(userID); + return "redirect:/user/list"; + } +} diff --git a/src/main/java/com/carService/demo/domain/Address.java b/src/main/java/com/carService/demo/domain/Address.java new file mode 100644 index 0000000..52f8652 --- /dev/null +++ b/src/main/java/com/carService/demo/domain/Address.java @@ -0,0 +1,27 @@ +package com.carService.demo.domain; + +import lombok.*; + +import javax.persistence.*; + +@Data +@Embeddable +@NoArgsConstructor +@AllArgsConstructor +public class Address { + @Column(name="country") + private String country; + + @Column(name="city") + private String city; + + @Column(name="postal_number") + private int postalNo; + + @Column(name="street") + private String street; + + @Column(name="street_number") +// For some reason spring is very unhappy with streetNo being a primitive type + private Integer streetNo; +} diff --git a/src/main/java/com/carService/demo/domain/Car.java b/src/main/java/com/carService/demo/domain/Car.java new file mode 100644 index 0000000..55d049d --- /dev/null +++ b/src/main/java/com/carService/demo/domain/Car.java @@ -0,0 +1,47 @@ +package com.carService.demo.domain; + +import com.carService.demo.domain.enums.CarManufacturerModel; +import lombok.*; + +import javax.persistence.*; +import java.util.List; + +@Entity +@Data +@NoArgsConstructor +@AllArgsConstructor +@Table(name="cars") +public class Car { + @Id + @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="car_sequence") + @SequenceGenerator(name="car_sequence", allocationSize=10) + @Setter(AccessLevel.PRIVATE) + private Long id; + + @ManyToOne + @JoinColumn(name="userid") + private User user; + + @Column(name="manufacturerModel") + private CarManufacturerModel manufacturerModel; + + @Column(name="production_year") + private short productionYear; + + @Column(name="registration") + private String registration; + + @Column(name="color") + private String color; + + @OneToMany(mappedBy="car", fetch=FetchType.EAGER) + private List services; + + @Override + public String toString() { + return String.format("%s %s (%d)", + this.manufacturerModel.getManufacturer(), + this.manufacturerModel.getModel(), + this.getId()); + } +} diff --git a/src/main/java/com/carService/demo/domain/CarService.java b/src/main/java/com/carService/demo/domain/CarService.java new file mode 100644 index 0000000..44a6c15 --- /dev/null +++ b/src/main/java/com/carService/demo/domain/CarService.java @@ -0,0 +1,53 @@ +package com.carService.demo.domain; + +import lombok.*; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.persistence.*; +import java.util.Date; + +@Entity +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Setter +@Table(name="services") +public class CarService { + @Id + @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="car_service_sequence") + @SequenceGenerator(name="car_service_sequence", allocationSize=10) + @Setter(AccessLevel.PRIVATE) + private Long id; + + @ManyToOne + @JoinColumn(name="carid") + private Car car; + + @DateTimeFormat(pattern="yyyy-MM-dd'T'HH:mm") + @Column(name="datetime") + private Date datetime; + + @Column(name="service_worker_first_name") + private String serviceWorkerFirstName; + + @Column(name="service_worker_last_name") + private String serviceWorkerLastName; + + @Column(name="description") + private String description; + + @Column(name="price") + private float price; + + @Column(name="payment_successful") + private boolean paymentSuccess; + + public String getServicerName() { + return String.format("%s %s", this.getServiceWorkerFirstName(), this.getServiceWorkerLastName()); + } + + @Override + public String toString() { + return String.format("%s (%s)", this.getDatetime().toString(), this.getServicerName()); + } +} diff --git a/src/main/java/com/carService/demo/domain/User.java b/src/main/java/com/carService/demo/domain/User.java new file mode 100644 index 0000000..9e45a17 --- /dev/null +++ b/src/main/java/com/carService/demo/domain/User.java @@ -0,0 +1,38 @@ +package com.carService.demo.domain; + +import lombok.*; + +import javax.persistence.*; +import java.util.List; + +@Entity +@Table(name="users") +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Setter +public class User { + @Id + @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="user_sequence") + @SequenceGenerator(name="user_sequence", allocationSize=10) + @Setter(AccessLevel.PRIVATE) + private Long id; + + private String oib; + private String firstName; + private String lastName; + + @Embedded + private Address address; + + @OneToMany(mappedBy="user", fetch=FetchType.EAGER) + private List cars; + + @Override + public String toString() { + return String.format("%s %s (%d)", + this.getFirstName(), + this.getLastName(), + this.getId()); + } +} diff --git a/src/main/java/com/carService/demo/domain/enums/CarManufacturerModel.java b/src/main/java/com/carService/demo/domain/enums/CarManufacturerModel.java new file mode 100644 index 0000000..aefbe66 --- /dev/null +++ b/src/main/java/com/carService/demo/domain/enums/CarManufacturerModel.java @@ -0,0 +1,27 @@ +package com.carService.demo.domain.enums; + +import lombok.Getter; + +@Getter +public enum CarManufacturerModel { + AUDI_A6("Audi", "A6"), + BMW_X6("BMW", "X6"), + MERCEDES_MAYBACH("Mercedes", "Maybach"), + SEAT_IBIZA("Seat", "Ibiza"), + OPEL_ASTRA("Opel", "Astra"), + SKODA_OCTAVIA("Škoda", "Octavia"), + RENAULT_MEGANE("Renault", "Megane"), + CITROEN_C3("Citroen", "C3"), + FERRARI_MARANELLO("Ferrari", "Maranello"), + LADA_NIVA("Lada", "Niva"); + + private String manufacturer; + private String model; + CarManufacturerModel(String manufacturer, String model) { + this.manufacturer = manufacturer; + this.model = model; + } + String getDisplayValue() { + return this.manufacturer + " " + this.model; + } +} \ No newline at end of file diff --git a/src/main/java/com/carService/demo/manager/CarManager.java b/src/main/java/com/carService/demo/manager/CarManager.java new file mode 100644 index 0000000..996cd21 --- /dev/null +++ b/src/main/java/com/carService/demo/manager/CarManager.java @@ -0,0 +1,16 @@ +package com.carService.demo.manager; + +import com.carService.demo.domain.Car; +import com.carService.demo.domain.User; + +import java.util.List; +import java.util.Optional; + +public interface CarManager { + Car createCar(Car car); + List getAllCars(); + Optional getCarById(Long carId); + List getCarsByUser(User user); + List getCarsByUserId(Long userID); + void deleteCarByID(Long carId); +} diff --git a/src/main/java/com/carService/demo/manager/CarManagerImpl.java b/src/main/java/com/carService/demo/manager/CarManagerImpl.java new file mode 100644 index 0000000..fe0e835 --- /dev/null +++ b/src/main/java/com/carService/demo/manager/CarManagerImpl.java @@ -0,0 +1,43 @@ +package com.carService.demo.manager; + +import com.carService.demo.domain.Car; +import com.carService.demo.domain.User; +import com.carService.demo.repository.CarRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Optional; + +@Service +@RequiredArgsConstructor +public class CarManagerImpl implements CarManager { + private final CarRepository carRepository; + + @Override + public Car createCar(Car car) { + return this.carRepository.save(car); + } + + @Override + public List getAllCars() { + var cars = this.carRepository.findAll(); + return cars; + } + + @Override + public Optional getCarById(Long carId) { + return this.carRepository.findById(carId); + } + public List getCarsByUser(User user) { + return this.carRepository.findByUser(user); + } + public List getCarsByUserId(Long userId) { + return this.carRepository.findByUserId(userId); + } + + @Override + public void deleteCarByID(Long carId) { + this.carRepository.deleteById(carId); + } +} diff --git a/src/main/java/com/carService/demo/manager/CarServiceManager.java b/src/main/java/com/carService/demo/manager/CarServiceManager.java new file mode 100644 index 0000000..fa5dbfa --- /dev/null +++ b/src/main/java/com/carService/demo/manager/CarServiceManager.java @@ -0,0 +1,17 @@ +package com.carService.demo.manager; + +import com.carService.demo.domain.Car; +import com.carService.demo.domain.CarService; + +import java.util.List; +import java.util.Optional; + +public interface CarServiceManager { + CarService createService(CarService service); + List getAllServices(); + Optional getServiceById(Long serviceId); + List getServicesByCar(Car car); + List getServicesByCarId(Long carId); + List getRecentServices(int limit); + void deleteServiceById(Long serviceId); +} diff --git a/src/main/java/com/carService/demo/manager/CarServiceManagerImpl.java b/src/main/java/com/carService/demo/manager/CarServiceManagerImpl.java new file mode 100644 index 0000000..c292415 --- /dev/null +++ b/src/main/java/com/carService/demo/manager/CarServiceManagerImpl.java @@ -0,0 +1,52 @@ +package com.carService.demo.manager; + +import com.carService.demo.domain.Car; +import com.carService.demo.domain.CarService; +import com.carService.demo.repository.CarServiceRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Optional; + +@RequiredArgsConstructor +@Service +public class CarServiceManagerImpl implements CarServiceManager { + private final CarServiceRepository carServiceRepository; + + @Override + public CarService createService(CarService service) { + return this.carServiceRepository.save(service); + } + + @Override + public List getAllServices() { + return this.carServiceRepository.findAll(); + } + @Override + public Optional getServiceById(Long serviceId) { + return this.carServiceRepository.findById(serviceId); + } + @Override + public List getServicesByCar(Car car) { + return this.carServiceRepository.findByCar(car); + } + @Override + public List getServicesByCarId(Long carId) { + return this.carServiceRepository.findByCarId(carId); + } + @Override + public List getRecentServices(int limit) { + List services = carServiceRepository.findAllByOrderByDatetimeDesc(); + if (services.size() < limit) { + limit = services.size(); + } + List limitedServices = services.subList(0, limit); + return limitedServices; + } + + @Override + public void deleteServiceById(Long serviceId) { + this.carServiceRepository.deleteById(serviceId); + } +} diff --git a/src/main/java/com/carService/demo/manager/UserManager.java b/src/main/java/com/carService/demo/manager/UserManager.java new file mode 100644 index 0000000..b1d5448 --- /dev/null +++ b/src/main/java/com/carService/demo/manager/UserManager.java @@ -0,0 +1,14 @@ +package com.carService.demo.manager; + +import com.carService.demo.domain.User; + +import java.util.List; +import java.util.Optional; + +public interface UserManager { + User createUser(User user); + List getAllUsers(); + List getAllUsersSortedByLastName(); + Optional getUser(Long userID); + void deleteUserByID(Long userID); +} diff --git a/src/main/java/com/carService/demo/manager/UserManagerImpl.java b/src/main/java/com/carService/demo/manager/UserManagerImpl.java new file mode 100644 index 0000000..f72f0e3 --- /dev/null +++ b/src/main/java/com/carService/demo/manager/UserManagerImpl.java @@ -0,0 +1,37 @@ +package com.carService.demo.manager; + +import com.carService.demo.domain.User; +import com.carService.demo.repository.UserRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Optional; + +@Service +@RequiredArgsConstructor +public class UserManagerImpl implements UserManager { + private final UserRepository userRepository; + + public User createUser(User user) { + return userRepository.save(user); + } + + public List getAllUsers() { + return userRepository.findAll(); + } + + public List getAllUsersSortedByLastName() { + var users = userRepository.findAll(); + users.sort((User a, User b) -> a.getLastName().compareTo(b.getLastName())); + return users; + } + + public Optional getUser(Long userID) { + return userRepository.findById(userID); + } + + public void deleteUserByID(Long userID) { + userRepository.deleteById(userID); + } +} diff --git a/src/main/java/com/carService/demo/repository/CarRepository.java b/src/main/java/com/carService/demo/repository/CarRepository.java new file mode 100644 index 0000000..221f676 --- /dev/null +++ b/src/main/java/com/carService/demo/repository/CarRepository.java @@ -0,0 +1,12 @@ +package com.carService.demo.repository; + +import com.carService.demo.domain.Car; +import com.carService.demo.domain.User; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; + +public interface CarRepository extends JpaRepository { + List findByUser(User user); + List findByUserId(Long userId); +} diff --git a/src/main/java/com/carService/demo/repository/CarServiceRepository.java b/src/main/java/com/carService/demo/repository/CarServiceRepository.java new file mode 100644 index 0000000..892f19c --- /dev/null +++ b/src/main/java/com/carService/demo/repository/CarServiceRepository.java @@ -0,0 +1,13 @@ +package com.carService.demo.repository; + +import com.carService.demo.domain.Car; +import com.carService.demo.domain.CarService; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; + +public interface CarServiceRepository extends JpaRepository { + List findByCar(Car car); + List findByCarId(Long carId); + List findAllByOrderByDatetimeDesc(); +} diff --git a/src/main/java/com/carService/demo/repository/UserRepository.java b/src/main/java/com/carService/demo/repository/UserRepository.java new file mode 100644 index 0000000..63e8f39 --- /dev/null +++ b/src/main/java/com/carService/demo/repository/UserRepository.java @@ -0,0 +1,7 @@ +package com.carService.demo.repository; + +import com.carService.demo.domain.User; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface UserRepository extends JpaRepository { +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..e4b0ae8 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,20 @@ +spring.thymeleaf.cache=false + +spring.jackson.serialization.INDENT_OUTPUT=true +#JPA properties +spring.jpa.hibernate.ddl-auto=update + +spring.datasource.url=jdbc:postgresql://127.0.0.1:2345/phatphuckdave +spring.datasource.username=phatphuckdave +spring.datasource.password=phatphuckdave765 +spring.datasource.driver-class-name=org.postgresql.Driver + +spring.jpa.database=POSTGRESQL +spring.jpa.database-platform = org.hibernate.dialect.PostgreSQL92Dialect +spring.jpa.open-in-view=true +spring.jpa.show_sql=false +spring.jpa.generate-ddl=false +spring.jpa.hibernate.use-new-id-generator-mappings=true +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true + +verySecretKey=verySecretKey diff --git a/src/main/resources/templates/car/car-add.html b/src/main/resources/templates/car/car-add.html new file mode 100644 index 0000000..4926ec6 --- /dev/null +++ b/src/main/resources/templates/car/car-add.html @@ -0,0 +1,51 @@ + + + + + Add car + + + + +
+
+

+
+
+
+
+ +
+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/car/car-info.html b/src/main/resources/templates/car/car-info.html new file mode 100644 index 0000000..2f80fbb --- /dev/null +++ b/src/main/resources/templates/car/car-info.html @@ -0,0 +1,108 @@ + + + + + Car info + + + + + +
+
+
+
+
+
+
+ +
+
+

+
+
+ +
+ +
+
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+
+
+ Car services + + + + + + + + + + + + + + + + + + + + + + + + +
IDServicer NameDateDescriptionPricePayment StatusEditDelete
+
+
+
+
+ +
+
+
+
+
+
+
+ + diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html new file mode 100644 index 0000000..d940da4 --- /dev/null +++ b/src/main/resources/templates/index.html @@ -0,0 +1,46 @@ + + + + + Index + + + + +
+
+
+
+
+

Recent services

+
+
+
+ + + + + + + + + + + + + + + + + +
IDInfoCarOwner
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/src/main/resources/templates/navbar.html b/src/main/resources/templates/navbar.html new file mode 100644 index 0000000..ed86f3e --- /dev/null +++ b/src/main/resources/templates/navbar.html @@ -0,0 +1,37 @@ + \ No newline at end of file diff --git a/src/main/resources/templates/service/service-add.html b/src/main/resources/templates/service/service-add.html new file mode 100644 index 0000000..b31e8ef --- /dev/null +++ b/src/main/resources/templates/service/service-add.html @@ -0,0 +1,55 @@ + + + + + Add service + + + + +
+
+

+
+
+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/service/service-info.html b/src/main/resources/templates/service/service-info.html new file mode 100644 index 0000000..74d305e --- /dev/null +++ b/src/main/resources/templates/service/service-info.html @@ -0,0 +1,60 @@ + + + + + Service info + + + + + +
+
+
+
+
+
+
+ +
+
+

+
+ + +
+
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/src/main/resources/templates/user/user-add.html b/src/main/resources/templates/user/user-add.html new file mode 100644 index 0000000..a6269e4 --- /dev/null +++ b/src/main/resources/templates/user/user-add.html @@ -0,0 +1,50 @@ + + + + + Add user + + + + +
+
+

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/user/user-info.html b/src/main/resources/templates/user/user-info.html new file mode 100644 index 0000000..731aa0b --- /dev/null +++ b/src/main/resources/templates/user/user-info.html @@ -0,0 +1,132 @@ + + + + + User info + + + + + +
+
+
+
+
+
+
+ +
+
+

+
+
+ +
+ +
+
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+
+
+ Cars and stuff + + + + + + + + + + + + + + + + + + + + + + + + +
IDManufacturerModelRegistrationProduction YearColorEditDelete
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/src/main/resources/templates/user/user-list.html b/src/main/resources/templates/user/user-list.html new file mode 100644 index 0000000..d14f813 --- /dev/null +++ b/src/main/resources/templates/user/user-list.html @@ -0,0 +1,36 @@ + + + + + User list + + + + +
+
+ + + + + + + + + + + + + +
IDFull Name
+ +
+
+ + + diff --git a/src/test/java/com/carService/demo/DemoApplicationTests.java b/src/test/java/com/carService/demo/DemoApplicationTests.java new file mode 100644 index 0000000..0d3d682 --- /dev/null +++ b/src/test/java/com/carService/demo/DemoApplicationTests.java @@ -0,0 +1,13 @@ +package com.carService.demo; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class DemoApplicationTests { + + @Test + void contextLoads() { + } + +}