Initial commit
This commit is contained in:
33
.gitignore
vendored
Normal file
33
.gitignore
vendored
Normal file
@@ -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/
|
2
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
2
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
@@ -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
|
59
README.md
Normal file
59
README.md
Normal file
@@ -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)
|
316
mvnw
vendored
Normal file
316
mvnw
vendored
Normal file
@@ -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 "$@"
|
188
mvnw.cmd
vendored
Normal file
188
mvnw.cmd
vendored
Normal file
@@ -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%
|
67
pom.xml
Normal file
67
pom.xml
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.6.2</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.carService</groupId>
|
||||||
|
<artifactId>demo</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<name>demo</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
<properties>
|
||||||
|
<java.version>11</java.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.postgresql</groupId>
|
||||||
|
<artifactId>postgresql</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
13
src/main/java/com/carService/demo/DemoApplication.java
Normal file
13
src/main/java/com/carService/demo/DemoApplication.java
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -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> 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";
|
||||||
|
}
|
||||||
|
}
|
@@ -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<CarService> 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";
|
||||||
|
}
|
||||||
|
}
|
@@ -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";
|
||||||
|
}
|
||||||
|
}
|
@@ -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> 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<User> 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";
|
||||||
|
}
|
||||||
|
}
|
27
src/main/java/com/carService/demo/domain/Address.java
Normal file
27
src/main/java/com/carService/demo/domain/Address.java
Normal file
@@ -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;
|
||||||
|
}
|
47
src/main/java/com/carService/demo/domain/Car.java
Normal file
47
src/main/java/com/carService/demo/domain/Car.java
Normal file
@@ -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<CarService> services;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s %s (%d)",
|
||||||
|
this.manufacturerModel.getManufacturer(),
|
||||||
|
this.manufacturerModel.getModel(),
|
||||||
|
this.getId());
|
||||||
|
}
|
||||||
|
}
|
53
src/main/java/com/carService/demo/domain/CarService.java
Normal file
53
src/main/java/com/carService/demo/domain/CarService.java
Normal file
@@ -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());
|
||||||
|
}
|
||||||
|
}
|
38
src/main/java/com/carService/demo/domain/User.java
Normal file
38
src/main/java/com/carService/demo/domain/User.java
Normal file
@@ -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<Car> cars;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s %s (%d)",
|
||||||
|
this.getFirstName(),
|
||||||
|
this.getLastName(),
|
||||||
|
this.getId());
|
||||||
|
}
|
||||||
|
}
|
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
16
src/main/java/com/carService/demo/manager/CarManager.java
Normal file
16
src/main/java/com/carService/demo/manager/CarManager.java
Normal file
@@ -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<Car> getAllCars();
|
||||||
|
Optional<Car> getCarById(Long carId);
|
||||||
|
List<Car> getCarsByUser(User user);
|
||||||
|
List<Car> getCarsByUserId(Long userID);
|
||||||
|
void deleteCarByID(Long carId);
|
||||||
|
}
|
@@ -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<Car> getAllCars() {
|
||||||
|
var cars = this.carRepository.findAll();
|
||||||
|
return cars;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Car> getCarById(Long carId) {
|
||||||
|
return this.carRepository.findById(carId);
|
||||||
|
}
|
||||||
|
public List<Car> getCarsByUser(User user) {
|
||||||
|
return this.carRepository.findByUser(user);
|
||||||
|
}
|
||||||
|
public List<Car> getCarsByUserId(Long userId) {
|
||||||
|
return this.carRepository.findByUserId(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteCarByID(Long carId) {
|
||||||
|
this.carRepository.deleteById(carId);
|
||||||
|
}
|
||||||
|
}
|
@@ -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<CarService> getAllServices();
|
||||||
|
Optional<CarService> getServiceById(Long serviceId);
|
||||||
|
List<CarService> getServicesByCar(Car car);
|
||||||
|
List<CarService> getServicesByCarId(Long carId);
|
||||||
|
List<CarService> getRecentServices(int limit);
|
||||||
|
void deleteServiceById(Long serviceId);
|
||||||
|
}
|
@@ -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<CarService> getAllServices() {
|
||||||
|
return this.carServiceRepository.findAll();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Optional<CarService> getServiceById(Long serviceId) {
|
||||||
|
return this.carServiceRepository.findById(serviceId);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<CarService> getServicesByCar(Car car) {
|
||||||
|
return this.carServiceRepository.findByCar(car);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<CarService> getServicesByCarId(Long carId) {
|
||||||
|
return this.carServiceRepository.findByCarId(carId);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<CarService> getRecentServices(int limit) {
|
||||||
|
List<CarService> services = carServiceRepository.findAllByOrderByDatetimeDesc();
|
||||||
|
if (services.size() < limit) {
|
||||||
|
limit = services.size();
|
||||||
|
}
|
||||||
|
List<CarService> limitedServices = services.subList(0, limit);
|
||||||
|
return limitedServices;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteServiceById(Long serviceId) {
|
||||||
|
this.carServiceRepository.deleteById(serviceId);
|
||||||
|
}
|
||||||
|
}
|
14
src/main/java/com/carService/demo/manager/UserManager.java
Normal file
14
src/main/java/com/carService/demo/manager/UserManager.java
Normal file
@@ -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<User> getAllUsers();
|
||||||
|
List<User> getAllUsersSortedByLastName();
|
||||||
|
Optional<User> getUser(Long userID);
|
||||||
|
void deleteUserByID(Long userID);
|
||||||
|
}
|
@@ -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<User> getAllUsers() {
|
||||||
|
return userRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<User> getAllUsersSortedByLastName() {
|
||||||
|
var users = userRepository.findAll();
|
||||||
|
users.sort((User a, User b) -> a.getLastName().compareTo(b.getLastName()));
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<User> getUser(Long userID) {
|
||||||
|
return userRepository.findById(userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteUserByID(Long userID) {
|
||||||
|
userRepository.deleteById(userID);
|
||||||
|
}
|
||||||
|
}
|
@@ -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<Car, Long> {
|
||||||
|
List<Car> findByUser(User user);
|
||||||
|
List<Car> findByUserId(Long userId);
|
||||||
|
}
|
@@ -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<CarService, Long> {
|
||||||
|
List<CarService> findByCar(Car car);
|
||||||
|
List<CarService> findByCarId(Long carId);
|
||||||
|
List<CarService> findAllByOrderByDatetimeDesc();
|
||||||
|
}
|
@@ -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<User, Long> {
|
||||||
|
}
|
20
src/main/resources/application.properties
Normal file
20
src/main/resources/application.properties
Normal file
@@ -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
|
51
src/main/resources/templates/car/car-add.html
Normal file
51
src/main/resources/templates/car/car-add.html
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Add car</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div th:replace="navbar.html :: navDiv"></div>
|
||||||
|
<div class="container mt-5">
|
||||||
|
<h1 th:text="${editMode} ? 'Uređivanje automobila' : 'Dodavanje automobila'"></h1>
|
||||||
|
<div class="py-3"></div>
|
||||||
|
<form id="registerForm" action="/car/add" method="POST" th:object="${car}">
|
||||||
|
<div class="mb-4">
|
||||||
|
<label for="userSelect">User</label><br>
|
||||||
|
<select id="userSelect" th:field="*{user}">
|
||||||
|
<option selected th:if="${editMode}"
|
||||||
|
th:value="${car.user.id}"
|
||||||
|
th:text="${car.user.firstName + ' ' + car.user.lastName + ' (' + car.user.id + ')'}"></option>
|
||||||
|
<option th:each="user : ${users}"
|
||||||
|
th:value="${user.id}"
|
||||||
|
th:text="${user.firstName + ' ' + user.lastName + ' (' + user.id + ')'}">
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="mb-4">
|
||||||
|
<label for="modelSelect">Model</label><br>
|
||||||
|
<select class="form-select form-select-lg" aria-label=".form-select-lg" id="modelSelect" th:field="*{manufacturerModel}">
|
||||||
|
<option th:each="manufacturerModel : ${manufacturers}"
|
||||||
|
th:value="${manufacturerModel}"
|
||||||
|
th:text="${manufacturerModel.manufacturer + ' ' + manufacturerModel.model}"></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="productionYear">Production Year</label>
|
||||||
|
<input type="text" id="productionYear" name="productionYear" class="form-control form-control-lg" placeholder="Production Year" th:field="*{productionYear}"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="registration">Registration</label>
|
||||||
|
<input type="text" id="registration" name="registration" class="form-control form-control-lg" placeholder="Registration" th:field="*{registration}"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="color">Color</label>
|
||||||
|
<input type="text" id="color" name="color" class="form-control form-control-lg" placeholder="Color" th:field="*{color}"/>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-outline-dark btn-lg px-5" type="submit">Add</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
108
src/main/resources/templates/car/car-info.html
Normal file
108
src/main/resources/templates/car/car-info.html
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Car info</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<style>
|
||||||
|
.userInfo {
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div th:replace="navbar.html :: navDiv"></div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-2"></div>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="row col-12">
|
||||||
|
<div class="row text-center py-5">
|
||||||
|
<div class="col-2">
|
||||||
|
<a th:href="'/user/list/'"><button class="btn btn-outline-dark btn-lg px-3">List</button></a>
|
||||||
|
</div>
|
||||||
|
<div class="col-6">
|
||||||
|
<h2 th:text="${car.toString}"></h2>
|
||||||
|
</div>
|
||||||
|
<div class="col-2">
|
||||||
|
<a th:href="'/car/edit/' + ${car.id}"><button class="btn btn-outline-dark btn-lg px-3">Edit car</button></a>
|
||||||
|
</div>
|
||||||
|
<div class="col-2">
|
||||||
|
<a th:href="'/car/delete/' + ${car.id}"><button class="btn btn-outline-dark btn-lg px-3">Remove car</button></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-2"></div>
|
||||||
|
<div class="col-6 userInfo">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<label for="registration">Registration: </label>
|
||||||
|
</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<span th:text="${car.registration}" id="registration"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<label for="productionYear">Production Year: </label>
|
||||||
|
</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<span th:text="${car.productionYear}" id="productionYear"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<label for="color">Color: </label>
|
||||||
|
</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<span th:text="${car.color}" id="color"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="row py-5">
|
||||||
|
Car services
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">ID</th>
|
||||||
|
<th scope="col">Servicer Name</th>
|
||||||
|
<th scope="col">Date</th>
|
||||||
|
<th scope="col">Description</th>
|
||||||
|
<th scope="col">Price</th>
|
||||||
|
<th scope="col">Payment Status</th>
|
||||||
|
<th scope="col">Edit</th>
|
||||||
|
<th scope="col">Delete</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="service : ${services}">
|
||||||
|
<td><a th:href="'/service/info/' + ${service.id}" th:text="${service.id}"></a></td>
|
||||||
|
<td th:text="${service.getServicerName}"></td>
|
||||||
|
<td th:text="${service.datetime}"></td>
|
||||||
|
<td th:text="${service.description}"></td>
|
||||||
|
<td th:text="${service.price}">
|
||||||
|
<td th:text="${service.paymentSuccess}"></td>
|
||||||
|
<td><a th:href="'/service/edit/' + ${service.id}"><button class="btn btn-outline-dark btn-md px-2">Edit</button></a></td>
|
||||||
|
<td><a th:href="'/service/delete/' + ${service.id}"><button class="btn btn-outline-dark btn-md px-2">Delete</button></a></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4"></div>
|
||||||
|
<div class="col-4">
|
||||||
|
<div class="row">
|
||||||
|
<a th:href="'/service/add'"><button class="btn btn-outline-dark btn-lg px-3">Dodaj servis info</button></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-4"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-2"></div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
46
src/main/resources/templates/index.html
Normal file
46
src/main/resources/templates/index.html
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Index</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div th:replace="navbar.html :: navDiv"></div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-3"></div>
|
||||||
|
<div class="col-6">
|
||||||
|
<div class="row text-center">
|
||||||
|
<h1>Recent services</h1>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="p-5">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">ID</th>
|
||||||
|
<th scope="col">Info</th>
|
||||||
|
<th scope="col">Car</th>
|
||||||
|
<th scope="col">Owner</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="service : ${services}">
|
||||||
|
<td th:text="${service.id}"></td>
|
||||||
|
<td><a th:href="'/service/info/' + ${service.id}" th:text="${service.toString}"></a></td>
|
||||||
|
<td><a th:href="'/car/info/' + ${service.car.id}" th:text="${service.car.toString}"></a></td>
|
||||||
|
<td><a th:href="'/user/info/' + ${service.car.user.id}" th:text="${service.car.user.toString}"></a></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-3"></div>
|
||||||
|
</div>
|
||||||
|
<div class="p-3 footer text-center fixed-bottom">
|
||||||
|
<a th:href="'/service/add/'"><button class="btn btn-outline-dark btn-lg px-5">Add service</button></a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
37
src/main/resources/templates/navbar.html
Normal file
37
src/main/resources/templates/navbar.html
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light px-3" th:fragment="navDiv">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="/">Index</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
|
<!-- <li class="nav-item">-->
|
||||||
|
<!-- <a class="nav-link active" aria-current="page" href="#">Home</a>-->
|
||||||
|
<!-- </li>-->
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<span class="nav-link dropdown-toggle" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
|
User</span>
|
||||||
|
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
|
<li><a class="dropdown-item" th:href="'/user/list'">List</a></li>
|
||||||
|
<li><a class="dropdown-item" th:href="'/user/add'">Add</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<span class="nav-link dropdown-toggle" id="navbarDropdown2" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
|
Car</span>
|
||||||
|
<ul class="dropdown-menu" aria-labelledby="navbarDropdown2">
|
||||||
|
<li><a class="dropdown-item" th:href="'/car/add'">Add</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<span class="nav-link dropdown-toggle" id="navbarDropdown3" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
|
Service</span>
|
||||||
|
<ul class="dropdown-menu" aria-labelledby="navbarDropdown3">
|
||||||
|
<li><a class="dropdown-item" th:href="'/service/add'">Add</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
55
src/main/resources/templates/service/service-add.html
Normal file
55
src/main/resources/templates/service/service-add.html
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Add service</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div th:replace="navbar.html :: navDiv"></div>
|
||||||
|
<div class="container mt-5">
|
||||||
|
<h1 th:text="${editMode} ? 'Uređivanje servisa' : 'Dodavanje servisa'"></h1>
|
||||||
|
<div class="py-3"></div>
|
||||||
|
<form id="registerForm" action="/service/add" method="POST" th:object="${carService}">
|
||||||
|
<div class="mb-4">
|
||||||
|
<label for="carSelect">Car</label><br>
|
||||||
|
<select id="carSelect" th:field="*{car}">
|
||||||
|
<option selected th:if="${editMode}"
|
||||||
|
th:value="${carService.car.id}"
|
||||||
|
th:text="${carService.car.toString}"></option>
|
||||||
|
<option th:each="car : ${cars}"
|
||||||
|
th:value="${car.id}"
|
||||||
|
th:text="${car.toString}">
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="datetime">Datetime</label>
|
||||||
|
<input type="datetime-local" id="datetime" name="datetime" class="form-control form-control-lg" th:field="*{datetime}"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="serviceWorkerFirstName">Worker first name:</label>
|
||||||
|
<input type="text" id="serviceWorkerFirstName" name="serviceWorkerFirstName" class="form-control form-control-lg" placeholder="Worker first name" th:field="*{serviceWorkerFirstName}"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="serviceWorkerLastName">Worker last name:</label>
|
||||||
|
<input type="text" id="serviceWorkerLastName" name="serviceWorkerLastName" class="form-control form-control-lg" placeholder="Worker last name" th:field="*{serviceWorkerLastName}"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="serviceDescription">Description:</label>
|
||||||
|
<textarea id="serviceDescription" name="serviceDescription" class="form-control form-control-lg" placeholder="Description" th:field="*{description}"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="price">Price:</label>
|
||||||
|
<input type="number" step="0.01" id="price" name="price" class="form-control form-control-lg" placeholder="Price" th:field="*{price}"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4 text-left">
|
||||||
|
<label for="paymentSuccess">Payment Success:</label>
|
||||||
|
<input type="checkbox" id="paymentSuccess" name="paymentSuccess" class="form-control form-control-lg" th:field="*{paymentSuccess}"/>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-outline-dark btn-lg px-5" type="submit">Add</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
60
src/main/resources/templates/service/service-info.html
Normal file
60
src/main/resources/templates/service/service-info.html
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Service info</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<style>
|
||||||
|
.userInfo {
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div th:replace="navbar.html :: navDiv"></div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-2"></div>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="row col-12">
|
||||||
|
<div class="row text-center py-5">
|
||||||
|
<div class="col-2">
|
||||||
|
<a th:href="'/user/list/'"><button class="btn btn-outline-dark btn-lg px-3">List</button></a>
|
||||||
|
</div>
|
||||||
|
<div class="col-6">
|
||||||
|
<h2 th:text="${carService.toString}"></h2>
|
||||||
|
</div>
|
||||||
|
<div class="col-2">
|
||||||
|
<a th:href="'/service/edit/' + ${carService.id}"><button class="btn btn-outline-dark btn-lg px-3">Edit service</button></a>
|
||||||
|
</div>
|
||||||
|
<div class="col-2">
|
||||||
|
<a th:href="'/service/delete/' + ${carService.id}"><button class="btn btn-outline-dark btn-lg px-3">Remove service</button></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-2"></div>
|
||||||
|
<div class="col-6 userInfo">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<label for="description">Description: </label>
|
||||||
|
</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<span th:text="${carService.description}" id="description"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<label for="price">Price: </label>
|
||||||
|
</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<span th:text="${carService.price}" id="price"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-2"></div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
50
src/main/resources/templates/user/user-add.html
Normal file
50
src/main/resources/templates/user/user-add.html
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Add user</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div th:replace="navbar.html :: navDiv"></div>
|
||||||
|
<div class="container mt-5">
|
||||||
|
<h1 th:text="${editMode} ? 'Edit user' : 'Add user'"></h1>
|
||||||
|
<form id="registerForm" action="/user/add" method="POST" th:object="${user}">
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="oib">OIB</label>
|
||||||
|
<input type="text" id="oib" name="oib" class="form-control form-control-lg" placeholder="OIB" th:field="*{oib}"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="firstName">First Name</label>
|
||||||
|
<input type="text" id="firstName" name="firstName" class="form-control form-control-lg" placeholder="First Name" th:field="*{firstName}"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="lastName">Last Name</label>
|
||||||
|
<input type="text" id="lastName" name="lastName" class="form-control form-control-lg" placeholder="Last Name" th:field="*{lastName}"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="country">Country</label>
|
||||||
|
<input type="text" id="country" name="country" class="form-control form-control-lg" placeholder="Country" th:field="*{address.country}"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="City">City</label>
|
||||||
|
<input type="text" id="City" name="City" class="form-control form-control-lg" placeholder="City" th:field="*{address.city}"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="postalNo">Postal Number</label>
|
||||||
|
<input type="text" id="postalNo" name="postalNo" class="form-control form-control-lg" placeholder="Postal Number" th:field="*{address.postalNo}"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="street">Street</label>
|
||||||
|
<input type="text" id="street" name="street" class="form-control form-control-lg" placeholder="Street" th:field="*{address.street}"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline form-white mb-4">
|
||||||
|
<label for="streetNo">Street Number</label>
|
||||||
|
<input type="text" id="streetNo" name="streetNo" class="form-control form-control-lg" placeholder="Street Number" th:field="*{address.streetNo}"/>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-outline-dark btn-lg px-5" type="submit">Register</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
132
src/main/resources/templates/user/user-info.html
Normal file
132
src/main/resources/templates/user/user-info.html
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>User info</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<style>
|
||||||
|
.userInfo {
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div th:replace="navbar.html :: navDiv"></div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-2"></div>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="row col-12">
|
||||||
|
<div class="row text-center py-5">
|
||||||
|
<div class="col-2">
|
||||||
|
<a th:href="'/user/list/'"><button class="btn btn-outline-dark btn-lg px-3">List</button></a>
|
||||||
|
</div>
|
||||||
|
<div class="col-6">
|
||||||
|
<h2 th:text="${user.toString}"></h2>
|
||||||
|
</div>
|
||||||
|
<div class="col-2">
|
||||||
|
<a th:href="'/user/edit/' + ${user.id}"><button class="btn btn-outline-dark btn-lg px-3">Edit user</button></a>
|
||||||
|
</div>
|
||||||
|
<div class="col-2">
|
||||||
|
<a th:href="'/user/delete/' + ${user.id}"><button class="btn btn-outline-dark btn-lg px-3">Remove user</button></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-2"></div>
|
||||||
|
<div class="col-6 userInfo">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<label for="oib">OIB: </label>
|
||||||
|
</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<span th:text="${user.oib}" id="oib"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<label for="country">Country: </label>
|
||||||
|
</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<span th:text="${user.address.country}" id="country"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<label for="city">City: </label>
|
||||||
|
</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<span th:text="${user.address.city}" id="city"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<label for="postalNo">Postal Number: </label>
|
||||||
|
</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<span th:text="${user.address.postalNo}" id="postalNo"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<label for="street">Street: </label>
|
||||||
|
</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<span th:text="${user.address.street}" id="street"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<label for="streetNo">Street Number: </label>
|
||||||
|
</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<span th:text="${user.address.streetNo}" id="streetNo"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="row py-5">
|
||||||
|
Cars and stuff
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">ID</th>
|
||||||
|
<th scope="col">Manufacturer</th>
|
||||||
|
<th scope="col">Model</th>
|
||||||
|
<th scope="col">Registration</th>
|
||||||
|
<th scope="col">Production Year</th>
|
||||||
|
<th scope="col">Color</th>
|
||||||
|
<th scope="col">Edit</th>
|
||||||
|
<th scope="col">Delete</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="car : ${cars}">
|
||||||
|
<td><a th:href="'/car/info/' + ${car.id}" th:text="${car.id}"></a></td>
|
||||||
|
<td th:text="${car.manufacturerModel.manufacturer}"></td>
|
||||||
|
<td th:text="${car.manufacturerModel.model}"></td>
|
||||||
|
<td th:text="${car.registration}"></td>
|
||||||
|
<td th:text="${car.productionYear}">
|
||||||
|
<td th:text="${car.color}"></td>
|
||||||
|
<td><a th:href="'/car/edit/' + ${car.id}"><button class="btn btn-outline-dark btn-md px-2">Edit</button></a></td>
|
||||||
|
<td><a th:href="'/car/delete/' + ${car.id}"><button class="btn btn-outline-dark btn-md px-2">Delete</button></a></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4"></div>
|
||||||
|
<div class="col-4">
|
||||||
|
<div class="row">
|
||||||
|
<a th:href="'/car/add'"><button class="btn btn-outline-dark btn-lg px-3">Dodaj automobil</button></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-4"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-2"></div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
36
src/main/resources/templates/user/user-list.html
Normal file
36
src/main/resources/templates/user/user-list.html
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>User list</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div th:replace="navbar.html :: navDiv"></div>
|
||||||
|
<div class="p-5">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">ID</th>
|
||||||
|
<th scope="col">Full Name</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="user : ${users}">
|
||||||
|
<td th:text="${user.id}"></td>
|
||||||
|
<td>
|
||||||
|
<a th:href="'/user/info/' + ${user.id}"
|
||||||
|
th:text="${user.firstName} + ' ' + ${user.lastName}"></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="p-3 footer text-center fixed-bottom">
|
||||||
|
<a th:href="'/user/add/'">
|
||||||
|
<button class="btn btn-outline-dark btn-lg px-5">Add user</button>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
13
src/test/java/com/carService/demo/DemoApplicationTests.java
Normal file
13
src/test/java/com/carService/demo/DemoApplicationTests.java
Normal file
@@ -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() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user