Compare commits
2 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
58399fa227 | 1 year ago |
|
|
72d3df69e6 | 1 year ago |
@ -0,0 +1,25 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
.nb-gradle/
|
||||
|
||||
@ -0,0 +1,225 @@
|
||||
#!/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
|
||||
#
|
||||
# http://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.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 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 /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 Migwn, 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)`"
|
||||
# TODO classpath?
|
||||
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="`which 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
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
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
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||
@ -0,0 +1,143 @@
|
||||
@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 http://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 Maven2 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 key stroke 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 enable echoing my 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 "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\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
|
||||
|
||||
%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 "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\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%
|
||||
|
||||
exit /B %ERROR_CODE%
|
||||
@ -0,0 +1,161 @@
|
||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>crm</groupId>
|
||||
<artifactId>crm</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>crm</name>
|
||||
<description>Final project</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.10.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</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-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf.extras</groupId>
|
||||
<artifactId>thymeleaf-extras-java8time</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf.extras</groupId>
|
||||
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.jpenren</groupId>
|
||||
<artifactId>thymeleaf-spring-data-dialect</artifactId>
|
||||
<version>2.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</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>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-actuator-docs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/net.sourceforge.nekohtml/nekohtml -->
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.nekohtml</groupId>
|
||||
<artifactId>nekohtml</artifactId>
|
||||
<version>1.9.21</version><!--$NO-MVN-MAN-VER$-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>5.5.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox</artifactId>
|
||||
<version>2.0.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.59</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.opencsv</groupId>
|
||||
<artifactId>opencsv</artifactId>
|
||||
<version>4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>3.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>3.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.supercsv</groupId>
|
||||
<artifactId>super-csv</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,73 @@
|
||||
package crm.controller;
|
||||
|
||||
import crm.entity.Customer;
|
||||
import crm.service.CustomerService;
|
||||
import crm.utils.WriteCsvToResponse;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class CSVController {
|
||||
|
||||
private CustomerService customerService;
|
||||
|
||||
public CSVController(CustomerService customerService) {
|
||||
this.customerService = customerService;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/customers", produces = "text/csv")
|
||||
public void findCustomers(HttpServletResponse httpServletResponse) throws IOException {
|
||||
List<Customer> customers = (List<Customer>) customerService.listAllCustomers();
|
||||
WriteCsvToResponse.writeCustomers(httpServletResponse.getWriter(), customers);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/customers/{id}", produces = "text/csv")
|
||||
public void findCustomer(@PathVariable Long id, HttpServletResponse httpServletResponse) throws IOException {
|
||||
Customer customer = customerService.showCustomer(id);
|
||||
WriteCsvToResponse.writeCustomer(httpServletResponse.getWriter(), customer);
|
||||
}
|
||||
|
||||
// @GetMapping("/show-import")
|
||||
// public String showImportCsvSite() {
|
||||
// return "csv/import";
|
||||
// }
|
||||
|
||||
/*@GetMapping("/import")
|
||||
public String processRequestImportCsv(Model model) {
|
||||
File document = ReadDataUtils.ReadFile("Select CSV file", null, "Only CSV Files", "csv");
|
||||
// System.out.println(document.getName());
|
||||
|
||||
CSVReader reader;
|
||||
List<String[]> data = new ArrayList<>();
|
||||
try {
|
||||
reader = new CSVReader(new FileReader(document));
|
||||
String[] line;
|
||||
while ((line = reader.readNext()) != null) {
|
||||
// System.out.println(line[1] + "\t" + line[2]);
|
||||
data.add(line);
|
||||
// if(line[1].equals("QUICK SUB")){
|
||||
// System.out.println(line[0] + "\t" + line[1] + "\t" + line[2]);
|
||||
// }
|
||||
}
|
||||
model.addAttribute("data", data);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
*//*System.out.println(data.get(0)[1] + "\t" + data.get(0)[2]);
|
||||
System.out.println(data.get(1)[1] + "\t" + data.get(1)[2]);*//*
|
||||
|
||||
return "csv/show";
|
||||
}*/
|
||||
|
||||
// @GetMapping("/show")
|
||||
// public String showPageWithCsvImported(@ModelAttribute List<String[]> data) {
|
||||
// data.
|
||||
// return "csv/show";
|
||||
// }
|
||||
|
||||
}
|
||||
@ -0,0 +1,504 @@
|
||||
package crm.controller;
|
||||
|
||||
import crm.entity.Contract;
|
||||
import crm.entity.Customer;
|
||||
import crm.entity.User;
|
||||
import crm.service.ContractService;
|
||||
import crm.service.CustomerService;
|
||||
import crm.service.UserService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/contract")
|
||||
public class ContractController {
|
||||
|
||||
private ContractService contractService;
|
||||
|
||||
private CustomerService customerService;
|
||||
|
||||
private UserService userService;
|
||||
|
||||
public ContractController(ContractService contractService, CustomerService customerService, UserService userService) {
|
||||
this.contractService = contractService;
|
||||
this.customerService = customerService;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/list
|
||||
* <p>
|
||||
* Shows all contracts
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/list
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public String showAllContracts(Model model) {
|
||||
model.addAttribute("contracts", contractService.listAllContracts());
|
||||
return "contract/list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/add
|
||||
* <p>
|
||||
* Shows add contract form
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/add
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public String showFormAddContract(Model model) {
|
||||
Iterable<Customer> customers = customerService.findAllByEnabledTrue();
|
||||
Iterable<User> users = userService.listAllUsers();
|
||||
model.addAttribute("contract", new Contract());
|
||||
model.addAttribute("customers", customers);
|
||||
model.addAttribute("users", users);
|
||||
return "contract/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/add
|
||||
* <p>
|
||||
* Processes add contract request
|
||||
*
|
||||
* @param contract variable type Contract
|
||||
* @param bindingResult variable type BindingResult
|
||||
* @return contract/success
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public String processRequestAddContract(@Valid Contract contract, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return "redirect:/contract/add";
|
||||
} else {
|
||||
contractService.saveContract(contract);
|
||||
return "contract/success";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/edit/{id}
|
||||
* <p>
|
||||
* Shows edit contract form
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @param id variable type long contract id
|
||||
* @return contract/edit
|
||||
*/
|
||||
@GetMapping("/edit/{id}")
|
||||
public String showFormEditContract(Model model, @PathVariable Long id) {
|
||||
model.addAttribute("contract", contractService.showContract(id));
|
||||
return "contract/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/edit/{id}
|
||||
* <p>
|
||||
* Processes edit contract request
|
||||
*
|
||||
* @param id variable type long contract id
|
||||
* @param contract variable type Contract
|
||||
* @param bindingResult variable type BindingResult
|
||||
* @return redirect:/contract/list
|
||||
*/
|
||||
@PostMapping("/edit/{id}")
|
||||
public String processRequestEditContract(@PathVariable Long id, @Valid Contract contract,
|
||||
BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return "redirect:/contract/edit/" + id;
|
||||
} else {
|
||||
contractService.saveContract(contract);
|
||||
return "redirect:/contract/list";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/name-search
|
||||
* <p>
|
||||
* Shows form to search contract by name
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/name-search
|
||||
*/
|
||||
@GetMapping("/name-search")
|
||||
public String showNameSearchForm(Model model) {
|
||||
model.addAttribute("contract", new Contract());
|
||||
return "contract/name-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/name-search
|
||||
* <p>
|
||||
* Processes request searching by name
|
||||
*
|
||||
* @param contract variable type Contract
|
||||
* @param model model to add attributes to
|
||||
* @return contract/show
|
||||
*/
|
||||
@PostMapping("/name-search")
|
||||
public String processRequestNameSearch(@ModelAttribute Contract contract, Model model) {
|
||||
model.addAttribute("contract", contractService.findByName(contract.getName()));
|
||||
return "contract/show-one";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/value-le-search
|
||||
* <p>
|
||||
* Shows form to search contract by value less equal than
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/value-le-search
|
||||
*/
|
||||
@GetMapping("/value-le-search")
|
||||
public String showValueLeesThanEqualSearchForm(Model model) {
|
||||
model.addAttribute("contract", new Contract());
|
||||
return "contract/value-le-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/value-le-search
|
||||
* <p>
|
||||
* Processes request searching by value less equal than
|
||||
*
|
||||
* @param contract variable type Contract
|
||||
* @param model model to add attributes to
|
||||
* @return contract/show-list
|
||||
*/
|
||||
@PostMapping("/value-le-search")
|
||||
public String processRequestValueLessThanEqualSearch(@ModelAttribute Contract contract, Model model) {
|
||||
model.addAttribute("contracts", contractService.findAllByValueLessThanEqual(contract.getValue()));
|
||||
return "contract/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/value-ge-search
|
||||
* <p>
|
||||
* Shows form to search contract by value greater equal than
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/value-ge-search
|
||||
*/
|
||||
@GetMapping("/value-ge-search")
|
||||
public String showValueGreaterThanEqualSearchForm(Model model) {
|
||||
model.addAttribute("contract", new Contract());
|
||||
return "contract/value-ge-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/value-ge-search
|
||||
* <p>
|
||||
* Processes request searching by value greater equal than
|
||||
*
|
||||
* @param contract variable type Contract
|
||||
* @param model model to add attributes to
|
||||
* @return contract/show-list
|
||||
*/
|
||||
@PostMapping("/value-ge-search")
|
||||
public String processRequestValueGreaterThanEqualSearch(@ModelAttribute Contract contract, Model model) {
|
||||
model.addAttribute("contracts", contractService.findAllByValueGreaterThanEqual(contract.getValue()));
|
||||
return "contract/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/begin-date-search
|
||||
* <p>
|
||||
* Shows form to search contract by begin date
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/begin-date-search
|
||||
*/
|
||||
@GetMapping("/begin-date-search")
|
||||
public String showBeginDateSearchForm(Model model) {
|
||||
model.addAttribute("contract", new Contract());
|
||||
return "contract/begin-date-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/begin-date-search
|
||||
* <p>
|
||||
* Processes request searching by begin date
|
||||
*
|
||||
* @param contract variable type Contract
|
||||
* @param model model to add attributes to
|
||||
* @return contract/show-list
|
||||
*/
|
||||
@PostMapping("/begin-date-search")
|
||||
public String processRequestBeginDateSearch(@ModelAttribute Contract contract, Model model) {
|
||||
model.addAttribute("contracts", contractService.findAllByBeginDate(contract.getBeginDate()));
|
||||
return "contract/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/begin-date-before-search
|
||||
* <p>
|
||||
* Shows form to search contract by begin date before
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/begin-date-before-search
|
||||
*/
|
||||
@GetMapping("/begin-date-before-search")
|
||||
public String showBeginDateBeforeSearchForm(Model model) {
|
||||
model.addAttribute("contract", new Contract());
|
||||
return "contract/begin-date-before-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/begin-date-before-search
|
||||
* <p>
|
||||
* Processes request searching by begin date before
|
||||
*
|
||||
* @param contract variable type Contract
|
||||
* @param model model to add attributes to
|
||||
* @return contract/show-list
|
||||
*/
|
||||
@PostMapping("/begin-date-before-search")
|
||||
public String processRequestBeginDateBeforeSearch(@ModelAttribute Contract contract, Model model) {
|
||||
model.addAttribute("contracts", contractService.findAllByBeginDateBefore(contract.getBeginDate()));
|
||||
return "contract/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/begin-date-after-search
|
||||
* <p>
|
||||
* Shows form to search contract by begin date after
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/begin-date-after-search
|
||||
*/
|
||||
@GetMapping("/begin-date-after-search")
|
||||
public String showBeginDateAfterSearchForm(Model model) {
|
||||
model.addAttribute("contract", new Contract());
|
||||
return "contract/begin-date-after-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/begin-date-after-search
|
||||
* <p>
|
||||
* Processes request searching by begin date after
|
||||
*
|
||||
* @param contract variable type Contract
|
||||
* @param model model to add attributes to
|
||||
* @return contract/show-list
|
||||
*/
|
||||
@PostMapping("/begin-date-after-search")
|
||||
public String processRequestBeginDateAfterSearch(@ModelAttribute Contract contract, Model model) {
|
||||
model.addAttribute("contracts", contractService.findAllByBeginDateAfter(contract.getBeginDate()));
|
||||
return "contract/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/end-date-search
|
||||
* <p>
|
||||
* Shows form to search contract by end date
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/end-date-search
|
||||
*/
|
||||
@GetMapping("/end-date-search")
|
||||
public String showEndDateSearchForm(Model model) {
|
||||
model.addAttribute("contract", new Contract());
|
||||
return "contract/end-date-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/end-date-search
|
||||
* <p>
|
||||
* Processes request searching by end date
|
||||
*
|
||||
* @param contract variable type Contract
|
||||
* @param model model to add attributes to
|
||||
* @return contract/show-list
|
||||
*/
|
||||
@PostMapping("/end-date-search")
|
||||
public String processRequestEndDateSearch(@ModelAttribute Contract contract, Model model) {
|
||||
model.addAttribute("contracts", contractService.findAllByEndDate(contract.getEndDate()));
|
||||
return "contract/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/end-date-before-search
|
||||
* <p>
|
||||
* Shows form to search contract by end date before
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/end-date-before-search
|
||||
*/
|
||||
@GetMapping("/end-date-before-search")
|
||||
public String showEndDateBeforeSearchForm(Model model) {
|
||||
model.addAttribute("contract", new Contract());
|
||||
return "contract/end-date-before-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/end-date-before-search
|
||||
* <p>
|
||||
* Processes request searching by end date before
|
||||
*
|
||||
* @param contract variable type Contract
|
||||
* @param model model to add attributes to
|
||||
* @return contract/show-list
|
||||
*/
|
||||
@PostMapping("/end-date-before-search")
|
||||
public String processRequestEndDateBeforeSearch(@ModelAttribute Contract contract, Model model) {
|
||||
model.addAttribute("contracts", contractService.findAllByEndDateBefore(contract.getEndDate()));
|
||||
return "contract/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/end-date-after-search
|
||||
* <p>
|
||||
* Shows form to search contract by end date after
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/end-date-after-search
|
||||
*/
|
||||
@GetMapping("/end-date-after-search")
|
||||
public String showEndDateAfterSearchForm(Model model) {
|
||||
model.addAttribute("contract", new Contract());
|
||||
return "contract/end-date-after-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/end-date-after-search
|
||||
* <p>
|
||||
* Processes request searching by end date after
|
||||
*
|
||||
* @param contract variable type Contract
|
||||
* @param model model to add attributes to
|
||||
* @return contract/show-list
|
||||
*/
|
||||
@PostMapping("/end-date-after-search")
|
||||
public String processRequestEndDateAfterSearch(@ModelAttribute Contract contract, Model model) {
|
||||
model.addAttribute("contracts", contractService.findAllByEndDateAfter(contract.getEndDate()));
|
||||
return "contract/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/status-search
|
||||
* <p>
|
||||
* Shows form to search contract by status
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/status-search
|
||||
*/
|
||||
@GetMapping("/status-search")
|
||||
public String showStatusSearchForm(Model model) {
|
||||
model.addAttribute("contract", new Contract());
|
||||
return "contract/status-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/status-search
|
||||
* <p>
|
||||
* Processes request searching by status
|
||||
*
|
||||
* @param contract variable type Contract
|
||||
* @param model model to add attributes to
|
||||
* @return contract/show-list
|
||||
*/
|
||||
@PostMapping("/status-search")
|
||||
public String processRequestStatusSearch(@ModelAttribute Contract contract, Model model) {
|
||||
model.addAttribute("contracts", contractService.findAllByStatus(contract.getStatus()));
|
||||
return "contract/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/customer-search
|
||||
* <p>
|
||||
* Shows form to search contract by customer
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/customer-search
|
||||
*/
|
||||
@GetMapping("/customer-search")
|
||||
public String showCustomerSearchForm(Model model) {
|
||||
Iterable<Customer> customers = customerService.findAllByEnabledTrue();
|
||||
model.addAttribute("contract", new Contract());
|
||||
model.addAttribute("customers", customers);
|
||||
return "contract/customer-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/customer-search
|
||||
* <p>
|
||||
* Processes request searching by customer
|
||||
*
|
||||
* @param contract variable type Contract
|
||||
* @param model model to add attributes to
|
||||
* @return contract/show-list
|
||||
*/
|
||||
@PostMapping("/customer-search")
|
||||
public String processRequestCustomerSearch(@ModelAttribute Contract contract, Model model) {
|
||||
model.addAttribute("contracts", contractService.findAllByCustomer(contract.getCustomer()));
|
||||
return "contract/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/customer-user-search
|
||||
* <p>
|
||||
* Shows form to search contract by customer and user
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/customer-user-search
|
||||
*/
|
||||
@GetMapping("/customer-user-search")
|
||||
public String showCustomerUserSearchForm(Model model) {
|
||||
Iterable<Customer> customers = customerService.findAllByEnabledTrue();
|
||||
Iterable<User> users = userService.listAllUsers();
|
||||
model.addAttribute("contract", new Contract());
|
||||
model.addAttribute("customers", customers);
|
||||
model.addAttribute("users", users);
|
||||
return "contract/customer-user-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/customer-user-search
|
||||
* <p>
|
||||
* Processes request searching by customer and user
|
||||
*
|
||||
* @param contract variable type Contract
|
||||
* @param model model to add attributes to
|
||||
* @return contract/show-list
|
||||
*/
|
||||
@PostMapping("/customer-user-search")
|
||||
public String processRequestCustomerUserSearch(@ModelAttribute Contract contract, Model model) {
|
||||
model.addAttribute("contracts", contractService.findAllByCustomerAndUser(contract.getCustomer(), contract.getUser()));
|
||||
return "contract/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/user-search
|
||||
* <p>
|
||||
* Shows form to search contract by user
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return contract/user-search
|
||||
*/
|
||||
@GetMapping("/user-search")
|
||||
public String showUserSearchForm(Model model) {
|
||||
Iterable<User> users = userService.listAllUsers();
|
||||
model.addAttribute("contract", new Contract());
|
||||
model.addAttribute("users", users);
|
||||
return "contract/user-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /contract/user-search
|
||||
* <p>
|
||||
* Processes request searching by user
|
||||
*
|
||||
* @param contract variable type Contract
|
||||
* @param model model to add attributes to
|
||||
* @return contract/show-list
|
||||
*/
|
||||
@PostMapping("/user-search")
|
||||
public String processRequestUserSearch(@ModelAttribute Contract contract, Model model) {
|
||||
model.addAttribute("contracts", contractService.findAllByUser(contract.getUser()));
|
||||
return "contract/show-list";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,386 @@
|
||||
package crm.controller;
|
||||
|
||||
import crm.entity.Customer;
|
||||
import crm.service.CustomerService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/customer")
|
||||
public class CustomerController {
|
||||
|
||||
private CustomerService customerService;
|
||||
|
||||
public CustomerController(CustomerService customerService) {
|
||||
this.customerService = customerService;
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/list
|
||||
* <p>
|
||||
* Shows all customers
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return customer/list
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public String showAllCustomers(Model model) {
|
||||
model.addAttribute("customers", customerService.listAllCustomers());
|
||||
return "customer/list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/add
|
||||
* <p>
|
||||
* Shows add customer form
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return customer/add
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public String showFormAddCustomer(Model model) {
|
||||
model.addAttribute("customer", new Customer());
|
||||
return "customer/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/add
|
||||
* <p>
|
||||
* Processes add customer request
|
||||
*
|
||||
* @param customer variable type Customer
|
||||
* @param bindingResult variable type BindingResult
|
||||
* @return customer/success
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public String processRequestAddCustomer(@Valid Customer customer, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return "redirect:/customer/add";
|
||||
} else {
|
||||
customerService.saveCustomer(customer);
|
||||
return "customer/success";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/edit/{id}
|
||||
* <p>
|
||||
* Shows edit customer form
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @param id variable type long customer id
|
||||
* @return customer/edit
|
||||
*/
|
||||
@GetMapping("/edit/{id}")
|
||||
public String showFormEditCustomer(Model model, @PathVariable Long id) {
|
||||
model.addAttribute("customer", customerService.showCustomer(id));
|
||||
return "customer/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/edit/{id}
|
||||
* <p>
|
||||
* Processes edit customer request
|
||||
*
|
||||
* @param id variable type long customer id
|
||||
* @param customer variable type Customer
|
||||
* @param bindingResult variable type BindingResult
|
||||
* @return redirect:/customer/list
|
||||
*/
|
||||
@PostMapping("/edit/{id}")
|
||||
public String processRequestEditCustomer(@PathVariable Long id, @Valid Customer customer,
|
||||
BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return "redirect:/customer/edit/" + id;
|
||||
} else {
|
||||
customerService.saveCustomer(customer);
|
||||
return "redirect:/customer/list";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/addCustomerBasedOnAnotherOne/{id}
|
||||
* <p>
|
||||
* Shows create-customer-based-on-another-one form
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @param id variable type long reference customer id
|
||||
* @return customer/add-customer-based-on-another-one
|
||||
*/
|
||||
@GetMapping("/addCustomerBasedOnAnotherOne/{id}")
|
||||
public String showFormCreateCustomerBasedOnAnotherOne(Model model, @PathVariable Long id) {
|
||||
model.addAttribute("customer", customerService.showCustomer(id));
|
||||
return "customer/add-customer-based-on-another-one";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/addCustomerBasedOnAnotherOne/{id}
|
||||
* <p>
|
||||
* Creates customer based on another one
|
||||
*
|
||||
* @param id variable type long reference customer id
|
||||
* @param customer variable type Customer
|
||||
* @param bindingResult variable type BindingResult
|
||||
* @return redirect:/customer/list
|
||||
*/
|
||||
@PostMapping("/addCustomerBasedOnAnotherOne/{id}")
|
||||
public String createCustomerBasedOnAnotherOne(@PathVariable Long id, @Valid Customer customer,
|
||||
BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return "redirect:/customer/addCustomerBasedOnAnotherOne/" + id;
|
||||
} else {
|
||||
Customer newCustomer = new Customer(
|
||||
customerService.getMaxId() + 1L,
|
||||
customer.getName(),
|
||||
customer.getEmail(),
|
||||
customer.getPhone(),
|
||||
customer.getCategories(),
|
||||
customer.getFirstName(),
|
||||
customer.getLastName(),
|
||||
customer.getCity(),
|
||||
customer.getAddress(),
|
||||
customer.getEnabled());
|
||||
customerService.saveCustomer(newCustomer);
|
||||
return "redirect:/customer/list";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/name-search
|
||||
* <p>
|
||||
* Shows form to search customer by name
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return customer/name-search
|
||||
*/
|
||||
@GetMapping("/name-search")
|
||||
public String showNameSearchForm(Model model) {
|
||||
model.addAttribute("customer", new Customer());
|
||||
return "customer/name-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/name-search
|
||||
* <p>
|
||||
* Processes request searching by name
|
||||
*
|
||||
* @param customer variable type Customer
|
||||
* @param model model to add attributes to
|
||||
* @return customer/show-one
|
||||
*/
|
||||
@PostMapping("/name-search")
|
||||
public String processRequestNameSearch(@ModelAttribute Customer customer, Model model) {
|
||||
model.addAttribute("customer", customerService.findOneByEnabledTrueAndName(customer.getName()));
|
||||
return "customer/show-one";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/email-search
|
||||
* <p>
|
||||
* Shows form to search customer by email
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return customer/email-search
|
||||
*/
|
||||
@GetMapping("/email-search")
|
||||
public String showEmailSearchForm(Model model) {
|
||||
model.addAttribute("customer", new Customer());
|
||||
return "customer/email-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/email-search
|
||||
* <p>
|
||||
* Processes request searching by city
|
||||
*
|
||||
* @param customer variable type Customer
|
||||
* @param model model to add attributes to
|
||||
* @return customer/show-list
|
||||
*/
|
||||
@PostMapping("/email-search")
|
||||
public String processRequestEmailSearch(@ModelAttribute Customer customer, Model model) {
|
||||
model.addAttribute("customers", customerService.findByEnabledTrueAndEmail(customer.getEmail()));
|
||||
return "customer/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/phone-search
|
||||
* <p>
|
||||
* Shows form to search customer by phone
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return customer/phone-search
|
||||
*/
|
||||
@GetMapping("/phone-search")
|
||||
public String showPhoneSearchForm(Model model) {
|
||||
model.addAttribute("customer", new Customer());
|
||||
return "customer/phone-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/phone-search
|
||||
* <p>
|
||||
* Processes request searching by phone
|
||||
*
|
||||
* @param customer variable type Customer
|
||||
* @param model model to add attributes to
|
||||
* @return customer/show-list
|
||||
*/
|
||||
@PostMapping("/phone-search")
|
||||
public String processRequestPhoneSearch(@ModelAttribute Customer customer, Model model) {
|
||||
model.addAttribute("customers", customerService.findByEnabledTrueAndPhone(customer.getPhone()));
|
||||
return "customer/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/first-name-search
|
||||
* <p>
|
||||
* Shows form to search customer by first name
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return customer/first-name-search
|
||||
*/
|
||||
@GetMapping("/first-name-search")
|
||||
public String showFirstNameSearchForm(Model model) {
|
||||
model.addAttribute("customer", new Customer());
|
||||
return "customer/first-name-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/first-name-search
|
||||
* <p>
|
||||
* Processes request searching by first name
|
||||
*
|
||||
* @param customer variable type Customer
|
||||
* @param model model to add attributes to
|
||||
* @return customer/show-list
|
||||
*/
|
||||
@PostMapping("/first-name-search")
|
||||
public String processRequestFirstNameSearch(@ModelAttribute Customer customer, Model model) {
|
||||
model.addAttribute("customers", customerService.findByEnabledTrueAndFirstName(customer.getFirstName()));
|
||||
return "customer/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/last-name-search
|
||||
* <p>
|
||||
* Shows form to search customer by last name
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return customer/last-name-search
|
||||
*/
|
||||
@GetMapping("/last-name-search")
|
||||
public String showLastNameSearchForm(Model model) {
|
||||
model.addAttribute("customer", new Customer());
|
||||
return "customer/last-name-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/last-name-search
|
||||
* <p>
|
||||
* Processes request searching by last name
|
||||
*
|
||||
* @param customer variable type Customer
|
||||
* @param model model to add attributes to
|
||||
* @return customer/show-list
|
||||
*/
|
||||
@PostMapping("/last-name-search")
|
||||
public String processRequestLastNameSearch(@ModelAttribute Customer customer, Model model) {
|
||||
model.addAttribute("customers", customerService.findByEnabledTrueAndLastName(customer.getLastName()));
|
||||
return "customer/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/first-name-last-name-search
|
||||
* <p>
|
||||
* Shows form to search customer by first name and last name
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return customer/first-name-last-name-search
|
||||
*/
|
||||
@GetMapping("/first-name-last-name-search")
|
||||
public String showFirstNameLastNameSearchForm(Model model) {
|
||||
model.addAttribute("customer", new Customer());
|
||||
return "customer/first-name-last-name-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/first-name-last-name-search
|
||||
* <p>
|
||||
* Processes request searching by first name and last name
|
||||
*
|
||||
* @param customer variable type Customer
|
||||
* @param model model to add attributes to
|
||||
* @return customer/show-list
|
||||
*/
|
||||
@PostMapping("/first-name-last-name-search")
|
||||
public String processRequestFirstNameLastNameSearch(@ModelAttribute Customer customer, Model model) {
|
||||
model.addAttribute("customers",
|
||||
customerService.findByEnabledTrueAndFirstNameAndLastName(customer.getFirstName(), customer.getLastName()));
|
||||
return "customer/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/city-search
|
||||
* <p>
|
||||
* Shows form to search customer by city
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return customer/city-search
|
||||
*/
|
||||
@GetMapping("/city-search")
|
||||
public String showCitySearchForm(Model model) {
|
||||
model.addAttribute("customer", new Customer());
|
||||
return "customer/city-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/city-search
|
||||
* <p>
|
||||
* Processes request searching by city
|
||||
*
|
||||
* @param customer variable type Customer
|
||||
* @param model model to add attributes to
|
||||
* @return customer/show-list
|
||||
*/
|
||||
@PostMapping("/city-search")
|
||||
public String processRequestCitySearch(@ModelAttribute Customer customer, Model model) {
|
||||
model.addAttribute("customers", customerService.findByEnabledTrueAndCity(customer.getCity()));
|
||||
return "customer/show-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/city-address-search
|
||||
* <p>
|
||||
* Shows form to search customer by city and address
|
||||
*
|
||||
* @param model model to add attributes to
|
||||
* @return customer/city-address-search
|
||||
*/
|
||||
@GetMapping("/city-address-search")
|
||||
public String showCityAddressSearchForm(Model model) {
|
||||
model.addAttribute("customer", new Customer());
|
||||
return "customer/city-address-search";
|
||||
}
|
||||
|
||||
/**
|
||||
* /customer/city-address-search
|
||||
* <p>
|
||||
* Processes request searching by city and address
|
||||
*
|
||||
* @param customer variable type Customer
|
||||
* @param model model to add attributes to
|
||||
* @return customer/show-list
|
||||
*/
|
||||
@PostMapping("/city-address-search")
|
||||
public String processRequestCityAddressSearch(@ModelAttribute Customer customer, Model model) {
|
||||
model.addAttribute("customers",
|
||||
customerService.findByEnabledTrueAndCityAndAddress(customer.getCity(), customer.getAddress()));
|
||||
return "customer/show-list";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package crm.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/date")
|
||||
public class DateTimeTestController {
|
||||
|
||||
@GetMapping("/test")
|
||||
public String dateTimeTest(Model model) {
|
||||
model.addAttribute("standardDate", new Date());
|
||||
model.addAttribute("localDateTime", LocalDateTime.now());
|
||||
model.addAttribute("localDate", LocalDate.now());
|
||||
model.addAttribute("timestamp", Instant.now());
|
||||
return "date/test";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package crm.controller;
|
||||
|
||||
import crm.service.UserService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
public class Export {
|
||||
|
||||
private UserService userService;
|
||||
|
||||
public Export(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle request to download an Excel document
|
||||
*/
|
||||
@GetMapping("/download")
|
||||
public String download(Model model) {
|
||||
model.addAttribute("users", userService.listAllUsers());
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package crm.controller;
|
||||
|
||||
//@Controller
|
||||
public class ExportCustomers {
|
||||
|
||||
// @Autowired
|
||||
// CustomerService customerService;
|
||||
//
|
||||
// /**
|
||||
// * Handle request to download an Excel document
|
||||
// */
|
||||
// @GetMapping("/download")
|
||||
// public String download(Model model) {
|
||||
// model.addAttribute("customers", customerService.listAllCustomers());
|
||||
// return "";
|
||||
// }
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package crm.controller;
|
||||
|
||||
import org.springframework.boot.autoconfigure.web.ErrorController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class MyErrorController implements ErrorController {
|
||||
|
||||
private static final String PATH = "/error";
|
||||
|
||||
@RequestMapping(value = PATH)
|
||||
public String error() {
|
||||
return "Error handling";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorPath() {
|
||||
return PATH;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package crm.controller;
|
||||
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.Paragraph;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
import crm.entity.Pdf;
|
||||
import crm.service.PdfService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
@Controller
|
||||
@Slf4j
|
||||
public class PdfController {
|
||||
|
||||
private PdfService pdfService;
|
||||
|
||||
public PdfController(PdfService pdfService) {
|
||||
this.pdfService = pdfService;
|
||||
}
|
||||
|
||||
private void generateSamplePdf(String fileName, String text) throws FileNotFoundException, DocumentException {
|
||||
if (!fileName.endsWith(".pdf")) {
|
||||
fileName += ".pdf";
|
||||
}
|
||||
Document document = new Document();
|
||||
PdfWriter.getInstance(document, new FileOutputStream(fileName));
|
||||
document.open();
|
||||
Paragraph paragraph = new Paragraph(text);
|
||||
document.add(paragraph);
|
||||
document.close();
|
||||
}
|
||||
|
||||
@GetMapping("/pdf-generator")
|
||||
public String pdfGenerator(Model model) {
|
||||
model.addAttribute("pdf", new Pdf());
|
||||
return "pdf/generator";
|
||||
}
|
||||
|
||||
@PostMapping("/pdf-generator")
|
||||
public String generatePdf(@Valid Pdf pdf, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return "redirect:/pdf-generator";
|
||||
} else {
|
||||
try {
|
||||
generateSamplePdf(pdf.getName(), pdf.getContent());
|
||||
pdfService.savePdf(pdf);
|
||||
} catch (FileNotFoundException e) {
|
||||
log.info("File Not Found");
|
||||
} catch (DocumentException e) {
|
||||
log.info("Document");
|
||||
}
|
||||
return "pdf/success";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package crm.controller;
|
||||
|
||||
import crm.entity.User;
|
||||
import crm.service.UserService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
public class RegisterController {
|
||||
|
||||
private UserService userService;
|
||||
|
||||
public RegisterController(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@GetMapping("/register")
|
||||
public String showRegistrationPage(Model model, User user){
|
||||
model.addAttribute("user", user);
|
||||
return "register";
|
||||
}
|
||||
|
||||
@PostMapping("/register")
|
||||
public String processRegistrationForm(Model model, @Valid User user, BindingResult bindingResult) {
|
||||
User userFromDB = userService.findByUsername(user.getUsername());
|
||||
|
||||
if (userFromDB != null) {
|
||||
model.addAttribute("alreadyRegisteredMessage",
|
||||
"Oops! There is already a user registered with the email provided.");
|
||||
bindingResult.reject("email");
|
||||
return "register";
|
||||
}
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return "redirect:/register";
|
||||
} else {
|
||||
userService.saveUser(user);
|
||||
return "success";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
package crm.controller;
|
||||
|
||||
import crm.entity.User;
|
||||
import crm.service.UserService;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
|
||||
private UserService userService;
|
||||
|
||||
public UserController(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
/**
|
||||
* /user/list
|
||||
* <p>
|
||||
* Shows all users
|
||||
*
|
||||
* @param model model to attributes to
|
||||
* @return user/list
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public String showAllUsers(Model model, @AuthenticationPrincipal UserDetails currentUser) {
|
||||
model.addAttribute("currentUser", userService.findByUsername(currentUser.getUsername()));
|
||||
model.addAttribute("users", userService.listAllUsers());
|
||||
return "user/list";
|
||||
}
|
||||
|
||||
/**
|
||||
* /user/edit/{id}
|
||||
* <p>
|
||||
* Shows edit user form
|
||||
*
|
||||
* @param model model to attributes to
|
||||
* @param id variable type long user id
|
||||
* @return user/edit
|
||||
*/
|
||||
@GetMapping("/edit/{id}")
|
||||
public String showFormEditUser(Model model, @PathVariable Long id) {
|
||||
model.addAttribute("user", userService.showUser(id));
|
||||
return "user/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* /user/edit/{id}
|
||||
* <p>
|
||||
* Processes edit user request
|
||||
*
|
||||
* @param id variable type long user id
|
||||
* @param user variable type User
|
||||
* @param bindingResult variable type BindingResult
|
||||
* @return redirect:/user/list
|
||||
*/
|
||||
@PostMapping("/edit/{id}")
|
||||
public String processRequestEditUser(@PathVariable Long id, @Valid User user,
|
||||
BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return "redirect:/user/edit/" + id;
|
||||
} else {
|
||||
userService.editUser(user);
|
||||
return "redirect:/user/list";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* /user/delete/{id}
|
||||
* <p>
|
||||
* Deletes user
|
||||
*
|
||||
* @param id variable type long user id
|
||||
* @return redirect:/user/list
|
||||
*/
|
||||
@GetMapping("/delete/{id}")
|
||||
public String deleteUser(@PathVariable Long id) {
|
||||
userService.deleteUser(userService.showUser(id));
|
||||
return "redirect:/user/list";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package crm.csv;
|
||||
|
||||
import com.opencsv.CSVReader;
|
||||
import crm.utils.ReadDataUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CSVTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
File document = ReadDataUtils.ReadFile("Select CSV file", null, "Only CSV Files", "csv");
|
||||
// System.out.println(document.getName());
|
||||
|
||||
CSVReader reader;
|
||||
List<Object[]> data = new ArrayList<>();
|
||||
try {
|
||||
reader = new CSVReader(new FileReader(document));
|
||||
String[] line;
|
||||
while ((line = reader.readNext()) != null) {
|
||||
// System.out.println(line[1] + "\t" + line[2]);
|
||||
data.add(line);
|
||||
if(line[1].equals("QUICK SUB")){
|
||||
System.out.println(line[0] + "\t" + line[1] + "\t" + line[2]);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
/*System.out.println(data.get(0)[1] + "\t" + data.get(0)[2]);
|
||||
System.out.println(data.get(1)[1] + "\t" + data.get(1)[2]);*/
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package crm.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "category")
|
||||
public class Category {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@Column(name = "category_id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "category")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package crm.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Contract {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
private String name;
|
||||
|
||||
private String content;
|
||||
|
||||
private BigDecimal value;
|
||||
|
||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
|
||||
private LocalDate beginDate;
|
||||
|
||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
|
||||
private LocalDate endDate;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Status status;
|
||||
|
||||
@ManyToOne
|
||||
private Customer customer;
|
||||
|
||||
@ManyToOne
|
||||
private User user;
|
||||
|
||||
// @Transient
|
||||
// private DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package crm.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
public class CurrentUser implements UserDetails {
|
||||
|
||||
private User user;
|
||||
|
||||
private Set<GrantedAuthority> authorities;
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
return authorities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return user.getPassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return user.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package crm.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Email;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Customer {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
@Size(min = 2)
|
||||
private String name;
|
||||
|
||||
@Column(name = "email", nullable = false, unique = true)
|
||||
@Email(message = "Please provide a valid e-mail")
|
||||
@NotEmpty(message = "Please provide an e-mail")
|
||||
private String email;
|
||||
|
||||
@Digits(fraction = 0, integer = 20)
|
||||
private int phone;
|
||||
|
||||
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "customer_category",
|
||||
joinColumns = @JoinColumn(name = "customer_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "category_id"))
|
||||
private Set<Category> categories;
|
||||
|
||||
private String firstName;
|
||||
|
||||
private String lastName;
|
||||
|
||||
private String city;
|
||||
|
||||
private String address;
|
||||
|
||||
private int enabled;
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package crm.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Entity(name = "pdf")
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Pdf {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
@Size(min = 2)
|
||||
private String name;
|
||||
|
||||
@Transient
|
||||
private String content;
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package crm.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "role")
|
||||
public class Role {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@Column(name = "role_id")
|
||||
private int id;
|
||||
|
||||
@Column(name = "role", unique = true)
|
||||
private String name;
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package crm.entity;
|
||||
|
||||
public enum Status {
|
||||
|
||||
PROPOSED,
|
||||
NEGOTIATED,
|
||||
IMPLEMENTED,
|
||||
DONE;
|
||||
|
||||
public static final Status[] ALL = {PROPOSED, NEGOTIATED, IMPLEMENTED, DONE};
|
||||
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package crm.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Email;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity(name = "users")
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
private String username;
|
||||
|
||||
@Column(name = "email", nullable = false, unique = true)
|
||||
@Email(message = "Please provide a valid e-mail")
|
||||
@NotEmpty(message = "Please provide an e-mail")
|
||||
private String email;
|
||||
|
||||
private String firstName;
|
||||
|
||||
private String lastName;
|
||||
|
||||
private String password;
|
||||
|
||||
private int enabled;
|
||||
|
||||
@ManyToOne
|
||||
private Role role;
|
||||
|
||||
public int getColumnCount() {
|
||||
return getClass().getDeclaredFields().length;
|
||||
}
|
||||
|
||||
public int getRole_id() {
|
||||
return role.getId();
|
||||
}
|
||||
|
||||
public String getRole_name() {
|
||||
return role.getName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return firstName + " " + lastName;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
spring.jpa.hibernate.ddl-auto=create-drop
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/crm?useSSL=false
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=password
|
||||
|
||||
management.security.enabled=false
|
||||
management.context-path=/appinfo
|
||||
|
||||
spring.thymeleaf.mode=LEGACYHTML5
|
||||
spring.thymeleaf.cache=false
|
||||
@ -0,0 +1,27 @@
|
||||
insert into role (role_id, role) values (1, 'ROLE_ADMIN'), (2, 'ROLE_USER'), (3, 'ROLE_MANAGER'), (4, 'ROLE_OWNER');
|
||||
|
||||
INSERT INTO users (id, email, enabled, first_name, last_name, password, username, role_role_id)
|
||||
VALUES ('1', 'a@u', '1', 'AFN', 'ALN', '$2a$10$iPgnenFIoM67cYL9let/iOLBphbDaEkAz3BmiXOCmWq5A4M2TkXAG', 'admin', '1'),
|
||||
('2', 'u@m', '1', 'UFN', 'ULN', '$2a$10$Ad.n7DA3e9QT.a8hXymxI.JKnAYTLR4nD4stJtfMiCLcr7FiZ/st.', 'user', '2'),
|
||||
('3', 'm@m', '1', 'MFN', 'MLN', '$2a$10$iQy1MYc97kkXBwrCJ5I9gO/QcRT.rdY6UDKriBvG.iyX29miDaKDe', 'manager', '3'),
|
||||
('4', 'o@m', '1', 'OFN', 'OLN', '$2a$10$VVH6bnOWLMczmH12BY99c.T6JMzMErt/gZKRCPfYlXcq7JMFoqkWW', 'owner', '4');
|
||||
# admin - pass = admin
|
||||
# user - pass = user
|
||||
# manager - pass = manager
|
||||
# owner - pass = owner
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
INSERT INTO category (category_id, category)
|
||||
VALUES ('1', 'small'), ('2', 'medium'), ('3', 'big');
|
||||
|
||||
INSERT INTO customer (id, address, city, email, enabled, first_name, last_name, name, phone)
|
||||
VALUES ('1', 'Small Street', 'Smallville', 'smallmail@mail.com', '1', 'SmallFN', 'SmallLN', 'Small INC', '123'),
|
||||
('2', 'Medium Street', 'Midtown', 'midmail@mail.com', '1', 'MidFN', 'MidLN', 'Mid INC', '456'),
|
||||
('3', 'Big Street', 'Big City', 'bigmail@mail.com', '1', 'BigFN', 'BigLN', 'Big INC', '789');
|
||||
|
||||
INSERT INTO customer_category (customer_id, category_id)
|
||||
VALUES (1, 1), (2, 2), (3, 3);
|
||||
|
||||
INSERT INTO contract (id, begin_date, content, end_date, name, status, value, customer_id, user_id)
|
||||
VALUES ('1', '2018-02-24 00:00:00', 'contract content', '2018-02-25 00:00:00', 'ContractName', 'PROPOSED', '100000.00', '2', '2');
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
||||
@ -0,0 +1,33 @@
|
||||
customer.id = id
|
||||
customer.address = address
|
||||
customer.city = city
|
||||
customer.email = email
|
||||
customer.first.name = first name
|
||||
customer.last.name = last name
|
||||
customer.name = name
|
||||
customer.phone = phone
|
||||
ordinal.number = no.
|
||||
user.username = Username
|
||||
user.email = Email
|
||||
user.first.name = First Name
|
||||
user.last.name = Last Name
|
||||
user.id = User id
|
||||
user.name = User name
|
||||
contract.id = id
|
||||
contract.name = name
|
||||
contract.content = content
|
||||
contract.value = value
|
||||
contract.begin.date = begin_date
|
||||
contract.end.date = end_date
|
||||
contract.status = status
|
||||
|
||||
crm.status = Status
|
||||
crm.status.PROPOSED = PROPOSED
|
||||
crm.status.NEGOTIATED = NEGOTIATED
|
||||
crm.status.IMPLEMENTED = IMPLEMENTED
|
||||
crm.status.DONE = DONE
|
||||
crm.customer.name = Customer name
|
||||
crm.customer.id = Customer id
|
||||
crm.user.id = User id
|
||||
role.id = Role id
|
||||
role.name = Role name
|
||||
@ -0,0 +1,11 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>Security with Spring Boot</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Access denied</h1>
|
||||
<a th:href="@{/login}">Login page</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Admin panel</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Admin panel</h1>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,77 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Add contract</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Add contract form</h2>
|
||||
<form th:action="@{|/contract/add|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Name:
|
||||
<input type="text" th:field="*{name}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Content:
|
||||
<input type="text" th:field="*{content}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Value:
|
||||
<input type="text" th:field="*{value}" placeholder="1000"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Begin Date:
|
||||
<input type="date" th:field="*{beginDate}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
End date:
|
||||
<input type="date" th:field="*{endDate}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Status:
|
||||
<select th:field="*{status}">
|
||||
<option th:each="status : ${T(crm.entity.Status).ALL}"
|
||||
th:value="${status}" th:text="${status}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Customer:
|
||||
<select th:field="*{customer.id}">
|
||||
<option th:each="customer : ${customers}"
|
||||
th:value="${customer.id}" th:text="${customer}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
User:
|
||||
<select th:field="*{user.id}">
|
||||
<option th:each="user : ${users}"
|
||||
th:value="${user.id}" th:text="${user}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Add Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search contract by begin date after</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search contract by begin date after</h2>
|
||||
<form th:action="@{|/contract/begin-date-after-search|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Begin Date:
|
||||
<input type="date" th:field="*{beginDate}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search contract by begin date before</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search contract by begin date before</h2>
|
||||
<form th:action="@{|/contract/begin-date-before-search|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Begin Date:
|
||||
<input type="date" th:field="*{beginDate}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search contract by begin date</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search contract by begin date</h2>
|
||||
<form th:action="@{|/contract/begin-date-search|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Begin Date:
|
||||
<input type="date" th:field="*{beginDate}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Contracts management</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Contracts management</h2>
|
||||
|
||||
<p><a th:href="@{|/contract/search|}" th:text="'Search for contract'"></a></p>
|
||||
<p><a th:href="@{|/contract/list|}" th:text="'Show contracts list'"></a></p>
|
||||
<p><a th:href="@{|/contract/add|}" th:text="'Add new contract'"></a></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search contracts by customer</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search contracts by customer</h2>
|
||||
<form th:action="@{|/contract/customer-search|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Customer:
|
||||
<select th:field="*{customer.id}">
|
||||
<option th:each="customer : ${customers}"
|
||||
th:value="${customer.id}" th:text="${customer}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search contracts by customer and user</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search contracts by customer and user</h2>
|
||||
<form th:action="@{|/contract/customer-user-search|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Customer:
|
||||
<select th:field="*{customer.id}">
|
||||
<option th:each="customer : ${customers}"
|
||||
th:value="${customer.id}" th:text="${customer}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
User:
|
||||
<select th:field="*{user.id}">
|
||||
<option th:each="user : ${users}"
|
||||
th:value="${user.id}" th:text="${user}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,69 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Edit contract</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Edit contract form</h2>
|
||||
<form th:action="@{|/contract/edit/${contract.id}|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Name:
|
||||
<input type="text" th:field="*{name}" th:value="*{name}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Content:
|
||||
<input type="text" th:field="*{content}" th:value="*{content}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Value:
|
||||
<input type="text" th:field="*{value}" th:value="*{value}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Begin Date:
|
||||
<input type="date" th:field="*{beginDate}" th:value="*{beginDate}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
End date:
|
||||
<input type="date" th:field="*{endDate}" th:value="*{endDate}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Status:
|
||||
<select th:field="*{status}">
|
||||
<option th:each="status : ${T(crm.entity.Status).ALL}"
|
||||
th:value="${status}" th:text="${status}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Customer id:
|
||||
<input type="number" th:field="*{customer.id}" th:value="*{customer.id}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
User id:
|
||||
<input type="number" th:field="*{user.id}" th:value="*{user.id}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Edit Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search contract by end date after</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search contract by end date after</h2>
|
||||
<form th:action="@{|/contract/end-date-after-search|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
End Date:
|
||||
<input type="date" th:field="*{endDate}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search contract by end date before</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search contract by end date before</h2>
|
||||
<form th:action="@{|/contract/end-date-before-search|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
End Date:
|
||||
<input type="date" th:field="*{endDate}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search contract by end date</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search contract by end date</h2>
|
||||
<form th:action="@{|/contract/end-date-search|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
End Date:
|
||||
<input type="date" th:field="*{endDate}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Contracts</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><a th:text="#{contract.id}"></a></th>
|
||||
<th><a th:text="#{contract.name}"></a></th>
|
||||
<th><a th:text="#{contract.content}"></a></th>
|
||||
<th><a th:text="#{contract.value}"></a></th>
|
||||
<th><a th:text="#{contract.begin.date}"></a></th>
|
||||
<th><a th:text="#{contract.end.date}"></a></th>
|
||||
<th><a th:text="#{contract.status}"></a></th>
|
||||
<th><a th:text="#{crm.customer.name}"></a></th>
|
||||
<th><a th:text="#{user.name}"></a></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="contract : ${contracts}">
|
||||
<td th:text="${contract.id}"></td>
|
||||
<td th:text="${contract.name}"></td>
|
||||
<td th:text="${contract.content}"></td>
|
||||
<td th:text="${contract.value}"></td>
|
||||
<td th:text="${#temporals.format(contract.beginDate, 'dd.MM.yyyy')}"></td>
|
||||
<td th:text="${#temporals.format(contract.endDate, 'dd.MM.yyyy')}"></td>
|
||||
<td th:text="${contract.status}"></td>
|
||||
<td th:text="${contract.customer.name}"></td>
|
||||
<td th:text="${contract.user.name}"></td>
|
||||
<p sec:authorize="hasAnyRole('ROLE_MANAGER', 'ROLE_OWNER')">
|
||||
<td><a th:href="@{|/contract/edit/${contract.id}|}">Edit</a></td>
|
||||
</p>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search for contract</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search contract by Name</h2>
|
||||
<form th:action="@{|/contract/name-search|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Name:
|
||||
<input type="text" th:field="*{name}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Choose searching type</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Choose searching type</h2>
|
||||
|
||||
<p><a th:href="@{|/contract/name-search|}" th:text="'Search for contract by Name'"></a></p>
|
||||
<p><a th:href="@{|/contract/value-le-search|}" th:text="'Search for contracts by Value Less Than Equal'"></a></p>
|
||||
<p><a th:href="@{|/contract/value-ge-search|}" th:text="'Search for contracts by Value Greater Than Equal'"></a></p>
|
||||
<p><a th:href="@{|/contract/begin-date-search|}" th:text="'Search for contracts by Begin Date'"></a></p>
|
||||
<p><a th:href="@{|/contract/begin-date-before-search|}" th:text="'Search for contracts by Begin Date Before'"></a></p>
|
||||
<p><a th:href="@{|/contract/begin-date-after-search|}" th:text="'Search for contracts by Begin Date After'"></a></p>
|
||||
<p><a th:href="@{|/contract/end-date-search|}" th:text="'Search for contracts by End Date'"></a></p>
|
||||
<p><a th:href="@{|/contract/end-date-before-search|}" th:text="'Search for contracts by End Date Before'"></a></p>
|
||||
<p><a th:href="@{|/contract/end-date-after-search|}" th:text="'Search for contracts by End Date After'"></a></p>
|
||||
<p><a th:href="@{|/contract/status-search|}" th:text="'Search for contracts by Status'"></a></p>
|
||||
<p><a th:href="@{|/contract/customer-search|}" th:text="'Search for contracts by Customer'"></a></p>
|
||||
<p><a th:href="@{|/contract/customer-user-search|}" th:text="'Search for contracts by Customer and User'"></a></p>
|
||||
<p><a th:href="@{|/contract/user-search|}" th:text="'Search for contracts by User'"></a></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Searching result</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><a th:text="#{contract.id}"></a></th>
|
||||
<th><a th:text="#{contract.name}"></a></th>
|
||||
<th><a th:text="#{contract.content}"></a></th>
|
||||
<th><a th:text="#{contract.value}"></a></th>
|
||||
<th><a th:text="#{contract.begin.date}"></a></th>
|
||||
<th><a th:text="#{contract.end.date}"></a></th>
|
||||
<th><a th:text="#{contract.status}"></a></th>
|
||||
<th><a th:text="#{crm.customer.name}"></a></th>
|
||||
<th><a th:text="#{user.name}"></a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="contract : ${contracts}">
|
||||
<td th:text="${contract.id}"></td>
|
||||
<td th:text="${contract.name}"></td>
|
||||
<td th:text="${contract.content}"></td>
|
||||
<td th:text="${contract.value}"></td>
|
||||
<td th:text="${#temporals.format(contract.beginDate, 'dd.MM.yyyy')}"></td>
|
||||
<td th:text="${#temporals.format(contract.endDate, 'dd.MM.yyyy')}"></td>
|
||||
<td th:text="${contract.status}"></td>
|
||||
<td th:text="${contract.customer.name}"></td>
|
||||
<td th:text="${contract.user.name}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Searching result</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><a th:text="#{contract.id}"></a></th>
|
||||
<th><a th:text="#{contract.name}"></a></th>
|
||||
<th><a th:text="#{contract.content}"></a></th>
|
||||
<th><a th:text="#{contract.value}"></a></th>
|
||||
<th><a th:text="#{contract.begin.date}"></a></th>
|
||||
<th><a th:text="#{contract.end.date}"></a></th>
|
||||
<th><a th:text="#{contract.status}"></a></th>
|
||||
<th><a th:text="#{crm.customer.name}"></a></th>
|
||||
<th><a th:text="#{user.name}"></a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:object="${contract}">
|
||||
<td th:text="*{id}"></td>
|
||||
<td th:text="*{name}"></td>
|
||||
<td th:text="*{content}"></td>
|
||||
<td th:text="*{value}"></td>
|
||||
<td th:text="*{beginDate}"></td>
|
||||
<td th:text="*{endDate}"></td>
|
||||
<td th:text="*{status}"></td>
|
||||
<td th:text="*{customer.name}"></td>
|
||||
<td th:text="*{user.name}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search contract by status</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search contract by status</h2>
|
||||
<form th:action="@{|/contract/status-search|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Status:
|
||||
<select th:field="*{status}">
|
||||
<option th:each="status : ${T(crm.entity.Status).ALL}"
|
||||
th:value="${status}" th:text="${status}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Success</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Contract successfully added to database</h2>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search contracts by user</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search contracts by user</h2>
|
||||
<form th:action="@{|/contract/user-search|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
User:
|
||||
<select th:field="*{user.id}">
|
||||
<option th:each="user : ${users}"
|
||||
th:value="${user.id}" th:text="${user}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search contract by value greater equal than</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search contract by value greater equal than</h2>
|
||||
<form th:action="@{|/contract/value-ge-search|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Value:
|
||||
<input type="text" th:field="*{value}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search contract by value less equal than</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search contract by value less equal than</h2>
|
||||
<form th:action="@{|/contract/value-le-search|}" th:object="${contract}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Value:
|
||||
<input type="text" th:field="*{value}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Contract"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!--<p><a th:href="@{|/import|}" th:text="'Import CSV file'"></a></p>-->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>CSV show</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ROW</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="d : ${data}">
|
||||
<td th:text="${d}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Add new customer based on another one</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Add new customer based on another one form</h2>
|
||||
<form th:action="@{|/customer/addCustomerBasedOnAnotherOne/${customer.id}|}" th:object="${customer}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Name:
|
||||
<input type="text" th:field="*{name}" th:value="*{name}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
E-mail:
|
||||
<input type="email" th:field="*{email}" th:value="*{email}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Phone:
|
||||
<input type="number" th:field="*{phone}" th:value="*{phone}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
First Name:
|
||||
<input type="text" th:field="*{firstName}" th:value="*{firstName}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Last Name:
|
||||
<input type="text" th:field="*{lastName}" th:value="*{lastName}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Address:
|
||||
<input type="text" th:field="*{address}" th:value="*{address}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
City:
|
||||
<input type="text" th:field="*{city}" th:value="*{city}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Add New Customer"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Add customer</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Add customer form</h2>
|
||||
<form th:action="@{|/customer/add|}" th:object="${customer}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Name:
|
||||
<input type="text" th:field="*{name}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
E-mail:
|
||||
<input type="email" th:field="*{email}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Phone:
|
||||
<input type="number" th:field="*{phone}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
First Name:
|
||||
<input type="text" th:field="*{firstName}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Last Name:
|
||||
<input type="text" th:field="*{lastName}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Address:
|
||||
<input type="text" th:field="*{address}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
City:
|
||||
<input type="text" th:field="*{city}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Add Customer"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search for customer</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search customer by City and Address</h2>
|
||||
<form th:action="@{|/customer/city-address-search|}" th:object="${customer}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
City:
|
||||
<input type="text" th:field="*{city}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Address:
|
||||
<input type="text" th:field="*{address}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Customer"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search for customer</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search customer by City</h2>
|
||||
<form th:action="@{|/customer/city-search|}" th:object="${customer}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
City:
|
||||
<input type="text" th:field="*{city}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Customer"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Customers management</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Customers management</h2>
|
||||
|
||||
<p><a th:href="@{|/search|}" th:text="'Search for customers'"></a></p>
|
||||
<p><a th:href="@{|/customer/list|}" th:text="'Show customers list'"></a></p>
|
||||
<p><a th:href="@{|/customer/add|}" th:text="'Add new customer'"></a></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Edit customer</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Edit customer form</h2>
|
||||
<form th:action="@{|/customer/edit/${customer.id}|}" th:object="${customer}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Name:
|
||||
<input type="text" th:field="*{name}" th:value="*{name}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
E-mail:
|
||||
<input type="email" th:field="*{email}" th:value="*{email}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Phone:
|
||||
<input type="number" th:field="*{phone}" th:value="*{phone}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
First Name:
|
||||
<input type="text" th:field="*{firstName}" th:value="*{firstName}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Last Name:
|
||||
<input type="text" th:field="*{lastName}" th:value="*{lastName}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Address:
|
||||
<input type="text" th:field="*{address}" th:value="*{address}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
City:
|
||||
<input type="text" th:field="*{city}" th:value="*{city}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Edit Customer"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search for customer</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search customer by Email</h2>
|
||||
<form th:action="@{|/customer/email-search|}" th:object="${customer}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
E-mail:
|
||||
<input type="email" th:field="*{email}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Customer"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search for customer</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search customer by First Name and Last Name</h2>
|
||||
<form th:action="@{|/customer/first-name-last-name-search|}" th:object="${customer}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
First Name:
|
||||
<input type="text" th:field="*{firstName}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Last Name:
|
||||
<input type="text" th:field="*{lastName}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Customer"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search for customer</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search customer by First Name</h2>
|
||||
<form th:action="@{|/customer/first-name-search|}" th:object="${customer}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
First Name:
|
||||
<input type="text" th:field="*{firstName}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Customer"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search for customer</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search customer by Last Name</h2>
|
||||
<form th:action="@{|/customer/last-name-search|}" th:object="${customer}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Last Name:
|
||||
<input type="text" th:field="*{lastName}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Customer"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Customers</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><a th:text="#{customer.id}"></a></th>
|
||||
<th><a th:text="#{customer.name}"></a></th>
|
||||
<th><a th:text="#{customer.email}"></a></th>
|
||||
<th><a th:text="#{customer.phone}"></a></th>
|
||||
<th><a th:text="#{customer.first.name}"></a></th>
|
||||
<th><a th:text="#{customer.last.name}"></a></th>
|
||||
<th><a th:text="#{customer.address}"></a></th>
|
||||
<th><a th:text="#{customer.city}"></a></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="customer : ${customers}">
|
||||
<td th:text="${customer.id}"></td>
|
||||
<td th:text="${customer.name}"></td>
|
||||
<td th:text="${customer.email}"></td>
|
||||
<td th:text="${customer.phone}"></td>
|
||||
<td th:text="${customer.firstName}"></td>
|
||||
<td th:text="${customer.lastName}"></td>
|
||||
<td th:text="${customer.address}"></td>
|
||||
<td th:text="${customer.city}"></td>
|
||||
<td><a th:href="@{|/customer/edit/${customer.id}|}">Edit</a></td>
|
||||
<td><a th:href="@{|/customer/addCustomerBasedOnAnotherOne/${customer.id}|}">Add new customer based on this</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search for customer</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search customer by Name</h2>
|
||||
<form th:action="@{|/customer/name-search|}" th:object="${customer}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Name:
|
||||
<input type="text" th:field="*{name}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Customer"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Search for customer</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Search customer by Phone</h2>
|
||||
<form th:action="@{|/customer/phone-search|}" th:object="${customer}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Phone:
|
||||
<input type="number" th:field="*{phone}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Search Customer"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Searching result</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><a th:text="#{customer.id}"></a></th>
|
||||
<th><a th:text="#{customer.address}"></a></th>
|
||||
<th><a th:text="#{customer.city}"></a></th>
|
||||
<th><a th:text="#{customer.email}"></a></th>
|
||||
<th><a th:text="#{customer.first.name}"></a></th>
|
||||
<th><a th:text="#{customer.last.name}"></a></th>
|
||||
<th><a th:text="#{customer.name}"></a></th>
|
||||
<th><a th:text="#{customer.phone}"></a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="customer : ${customers}">
|
||||
<td th:text="${customer.id}"></td>
|
||||
<td th:text="${customer.address}"></td>
|
||||
<td th:text="${customer.city}"></td>
|
||||
<td th:text="${customer.email}"></td>
|
||||
<td th:text="${customer.firstName}"></td>
|
||||
<td th:text="${customer.lastName}"></td>
|
||||
<td th:text="${customer.name}"></td>
|
||||
<td th:text="${customer.phone}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Searching result</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><a th:text="#{customer.id}"></a></th>
|
||||
<th><a th:text="#{customer.address}"></a></th>
|
||||
<th><a th:text="#{customer.city}"></a></th>
|
||||
<th><a th:text="#{customer.email}"></a></th>
|
||||
<th><a th:text="#{customer.first.name}"></a></th>
|
||||
<th><a th:text="#{customer.last.name}"></a></th>
|
||||
<th><a th:text="#{customer.name}"></a></th>
|
||||
<th><a th:text="#{customer.phone}"></a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:object="${customer}">
|
||||
<td th:text="*{id}"></td>
|
||||
<td th:text="*{address}"></td>
|
||||
<td th:text="*{city}"></td>
|
||||
<td th:text="*{email}"></td>
|
||||
<td th:text="*{firstName}"></td>
|
||||
<td th:text="*{lastName}"></td>
|
||||
<td th:text="*{name}"></td>
|
||||
<td th:text="*{phone}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Success</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Customer successfully added to database</h2>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Date test</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Date test</h1>
|
||||
|
||||
<h2>Format ISO</h2>
|
||||
<p th:text="${#dates.formatISO(standardDate)}"></p>
|
||||
<p th:text="${#temporals.formatISO(localDateTime)}"></p>
|
||||
<p th:text="${#temporals.formatISO(localDate)}"></p>
|
||||
<p th:text="${#temporals.formatISO(timestamp)}"></p>
|
||||
|
||||
<h2>Format manually</h2>
|
||||
<p th:text="${#dates.format(standardDate, 'dd-MM-yyyy HH:mm')}"></p>
|
||||
<p th:text="${#temporals.format(localDateTime, 'dd-MM-yyyy HH:mm')}"></p>
|
||||
<p th:text="${#temporals.format(localDate, 'MM-yyyy')}"></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Home page</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Home page</h1>
|
||||
|
||||
<a sec:authorize="hasRole('ROLE_ANONYMOUS')">
|
||||
<p>Login = user, Password = user</p>
|
||||
<p>Login = manager, Password = manager</p>
|
||||
<p>Login = owner, Password = owner</p>
|
||||
<p>Login = admin, Password = admin</p>
|
||||
<p>User has some restrictions. Only manager and owner can edit contracts. Only admin can delete users.</p>
|
||||
<p><a th:href="@{|/login|}" th:text="'Log in'"></a></p>
|
||||
<p><a th:href="@{|/register|}" th:text="'Register'"></a></p>
|
||||
</a>
|
||||
<a sec:authorize="isAuthenticated()">
|
||||
<p><a th:href="@{|/user/menu|}" th:text="'User menu'"></a></p>
|
||||
|
||||
<p><a th:href="@{|/customer/menu|}" th:text="'Customer menu'"></a></p>
|
||||
|
||||
<p><a th:href="@{|/contract/menu|}" th:text="'Contract menu'"></a></p>
|
||||
|
||||
<p><a th:href="@{|/pdf-generator|}" th:text="'Simple pdf generator'"></a></p>
|
||||
|
||||
<!--<p><a th:href="@{|/import|}" th:text="'Import CSV file'"></a></p>-->
|
||||
|
||||
|
||||
<p>Logged as: <span sec:authentication="name"></span></p>
|
||||
<p>Has role: <span sec:authentication="authorities"></span></p>
|
||||
|
||||
<a th:href="@{/logout}">Log out</a>
|
||||
</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||
<body>
|
||||
|
||||
<h1>Custom login page</h1>
|
||||
<form th:action="@{/login}" method="post">
|
||||
<div><label> User Name : <input type="text" name="username"/> </label></div>
|
||||
<div><label> Password: <input type="password" name="password"/> </label></div>
|
||||
<div><input type="submit" value="Sign In"/></div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||
<body>
|
||||
|
||||
<h1 th:inline="text">Hello in options</h1>
|
||||
<form th:action="@{/logout}" method="post">
|
||||
<input type="submit" value="Log Out"/>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Document generator</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h3>Enter the data to generate the document</h3>
|
||||
|
||||
<form th:action="@{/pdf-generator}" th:object="${pdf}" method="post" id="pdfform">
|
||||
<div>
|
||||
<input type="hidden" th:field="*{id}" />
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
File name:
|
||||
<input type="text" th:field="*{name}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Generate pdf"/>
|
||||
</div>
|
||||
</form>
|
||||
<textarea form ="pdfform" name="taname" id="taid" cols="35" wrap="soft" th:field="${pdf.content}"></textarea>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Success</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Pdf successfully created.</h2>
|
||||
<p>File is saved in project main folder</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Register</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Register</h2>
|
||||
<form th:action="@{/register}" th:object="${user}" method="post">
|
||||
<div>
|
||||
<input type="hidden" th:field="*{id}" />
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Username:
|
||||
<input type="text" th:field="*{username}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Email:
|
||||
<input type="email" th:field="*{email}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Password:
|
||||
<input type="password" th:field="*{password}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
First Name:
|
||||
<input type="text" th:field="*{firstName}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Last Name:
|
||||
<input type="text" th:field="*{lastName}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Register"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Choose searching type</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Choose searching type</h2>
|
||||
|
||||
<p><a th:href="@{|/customer/name-search|}" th:text="'Search for customers by Name'"></a></p>
|
||||
<p><a th:href="@{|/customer/email-search|}" th:text="'Search for customers by Email'"></a></p>
|
||||
<p><a th:href="@{|/customer/phone-search|}" th:text="'Search for customers by Phone'"></a></p>
|
||||
<p><a th:href="@{|/customer/first-name-search|}" th:text="'Search for customers by First Name'"></a></p>
|
||||
<p><a th:href="@{|/customer/last-name-search|}" th:text="'Search for customers by Last Name'"></a></p>
|
||||
<p><a th:href="@{|/customer/first-name-last-name-search|}" th:text="'Search for customers by First Name and Last Name'"></a></p>
|
||||
<p><a th:href="@{|/customer/city-search|}" th:text="'Search for customers by City'"></a></p>
|
||||
<p><a th:href="@{|/customer/city-address-search|}" th:text="'Search for customers by City and Address'"></a></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Success</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>User successfully added to database</h2>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Edit user</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Edit user form</h2>
|
||||
<form th:action="@{|/user/edit/${user.id}|}" th:object="${user}" method="post">
|
||||
<div>
|
||||
<label>
|
||||
Username:
|
||||
<input type="text" th:field="*{username}" th:value="*{username}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
E-mail:
|
||||
<input type="email" th:field="*{email}" th:value="*{email}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
First Name:
|
||||
<input type="text" th:field="*{firstName}" th:value="*{firstName}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Last Name:
|
||||
<input type="text" th:field="*{lastName}" th:value="*{lastName}"/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Password:
|
||||
<input type="password" th:field="*{password}" th:value="*{password}"/>
|
||||
</label>
|
||||
</div>
|
||||
<p sec:authorize="hasAnyRole('ROLE_MANAGER', 'ROLE_OWNER', 'ROLE_ADMIN')">
|
||||
<div>
|
||||
<label>
|
||||
Role:
|
||||
<input type="text" th:field="*{role.id}" th:value="*{role.id}"/>
|
||||
</label>
|
||||
</div>
|
||||
</p>
|
||||
<div>
|
||||
<input type="submit" value="Edit User"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,60 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Users</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><a th:text="#{ordinal.number}"></a></th>
|
||||
<th><a th:text="#{user.username}"></a></th>
|
||||
<th><a th:text="#{user.email}"></a></th>
|
||||
<th><a th:text="#{user.first.name}"></a></th>
|
||||
<th><a th:text="#{user.last.name}"></a></th>
|
||||
<th><a th:text="#{role.id}"></a></th>
|
||||
<th><a th:text="#{role.name}"></a></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="user, iterStat : ${users}">
|
||||
<td th:text="${iterStat.count}"></td>
|
||||
<td th:text="${user.username}"></td>
|
||||
<td th:text="${user.email}"></td>
|
||||
<td th:text="${user.firstName}"></td>
|
||||
<td th:text="${user.lastName}"></td>
|
||||
<td th:text="${user.role.id}"></td>
|
||||
<td th:text="${user.role.name}"></td>
|
||||
<p sec:authorize="hasAnyRole('ROLE_USER', 'ROLE_MANAGER')">
|
||||
<td><a th:if="${currentUser.equals(user)}" th:href="@{|/user/edit/${user.id}|}">Edit</a></td>
|
||||
</p>
|
||||
<p sec:authorize="hasAnyRole('ROLE_OWNER', 'ROLE_ADMIN')">
|
||||
<td><a th:href="@{|/user/edit/${user.id}|}">Edit</a></td>
|
||||
</p>
|
||||
<p sec:authorize="hasRole('ROLE_ADMIN')">
|
||||
<td><a th:unless="${currentUser.equals(user)}" th:href="@{|/user/delete/${user.id}|}">Delete</a></td>
|
||||
</p>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><a th:href="@{|/download.pdf|}" th:text="'Download users list in PDF file'"></a></p>
|
||||
<p><a th:href="@{|/download.xls|}" th:text="'Download users list in XLS file'"></a></p>
|
||||
<p><a th:href="@{|/download.csv|}" th:text="'Download users list in CSV file'"></a></p>
|
||||
|
||||
<p sec:authorize="isAuthenticated()">
|
||||
<p>Logged as: <span sec:authentication="name"></span></p>
|
||||
<p>Has role: <span sec:authentication="authorities"></span></p>
|
||||
</p>
|
||||
|
||||
<span sec:authorize="isAuthenticated()">
|
||||
<a th:href="@{/logout}">Log out</a>
|
||||
</span>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Success</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>User successfully added to database</h2>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Users management</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Users management</h2>
|
||||
|
||||
<p><a th:href="@{|/user/list|}" th:text="'Show users list'"></a></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,16 @@
|
||||
package crm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class CrmApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package crm;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
|
||||
|
||||
@EntityScan(
|
||||
basePackageClasses = {CrmApplication.class, Jsr310JpaConverters.class}
|
||||
)
|
||||
@SpringBootApplication
|
||||
public class CrmApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CrmApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package crm;
|
||||
|
||||
import crm.service.SpringDataUserDetailsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(securedEnabled = true)
|
||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
public BCryptPasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SpringDataUserDetailsService customUserDetailsService() {
|
||||
return new SpringDataUserDetailsService();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.userDetailsService(customUserDetailsService()).passwordEncoder(passwordEncoder());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/admin/**", "/user/delete/**").hasRole("ADMIN")
|
||||
.antMatchers("/pdf-generator", "/search/**", "/customer/**", "/user/edit/**", "/user/list", "/contract/**").hasAnyRole( "ADMIN", "USER", "MANAGER", "OWNER")
|
||||
.anyRequest().permitAll()
|
||||
.and()
|
||||
.formLogin().loginPage("/login").permitAll()
|
||||
.and()
|
||||
.logout().logoutSuccessUrl("/").permitAll()
|
||||
.and()
|
||||
.exceptionHandling().accessDeniedPage("/403");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,165 @@
|
||||
package crm;
|
||||
|
||||
import crm.viewResolver.CsvViewResolver;
|
||||
import crm.viewResolver.ExcelViewResolver;
|
||||
import crm.viewResolver.PdfViewResolver;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Description;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.accept.ContentNegotiationManager;
|
||||
import org.springframework.web.servlet.ViewResolver;
|
||||
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
|
||||
import org.thymeleaf.TemplateEngine;
|
||||
import org.thymeleaf.dialect.springdata.SpringDataDialect;
|
||||
import org.thymeleaf.extras.java8time.dialect.Java8TimeDialect;
|
||||
import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect;
|
||||
import org.thymeleaf.spring4.SpringTemplateEngine;
|
||||
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
|
||||
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
|
||||
import org.thymeleaf.templateresolver.ITemplateResolver;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Configuration
|
||||
public class WebAppConfig extends WebMvcConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
registry.addViewController("/login").setViewName("login");
|
||||
registry.addViewController("/").setViewName("index");
|
||||
registry.addViewController("/user/menu").setViewName("user/user-menu");
|
||||
registry.addViewController("/customer/menu").setViewName("customer/customer-menu");
|
||||
registry.addViewController("/contract/menu").setViewName("contract/contract-menu");
|
||||
registry.addViewController("/contract/search").setViewName("contract/search");
|
||||
registry.addViewController("/admin").setViewName("admin/panel");
|
||||
registry.addViewController("/search").setViewName("search");
|
||||
registry.addViewController("/403").setViewName("403");
|
||||
registry.addViewController("/logout").setViewName("logout");
|
||||
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
||||
configurer.favorPathExtension(true)
|
||||
.ignoreAcceptHeader(false)
|
||||
.defaultContentType(MediaType.APPLICATION_JSON)
|
||||
.useJaf(false);
|
||||
|
||||
final Map<String,MediaType> mediaTypes = new HashMap<>();
|
||||
mediaTypes.put("html", MediaType.TEXT_HTML);
|
||||
mediaTypes.put("json", MediaType.APPLICATION_JSON);
|
||||
mediaTypes.put("xls", MediaType.valueOf("application/vnd.ms-excel"));
|
||||
mediaTypes.put("pdf", MediaType.APPLICATION_PDF);
|
||||
mediaTypes.put("csv", new MediaType("text","csv", Charset.forName("utf-8")));
|
||||
configurer.mediaTypes(mediaTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure ContentNegotiatingViewResolver
|
||||
*/
|
||||
@Bean
|
||||
public ViewResolver contentNegotiatingViewResolver(ContentNegotiationManager manager) {
|
||||
ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
|
||||
resolver.setContentNegotiationManager(manager);
|
||||
|
||||
// Define all possible view resolvers
|
||||
List<ViewResolver> resolvers = new ArrayList<>();
|
||||
|
||||
resolvers.add(csvViewResolver());
|
||||
resolvers.add(excelViewResolver());
|
||||
resolvers.add(pdfViewResolver());
|
||||
resolvers.add(viewResolver());
|
||||
|
||||
resolver.setViewResolvers(resolvers);
|
||||
return resolver;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Description("Thymeleaf template resolver serving HTML 5")
|
||||
public ClassLoaderTemplateResolver templateResolver() {
|
||||
|
||||
ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
|
||||
|
||||
templateResolver.setPrefix("templates/");
|
||||
templateResolver.setCacheable(false);
|
||||
templateResolver.setSuffix(".html");
|
||||
templateResolver.setTemplateMode("HTML5");
|
||||
templateResolver.setCharacterEncoding("UTF-8");
|
||||
|
||||
return templateResolver;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Description("Thymeleaf template engine with Spring integration")
|
||||
public SpringTemplateEngine templateEngine() {
|
||||
|
||||
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
|
||||
templateEngine.setTemplateResolver(templateResolver());
|
||||
|
||||
// add dialect spring security
|
||||
templateEngine.addDialect(new SpringSecurityDialect());
|
||||
return templateEngine;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TemplateEngine templateEngine(ITemplateResolver templateResolver) {
|
||||
SpringTemplateEngine engine = new SpringTemplateEngine();
|
||||
engine.addDialect(new Java8TimeDialect());
|
||||
engine.setTemplateResolver(templateResolver);
|
||||
return engine;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Description("Thymeleaf view resolver")
|
||||
public ViewResolver viewResolver() {
|
||||
|
||||
ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
|
||||
|
||||
viewResolver.setTemplateEngine(templateEngine());
|
||||
viewResolver.setCharacterEncoding("UTF-8");
|
||||
|
||||
return viewResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure View resolver to provide XLS output using Apache POI library to
|
||||
* generate XLS output for an object content
|
||||
*/
|
||||
@Bean
|
||||
public ViewResolver excelViewResolver() {
|
||||
return new ExcelViewResolver();
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure View resolver to provide Csv output using Super Csv library to
|
||||
* generate Csv output for an object content
|
||||
*/
|
||||
@Bean
|
||||
public ViewResolver csvViewResolver() {
|
||||
return new CsvViewResolver();
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure View resolver to provide Pdf output using iText library to
|
||||
* generate pdf output for an object content
|
||||
*/
|
||||
@Bean
|
||||
public ViewResolver pdfViewResolver() {
|
||||
return new PdfViewResolver();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SpringDataDialect springDataDialect() {
|
||||
return new SpringDataDialect();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package crm.repository;
|
||||
|
||||
import crm.entity.Category;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CategoryRepository extends JpaRepository<Category, Long> {
|
||||
|
||||
Category findByName(String name);
|
||||
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package crm.repository;
|
||||
|
||||
import crm.entity.Contract;
|
||||
import crm.entity.Customer;
|
||||
import crm.entity.Status;
|
||||
import crm.entity.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Repository
|
||||
public interface ContractRepository extends JpaRepository<Contract, Long> {
|
||||
|
||||
Contract findByName(String contractName);
|
||||
|
||||
Iterable<Contract> findAllByValueLessThanEqual(BigDecimal value);
|
||||
|
||||
Iterable<Contract> findAllByValueGreaterThanEqual(BigDecimal value);
|
||||
|
||||
Iterable<Contract> findAllByBeginDate(LocalDate beginDate);
|
||||
|
||||
Iterable<Contract> findAllByBeginDateBefore(LocalDate beforeBeginDate);
|
||||
|
||||
Iterable<Contract> findAllByBeginDateAfter(LocalDate afterBeginDate);
|
||||
|
||||
Iterable<Contract> findAllByEndDate(LocalDate endDate);
|
||||
|
||||
Iterable<Contract> findAllByEndDateBefore(LocalDate beforeEndDate);
|
||||
|
||||
Iterable<Contract> findAllByEndDateAfter(LocalDate afterEndDate);
|
||||
|
||||
Iterable<Contract> findAllByStatus(Status status);
|
||||
|
||||
Iterable<Contract> findAllByCustomer(Customer customer);
|
||||
|
||||
Iterable<Contract> findAllByCustomerAndUser(Customer customer, User user);
|
||||
|
||||
Iterable<Contract> findAllByUser(User user);
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package crm.repository;
|
||||
|
||||
import crm.entity.Category;
|
||||
import crm.entity.Customer;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* NOTICE
|
||||
* <p>
|
||||
* When some declaration
|
||||
* does NOT HAVE Enabled param
|
||||
* searching works for ALL customers
|
||||
* also for NOT enabled (inactive) ones
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface CustomerRepository extends JpaRepository<Customer, Long> {
|
||||
|
||||
@Query(value = "select max(id) from crm.customer", nativeQuery = true)
|
||||
Long getMaxId();
|
||||
|
||||
Iterable<Customer> findAllByEnabled(int enabled);
|
||||
|
||||
Customer findOneByEnabledAndName(int enabled, String name);
|
||||
Customer findOneByName(String name);
|
||||
|
||||
Iterable<Customer> findByEnabledAndEmail(int enabled, String email);
|
||||
Iterable<Customer> findByEmail(String email);
|
||||
|
||||
Iterable<Customer> findByEnabledAndCity(int enabled, String city);
|
||||
Iterable<Customer> findByCity(String city);
|
||||
|
||||
Iterable<Customer> findByEnabledAndCityAndAddress(int enabled, String city, String address);
|
||||
Iterable<Customer> findByCityAndAddress(String city, String address);
|
||||
|
||||
Iterable<Customer> findByEnabledAndPhone(int enabled, int phone);
|
||||
Iterable<Customer> findByPhone(int phone);
|
||||
|
||||
Iterable<Customer> findByEnabledAndFirstName(int enabled, String firstName);
|
||||
Iterable<Customer> findByFirstName(String firstName);
|
||||
|
||||
Iterable<Customer> findByEnabledAndLastName(int enabled, String lastName);
|
||||
Iterable<Customer> findByLastName(String lastName);
|
||||
|
||||
Iterable<Customer> findByEnabledAndFirstNameAndLastName(int enabled, String firstName, String lastName);
|
||||
Iterable<Customer> findByFirstNameAndLastName(String firstName, String lastName);
|
||||
|
||||
Iterable<Customer> findByEnabledAndCategories(int enabled, Set<Category> category);
|
||||
Iterable<Customer> findByCategories(Set<Category> category);
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package crm.repository;
|
||||
|
||||
import crm.entity.Pdf;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PdfRepository extends JpaRepository<Pdf, Long> {
|
||||
|
||||
Pdf findByName(String name);
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package crm.repository;
|
||||
|
||||
import crm.entity.Role;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface RoleRepository extends JpaRepository<Role, Integer> {
|
||||
|
||||
Role findByName(String name);
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package crm.repository;
|
||||
|
||||
import crm.entity.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
|
||||
User findByUsername(String username);
|
||||
|
||||
Iterable<User> findAllByEnabled (int enabled);
|
||||
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package crm.service;
|
||||
|
||||
import crm.entity.Contract;
|
||||
import crm.entity.Customer;
|
||||
import crm.entity.Status;
|
||||
import crm.entity.User;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public interface ContractService {
|
||||
|
||||
Contract findByName(String contractName);
|
||||
|
||||
Iterable<Contract> listAllContracts();
|
||||
|
||||
Contract showContract(Long id);
|
||||
|
||||
Iterable<Contract> findAllByValueLessThanEqual(BigDecimal value);
|
||||
|
||||
Iterable<Contract> findAllByValueGreaterThanEqual(BigDecimal value);
|
||||
|
||||
Iterable<Contract> findAllByBeginDate(LocalDate beginDate);
|
||||
|
||||
Iterable<Contract> findAllByBeginDateBefore(LocalDate beforeBeginDate);
|
||||
|
||||
Iterable<Contract> findAllByBeginDateAfter(LocalDate afterBeginDate);
|
||||
|
||||
Iterable<Contract> findAllByEndDate(LocalDate endDate);
|
||||
|
||||
Iterable<Contract> findAllByEndDateBefore(LocalDate beforeEndDate);
|
||||
|
||||
Iterable<Contract> findAllByEndDateAfter(LocalDate afterEndDate);
|
||||
|
||||
Iterable<Contract> findAllByStatus(Status status);
|
||||
|
||||
Iterable<Contract> findAllByCustomer(Customer customer);
|
||||
|
||||
Iterable<Contract> findAllByCustomerAndUser(Customer customer, User user);
|
||||
|
||||
Iterable<Contract> findAllByUser(User user);
|
||||
|
||||
void saveContract(Contract contract);
|
||||
|
||||
}
|
||||
@ -0,0 +1,110 @@
|
||||
package crm.service;
|
||||
|
||||
import crm.entity.Contract;
|
||||
import crm.entity.Customer;
|
||||
import crm.entity.Status;
|
||||
import crm.entity.User;
|
||||
import crm.repository.ContractRepository;
|
||||
import crm.repository.CustomerRepository;
|
||||
import crm.repository.UserRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Service
|
||||
public class ContractServiceImpl implements ContractService {
|
||||
|
||||
private ContractRepository contractRepository;
|
||||
private CustomerRepository customerRepository;
|
||||
private UserRepository userRepository;
|
||||
|
||||
public ContractServiceImpl(ContractRepository contractRepository, CustomerRepository customerRepository, UserRepository userRepository) {
|
||||
this.contractRepository = contractRepository;
|
||||
this.customerRepository = customerRepository;
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Contract findByName(String contractName) {
|
||||
return contractRepository.findByName(contractName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Contract> listAllContracts() {
|
||||
return contractRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Contract showContract(Long id) {
|
||||
return contractRepository.findOne(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Contract> findAllByValueLessThanEqual(BigDecimal value) {
|
||||
return contractRepository.findAllByValueLessThanEqual(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Contract> findAllByValueGreaterThanEqual(BigDecimal value) {
|
||||
return contractRepository.findAllByValueGreaterThanEqual(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Contract> findAllByBeginDate(LocalDate beginDate) {
|
||||
return contractRepository.findAllByBeginDate(beginDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Contract> findAllByBeginDateBefore(LocalDate beforeBeginDate) {
|
||||
return contractRepository.findAllByBeginDateBefore(beforeBeginDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Contract> findAllByBeginDateAfter(LocalDate afterBeginDate) {
|
||||
return contractRepository.findAllByBeginDateAfter(afterBeginDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Contract> findAllByEndDate(LocalDate endDate) {
|
||||
return contractRepository.findAllByEndDate(endDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Contract> findAllByEndDateBefore(LocalDate beforeEndDate) {
|
||||
return contractRepository.findAllByEndDateBefore(beforeEndDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Contract> findAllByEndDateAfter(LocalDate afterEndDate) {
|
||||
return contractRepository.findAllByEndDateAfter(afterEndDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Contract> findAllByStatus(Status status) {
|
||||
return contractRepository.findAllByStatus(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Contract> findAllByCustomer(Customer customer) {
|
||||
return contractRepository.findAllByCustomer(customer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Contract> findAllByCustomerAndUser(Customer customer, User user) {
|
||||
return contractRepository.findAllByCustomerAndUser(customer, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Contract> findAllByUser(User user) {
|
||||
return contractRepository.findAllByUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveContract(Contract contract) {
|
||||
customerRepository.save(customerRepository.findAll());
|
||||
userRepository.save(userRepository.findAll());
|
||||
contractRepository.save(contract);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package crm.service;
|
||||
|
||||
import crm.entity.Category;
|
||||
import crm.entity.Customer;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* NOTICE
|
||||
* <p>
|
||||
* When some declaration
|
||||
* does NOT HAVE Enabled param
|
||||
* searching works for ALL customers
|
||||
* also for NOT enabled (inactive) ones
|
||||
*/
|
||||
|
||||
public interface CustomerService {
|
||||
|
||||
Long getMaxId();
|
||||
|
||||
Iterable<Customer> listAllCustomers();
|
||||
|
||||
Customer showCustomer(Long id);
|
||||
|
||||
Iterable<Customer> findAllByEnabledTrue();
|
||||
Iterable<Customer> findAllByEnabledFalse();
|
||||
|
||||
Customer findOneByEnabledTrueAndName(String name);
|
||||
Customer findOneByEnabledFalseAndName(String name);
|
||||
Customer findOneByName(String name);
|
||||
|
||||
Iterable<Customer> findByEnabledTrueAndEmail(String email);
|
||||
Iterable<Customer> findByEnabledFalseAndEmail(String email);
|
||||
Iterable<Customer> findByEmail(String email);
|
||||
|
||||
Iterable<Customer> findByEnabledTrueAndPhone(int phone);
|
||||
Iterable<Customer> findByEnabledFalseAndPhone(int phone);
|
||||
Iterable<Customer> findByPhone(int phone);
|
||||
|
||||
Iterable<Customer> findByEnabledTrueAndCategories(Set<Category> category);
|
||||
Iterable<Customer> findByEnabledFalseAndCategories(Set<Category> category);
|
||||
Iterable<Customer> findByCategories(Set<Category> category);
|
||||
|
||||
Iterable<Customer> findByEnabledTrueAndFirstName(String firstName);
|
||||
Iterable<Customer> findByEnabledFalseAndFirstName(String firstName);
|
||||
Iterable<Customer> findByFirstName(String firstName);
|
||||
|
||||
Iterable<Customer> findByEnabledTrueAndLastName(String lastName);
|
||||
Iterable<Customer> findByEnabledFalseAndLastName(String lastName);
|
||||
Iterable<Customer> findByLastName(String lastName);
|
||||
|
||||
Iterable<Customer> findByEnabledTrueAndFirstNameAndLastName(String firstName, String lastName);
|
||||
Iterable<Customer> findByEnabledFalseAndFirstNameAndLastName(String firstName, String lastName);
|
||||
Iterable<Customer> findByFirstNameAndLastName(String firstName, String lastName);
|
||||
|
||||
Iterable<Customer> findByEnabledTrueAndCity(String city);
|
||||
Iterable<Customer> findByEnabledFalseAndCity(String city);
|
||||
Iterable<Customer> findByCity(String city);
|
||||
|
||||
Iterable<Customer> findByEnabledTrueAndCityAndAddress(String city, String address);
|
||||
Iterable<Customer> findByEnabledFalseAndCityAndAddress(String city, String address);
|
||||
Iterable<Customer> findByCityAndAddress(String city, String address);
|
||||
|
||||
void saveCustomer(Customer customer);
|
||||
//
|
||||
// void editCustomer(Customer customer);
|
||||
//
|
||||
// void deleteCustomer(Customer customer);
|
||||
|
||||
}
|
||||
@ -0,0 +1,196 @@
|
||||
package crm.service;
|
||||
|
||||
import crm.entity.Category;
|
||||
import crm.entity.Customer;
|
||||
import crm.repository.CustomerRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
public class CustomerServiceImpl implements CustomerService {
|
||||
|
||||
private CustomerRepository customerRepository;
|
||||
|
||||
public CustomerServiceImpl(CustomerRepository customerRepository) {
|
||||
this.customerRepository = customerRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getMaxId() {
|
||||
return customerRepository.getMaxId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> listAllCustomers() {
|
||||
return customerRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Customer showCustomer(Long id) {
|
||||
return customerRepository.findOne(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findAllByEnabledTrue() {
|
||||
return customerRepository.findAllByEnabled(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findAllByEnabledFalse() {
|
||||
return customerRepository.findAllByEnabled(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Customer findOneByEnabledTrueAndName(String name) {
|
||||
return customerRepository.findOneByEnabledAndName(1, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Customer findOneByEnabledFalseAndName(String name) {
|
||||
return customerRepository.findOneByEnabledAndName(0, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Customer findOneByName(String name) {
|
||||
return customerRepository.findOneByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledTrueAndEmail(String email) {
|
||||
return customerRepository.findByEnabledAndEmail(1, email);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledFalseAndEmail(String email) {
|
||||
return customerRepository.findByEnabledAndEmail(0, email);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEmail(String email) {
|
||||
return customerRepository.findByEmail(email);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledTrueAndPhone(int phone) {
|
||||
return customerRepository.findByEnabledAndPhone(1, phone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledFalseAndPhone(int phone) {
|
||||
return customerRepository.findByEnabledAndPhone(0, phone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByPhone(int phone) {
|
||||
return customerRepository.findByPhone(phone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledTrueAndCategories(Set<Category> category) {
|
||||
return customerRepository.findByEnabledAndCategories(1, category);
|
||||
}
|
||||
//
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledFalseAndCategories(Set<Category> category) {
|
||||
return customerRepository.findByEnabledAndCategories(0, category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByCategories(Set<Category> category) {
|
||||
return customerRepository.findByCategories(category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledTrueAndFirstName(String firstName) {
|
||||
return customerRepository.findByEnabledAndFirstName(1, firstName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledFalseAndFirstName(String firstName) {
|
||||
return customerRepository.findByEnabledAndFirstName(0, firstName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByFirstName(String firstName) {
|
||||
return customerRepository.findByFirstName(firstName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledTrueAndLastName(String lastName) {
|
||||
return customerRepository.findByEnabledAndLastName(1, lastName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledFalseAndLastName(String lastName) {
|
||||
return customerRepository.findByEnabledAndLastName(0, lastName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByLastName(String lastName) {
|
||||
return customerRepository.findByLastName(lastName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledTrueAndFirstNameAndLastName(String firstName, String lastName) {
|
||||
return customerRepository.findByEnabledAndFirstNameAndLastName(1, firstName, lastName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledFalseAndFirstNameAndLastName(String firstName, String lastName) {
|
||||
return customerRepository.findByEnabledAndFirstNameAndLastName(0, firstName, lastName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByFirstNameAndLastName(String firstName, String lastName) {
|
||||
return customerRepository.findByFirstNameAndLastName(firstName, lastName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledTrueAndCity(String city) {
|
||||
return customerRepository.findByEnabledAndCity(1, city);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledFalseAndCity(String city) {
|
||||
return customerRepository.findByEnabledAndCity(0, city);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByCity(String city) {
|
||||
return customerRepository.findByCity(city);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledTrueAndCityAndAddress(String city, String address) {
|
||||
return customerRepository.findByEnabledAndCityAndAddress(1, city, address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByEnabledFalseAndCityAndAddress(String city, String address) {
|
||||
return customerRepository.findByEnabledAndCityAndAddress(0, city, address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findByCityAndAddress(String city, String address) {
|
||||
return customerRepository.findByCityAndAddress(city, address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveCustomer(Customer customer) {
|
||||
customer.setEnabled(1);
|
||||
customerRepository.save(customer);
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public void editCustomer(Customer customer) {
|
||||
// customerRepository.save(customer);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void deleteCustomer(Customer customer) {
|
||||
// customer.setEnabled(0);
|
||||
// customerRepository.save(customer);
|
||||
// }
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package crm.service;
|
||||
|
||||
import crm.entity.Pdf;
|
||||
|
||||
public interface PdfService {
|
||||
|
||||
Pdf findByName(String name);
|
||||
|
||||
void savePdf(Pdf pdf);
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package crm.service;
|
||||
|
||||
import crm.entity.Pdf;
|
||||
import crm.repository.PdfRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class PdfServiceImpl implements PdfService {
|
||||
|
||||
private PdfRepository pdfRepository;
|
||||
|
||||
public PdfServiceImpl(PdfRepository pdfRepository) {
|
||||
this.pdfRepository = pdfRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pdf findByName(String name) {
|
||||
return pdfRepository.findByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePdf(Pdf pdf) {
|
||||
pdfRepository.save(pdf);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package crm.service;
|
||||
|
||||
import crm.entity.Role;
|
||||
|
||||
public interface RoleService {
|
||||
|
||||
Iterable<Role> listAllRoles();
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package crm.service;
|
||||
|
||||
import crm.entity.Role;
|
||||
import crm.repository.RoleRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class RoleServiceImpl implements RoleService {
|
||||
|
||||
private RoleRepository roleRepository;
|
||||
|
||||
public RoleServiceImpl(RoleRepository roleRepository) {
|
||||
this.roleRepository = roleRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Role> listAllRoles() {
|
||||
return roleRepository.findAll();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package crm.service;
|
||||
|
||||
import crm.entity.CurrentUser;
|
||||
import crm.entity.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
public class SpringDataUserDetailsService implements UserDetailsService {
|
||||
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
User user = userService.findByUsername(username);
|
||||
if (user == null) {
|
||||
throw new UsernameNotFoundException(username);
|
||||
}
|
||||
String role = user.getRole().getName();
|
||||
Set<GrantedAuthority> grantedAuthorities = new HashSet<>();
|
||||
grantedAuthorities.add(new SimpleGrantedAuthority(role));
|
||||
CurrentUser currentUser = new CurrentUser();
|
||||
currentUser.setUser(user);
|
||||
currentUser.setAuthorities(grantedAuthorities);
|
||||
return currentUser;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package crm.service;
|
||||
|
||||
import crm.entity.User;
|
||||
|
||||
public interface UserService {
|
||||
|
||||
User findByUsername(String username);
|
||||
|
||||
Iterable<User> listAllUsers();
|
||||
|
||||
User showUser(Long id);
|
||||
|
||||
void saveUser(User user);
|
||||
|
||||
void editUser(User user);
|
||||
|
||||
void deleteUser(User user);
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue