├── .classpath ├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── .project ├── LICENSE ├── README.md ├── model_er.png ├── mvnw ├── mvnw.cmd ├── pom.xml ├── screenshots ├── screenshot01.png ├── screenshot02.png ├── screenshot03.png ├── screenshot04.png ├── screenshot05.png ├── screenshot06.png ├── screenshot07.png └── screenshot08.png ├── spring_course.sql └── src ├── main ├── java │ └── course │ │ ├── CrudbootApplication.java │ │ ├── WebSecurityConfig.java │ │ ├── controller │ │ ├── CourseController.java │ │ ├── IndexController.java │ │ ├── SignupController.java │ │ ├── StudentController.java │ │ └── UserController.java │ │ ├── entity │ │ ├── Course.java │ │ ├── Student.java │ │ └── User.java │ │ ├── repository │ │ ├── CourseRepository.java │ │ ├── StudentRepository.java │ │ └── UserRepository.java │ │ └── service │ │ ├── CourseServiceImpl.java │ │ ├── StudentServiceImpl.java │ │ └── UserServiceImpl.java └── resources │ ├── application.properties │ ├── static │ ├── css │ │ ├── bootstrap.min.css │ │ ├── font-awesome.min.css │ │ └── style.css │ └── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ └── fontawesome-webfont.woff2 │ └── templates │ ├── addStudentCourse.html │ ├── courseForm.html │ ├── courseShow.html │ ├── courses.html │ ├── error.html │ ├── fragments │ ├── header.html │ └── headerinc.html │ ├── index.html │ ├── login.html │ ├── signup.html │ ├── studentForm.html │ ├── studentShow.html │ ├── students.html │ ├── userForm.html │ ├── userShow.html │ └── users.html └── test └── java └── course └── CrudbootApplicationTests.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | local.properties 3 | .settings/ -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | crudboot 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Danilo Meneghel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Course 2 | 3 | Course registration project using Java Web with Spring Framework.
4 | Spring much lighter! :) 5 | 6 | ## Features 7 | 8 | - CRUD 9 | - ACL 10 | - Validation 11 | - Login 12 | - Responsive 13 | 14 | ## Requirements 15 | 16 | - NetBeans 8.2 17 | - Java JDK 1.8 18 | - Apache Tomcat >= 9 19 | - MySql >=5 20 | 21 | ## Tecnologies 22 | 23 | - Java 24 | - JPA 25 | - Maven 26 | - Spring 27 | - CSS 28 | - Bootstrap 29 | - MySql 30 | 31 | ## Installation 32 | 33 | ``` 34 | $ git clone https://github.com/danilomeneghel/spring-course.git 35 | 36 | $ cd spring-course 37 | 38 | ``` 39 | 40 | Then create a database with name spring_course in your mysql. You can find database dump in spring_course.sql, import it: 41 | 42 | ``` 43 | $ mysql -u -p 44 | 45 | mysql> create database `spring_course`; 46 | 47 | mysql> use `spring_course`; 48 | 49 | mysql> source spring_course.sql 50 | 51 | ``` 52 | 53 | Then open the file "src/main/resources/application.properties" and enter the data according to the connection of your database.
54 | 55 | When the configuration is complete, just type in the terminal "mvn spring-boot: run" and open in your browser the following address:
56 | 57 | http://localhost:8080/ 58 | 59 | ## Demonstration 60 | 61 | https://java-spring-course.herokuapp.com/
62 | 63 | - Login 64 | - Username: admin 65 | - Password: admin 66 | 67 | ## Licence 68 | 69 | User Registration is licensed under The MIT License (MIT). 70 | 71 | ## Screenshots 72 | 73 | ![Screenshots](screenshots/screenshot01.png)

74 | ![Screenshots](screenshots/screenshot02.png)

75 | ![Screenshots](screenshots/screenshot03.png)

76 | ![Screenshots](screenshots/screenshot04.png)

77 | ![Screenshots](screenshots/screenshot05.png)

78 | ![Screenshots](screenshots/screenshot06.png)

79 | ![Screenshots](screenshots/screenshot07.png)

80 | ![Screenshots](screenshots/screenshot08.png)

81 | 82 | ## Model ER 83 | 84 | ![Screenshots](model_er.png)

85 | 86 | 87 | Developed by
88 | Danilo Meneghel
89 | danilo.meneghel@gmail.com
90 | http://danilomeneghel.github.io/
91 | -------------------------------------------------------------------------------- /model_er.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/model_er.png -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # 58 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look 59 | # for the new JDKs provided by Oracle. 60 | # 61 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then 62 | # 63 | # Apple JDKs 64 | # 65 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home 66 | fi 67 | 68 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then 69 | # 70 | # Apple JDKs 71 | # 72 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 73 | fi 74 | 75 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then 76 | # 77 | # Oracle JDKs 78 | # 79 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 80 | fi 81 | 82 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then 83 | # 84 | # Apple JDKs 85 | # 86 | export JAVA_HOME=`/usr/libexec/java_home` 87 | fi 88 | ;; 89 | esac 90 | 91 | if [ -z "$JAVA_HOME" ] ; then 92 | if [ -r /etc/gentoo-release ] ; then 93 | JAVA_HOME=`java-config --jre-home` 94 | fi 95 | fi 96 | 97 | if [ -z "$M2_HOME" ] ; then 98 | ## resolve links - $0 may be a link to maven's home 99 | PRG="$0" 100 | 101 | # need this for relative symlinks 102 | while [ -h "$PRG" ] ; do 103 | ls=`ls -ld "$PRG"` 104 | link=`expr "$ls" : '.*-> \(.*\)$'` 105 | if expr "$link" : '/.*' > /dev/null; then 106 | PRG="$link" 107 | else 108 | PRG="`dirname "$PRG"`/$link" 109 | fi 110 | done 111 | 112 | saveddir=`pwd` 113 | 114 | M2_HOME=`dirname "$PRG"`/.. 115 | 116 | # make it fully qualified 117 | M2_HOME=`cd "$M2_HOME" && pwd` 118 | 119 | cd "$saveddir" 120 | # echo Using m2 at $M2_HOME 121 | fi 122 | 123 | # For Cygwin, ensure paths are in UNIX format before anything is touched 124 | if $cygwin ; then 125 | [ -n "$M2_HOME" ] && 126 | M2_HOME=`cygpath --unix "$M2_HOME"` 127 | [ -n "$JAVA_HOME" ] && 128 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 129 | [ -n "$CLASSPATH" ] && 130 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 131 | fi 132 | 133 | # For Migwn, ensure paths are in UNIX format before anything is touched 134 | if $mingw ; then 135 | [ -n "$M2_HOME" ] && 136 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 137 | [ -n "$JAVA_HOME" ] && 138 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 139 | # TODO classpath? 140 | fi 141 | 142 | if [ -z "$JAVA_HOME" ]; then 143 | javaExecutable="`which javac`" 144 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 145 | # readlink(1) is not available as standard on Solaris 10. 146 | readLink=`which readlink` 147 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 148 | if $darwin ; then 149 | javaHome="`dirname \"$javaExecutable\"`" 150 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 151 | else 152 | javaExecutable="`readlink -f \"$javaExecutable\"`" 153 | fi 154 | javaHome="`dirname \"$javaExecutable\"`" 155 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 156 | JAVA_HOME="$javaHome" 157 | export JAVA_HOME 158 | fi 159 | fi 160 | fi 161 | 162 | if [ -z "$JAVACMD" ] ; then 163 | if [ -n "$JAVA_HOME" ] ; then 164 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 165 | # IBM's JDK on AIX uses strange locations for the executables 166 | JAVACMD="$JAVA_HOME/jre/sh/java" 167 | else 168 | JAVACMD="$JAVA_HOME/bin/java" 169 | fi 170 | else 171 | JAVACMD="`which java`" 172 | fi 173 | fi 174 | 175 | if [ ! -x "$JAVACMD" ] ; then 176 | echo "Error: JAVA_HOME is not defined correctly." >&2 177 | echo " We cannot execute $JAVACMD" >&2 178 | exit 1 179 | fi 180 | 181 | if [ -z "$JAVA_HOME" ] ; then 182 | echo "Warning: JAVA_HOME environment variable is not set." 183 | fi 184 | 185 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 186 | 187 | # For Cygwin, switch paths to Windows format before running java 188 | if $cygwin; then 189 | [ -n "$M2_HOME" ] && 190 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 191 | [ -n "$JAVA_HOME" ] && 192 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 193 | [ -n "$CLASSPATH" ] && 194 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 195 | fi 196 | 197 | # traverses directory structure from process work directory to filesystem root 198 | # first directory with .mvn subdirectory is considered project base directory 199 | find_maven_basedir() { 200 | local basedir=$(pwd) 201 | local wdir=$(pwd) 202 | while [ "$wdir" != '/' ] ; do 203 | if [ -d "$wdir"/.mvn ] ; then 204 | basedir=$wdir 205 | break 206 | fi 207 | wdir=$(cd "$wdir/.."; pwd) 208 | done 209 | echo "${basedir}" 210 | } 211 | 212 | # concatenates all lines of a file 213 | concat_lines() { 214 | if [ -f "$1" ]; then 215 | echo "$(tr -s '\n' ' ' < "$1")" 216 | fi 217 | } 218 | 219 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} 220 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 221 | 222 | # Provide a "standardized" way to retrieve the CLI args that will 223 | # work with both Windows and non-Windows executions. 224 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 225 | export MAVEN_CMD_LINE_ARGS 226 | 227 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 228 | 229 | exec "$JAVACMD" \ 230 | $MAVEN_OPTS \ 231 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 232 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 233 | ${WRAPPER_LAUNCHER} "$@" 234 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | set MAVEN_CMD_LINE_ARGS=%* 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | 121 | set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" 122 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 123 | 124 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% 125 | if ERRORLEVEL 1 goto error 126 | goto end 127 | 128 | :error 129 | set ERROR_CODE=1 130 | 131 | :end 132 | @endlocal & set ERROR_CODE=%ERROR_CODE% 133 | 134 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 135 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 136 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 137 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 138 | :skipRcPost 139 | 140 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 141 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 142 | 143 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 144 | 145 | exit /B %ERROR_CODE% -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | course 7 | spring-course 8 | 1.0 9 | jar 10 | 11 | spring-course 12 | Project with Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.0.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | 1.8 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-thymeleaf 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-validation 40 | 41 | 42 | 43 | mysql 44 | mysql-connector-java 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-test 50 | test 51 | 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-starter-data-jpa 56 | 57 | 58 | 59 | com.h2database 60 | h2 61 | 62 | 63 | 64 | org.springframework.boot 65 | spring-boot-starter-security 66 | 67 | 68 | 69 | org.springframework.boot 70 | spring-boot-devtools 71 | 72 | 73 | 74 | org.assertj 75 | assertj-core 76 | 3.5.2 77 | 78 | 79 | 80 | org.thymeleaf.extras 81 | thymeleaf-extras-springsecurity4 82 | 83 | 84 | 85 | 86 | 87 | 88 | org.springframework.boot 89 | spring-boot-maven-plugin 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /screenshots/screenshot01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/screenshots/screenshot01.png -------------------------------------------------------------------------------- /screenshots/screenshot02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/screenshots/screenshot02.png -------------------------------------------------------------------------------- /screenshots/screenshot03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/screenshots/screenshot03.png -------------------------------------------------------------------------------- /screenshots/screenshot04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/screenshots/screenshot04.png -------------------------------------------------------------------------------- /screenshots/screenshot05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/screenshots/screenshot05.png -------------------------------------------------------------------------------- /screenshots/screenshot06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/screenshots/screenshot06.png -------------------------------------------------------------------------------- /screenshots/screenshot07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/screenshots/screenshot07.png -------------------------------------------------------------------------------- /screenshots/screenshot08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/screenshots/screenshot08.png -------------------------------------------------------------------------------- /spring_course.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 4.7.9 3 | -- https://www.phpmyadmin.net/ 4 | -- 5 | -- Host: 127.0.0.1:3306 6 | -- Generation Time: 12-Nov-2018 às 03:16 7 | -- Versão do servidor: 5.7.21 8 | -- PHP Version: 7.2.4 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | SET AUTOCOMMIT = 0; 12 | START TRANSACTION; 13 | SET time_zone = "+00:00"; 14 | 15 | 16 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 17 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 18 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 19 | /*!40101 SET NAMES utf8mb4 */; 20 | 21 | -- 22 | -- Database: `spring_course` 23 | -- 24 | 25 | -- -------------------------------------------------------- 26 | 27 | -- 28 | -- Estrutura da tabela `course` 29 | -- 30 | 31 | DROP TABLE IF EXISTS `course`; 32 | CREATE TABLE IF NOT EXISTS `course` ( 33 | `courseid` bigint(20) NOT NULL AUTO_INCREMENT, 34 | `coursename` varchar(255) DEFAULT NULL, 35 | PRIMARY KEY (`courseid`) 36 | ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=latin1; 37 | 38 | -- 39 | -- Extraindo dados da tabela `course` 40 | -- 41 | 42 | INSERT INTO `course` (`courseid`, `coursename`) VALUES 43 | (1, 'Programming Logic'), 44 | (2, 'Programming'), 45 | (3, 'Data Structure'), 46 | (4, 'Database'), 47 | (5, 'Software Engineering'), 48 | (6, 'People Management'); 49 | 50 | -- -------------------------------------------------------- 51 | 52 | -- 53 | -- Estrutura da tabela `student` 54 | -- 55 | 56 | DROP TABLE IF EXISTS `student`; 57 | CREATE TABLE IF NOT EXISTS `student` ( 58 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 59 | `department` varchar(255) DEFAULT NULL, 60 | `email` varchar(255) DEFAULT NULL, 61 | `firstname` varchar(255) DEFAULT NULL, 62 | `lastname` varchar(255) DEFAULT NULL, 63 | PRIMARY KEY (`id`) 64 | ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1; 65 | 66 | -- 67 | -- Extraindo dados da tabela `student` 68 | -- 69 | 70 | INSERT INTO `student` (`id`, `department`, `email`, `firstname`, `lastname`) VALUES 71 | (1, 'TI', 'john@mayer.com', 'John', 'Mayer'), 72 | (2, 'RH', 'mary@jane.com', 'Mary', 'Jane'), 73 | (3, 'TI', 'stephany@alba.com', 'Stephany', 'Alba'); 74 | 75 | -- -------------------------------------------------------- 76 | 77 | -- 78 | -- Estrutura da tabela `student_course` 79 | -- 80 | 81 | DROP TABLE IF EXISTS `student_course`; 82 | CREATE TABLE IF NOT EXISTS `student_course` ( 83 | `id` bigint(20) NOT NULL, 84 | `courseid` bigint(20) NOT NULL, 85 | PRIMARY KEY (`id`,`courseid`), 86 | KEY `courseid` (`courseid`) 87 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 88 | 89 | -- 90 | -- Extraindo dados da tabela `student_course` 91 | -- 92 | 93 | INSERT INTO `student_course` (`id`, `courseid`) VALUES 94 | (1, 1), 95 | (2, 1), 96 | (3, 1), 97 | (1, 2), 98 | (1, 3), 99 | (2, 3), 100 | (3, 6); 101 | 102 | -- -------------------------------------------------------- 103 | 104 | -- 105 | -- Estrutura da tabela `user` 106 | -- 107 | 108 | DROP TABLE IF EXISTS `user`; 109 | CREATE TABLE IF NOT EXISTS `user` ( 110 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 111 | `password` varchar(255) NOT NULL, 112 | `role` varchar(255) NOT NULL, 113 | `username` varchar(255) NOT NULL, 114 | PRIMARY KEY (`id`), 115 | UNIQUE KEY `UK_sb8bbouer5wak8vyiiy4pf2bx` (`username`) 116 | ) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=latin1; 117 | 118 | -- 119 | -- Extraindo dados da tabela `user` 120 | -- 121 | 122 | INSERT INTO `user` (`id`, `password`, `role`, `username`) VALUES 123 | (1, '$2a$06$3jYRJrg0ghaaypjZ/.g4SethoeA51ph3UD4kZi9oPkeMTpjKU5uo6', 'USER', 'user'), 124 | (2, '$2a$08$bCCcGjB03eulCWt3CY0AZew2rVzXFyouUolL5dkL/pBgFkUH9O4J2', 'ADMIN', 'admin'); 125 | 126 | -- 127 | -- Constraints for dumped tables 128 | -- 129 | 130 | -- 131 | -- Limitadores para a tabela `student_course` 132 | -- 133 | ALTER TABLE `student_course` 134 | ADD CONSTRAINT `student_course_ibfk_1` FOREIGN KEY (`courseid`) REFERENCES `course` (`courseid`) ON DELETE CASCADE ON UPDATE CASCADE, 135 | ADD CONSTRAINT `student_course_ibfk_2` FOREIGN KEY (`id`) REFERENCES `student` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; 136 | COMMIT; 137 | 138 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 139 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 140 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 141 | -------------------------------------------------------------------------------- /src/main/java/course/CrudbootApplication.java: -------------------------------------------------------------------------------- 1 | package course; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | 9 | @SpringBootApplication 10 | public class CrudbootApplication { 11 | 12 | private static final Logger log = LoggerFactory.getLogger(CrudbootApplication.class); 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(CrudbootApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/course/WebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package course; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 7 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 8 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 9 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 10 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 11 | 12 | import course.service.UserServiceImpl; 13 | 14 | @Configuration 15 | @EnableWebSecurity 16 | @ComponentScan("course") 17 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 18 | 19 | @Autowired 20 | private UserServiceImpl userDetailsService; 21 | 22 | @Override 23 | protected void configure(HttpSecurity http) throws Exception { 24 | http 25 | .authorizeRequests().antMatchers("/css/**", "/fonts/**", "/signup", "/saveSignup").permitAll() // Enable css when logged out 26 | .and() 27 | .authorizeRequests() 28 | .anyRequest().authenticated() 29 | .and() 30 | .formLogin() 31 | .loginPage("/login") 32 | .defaultSuccessUrl("/") 33 | .permitAll() 34 | .and() 35 | .logout() 36 | .permitAll() 37 | .and(); 38 | } 39 | 40 | @Autowired 41 | public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { 42 | auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/course/controller/CourseController.java: -------------------------------------------------------------------------------- 1 | package course.controller; 2 | 3 | import java.util.List; 4 | import javax.validation.Valid; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.validation.BindingResult; 13 | import org.springframework.web.bind.annotation.ModelAttribute; 14 | 15 | import course.entity.Course; 16 | import course.service.CourseServiceImpl; 17 | import org.springframework.web.bind.annotation.RequestParam; 18 | 19 | @Controller 20 | public class CourseController { 21 | 22 | @Autowired 23 | private CourseServiceImpl courseService; 24 | 25 | @RequestMapping("courses") 26 | public String index(Model model) { 27 | List courses = (List) courseService.findAllByOrderByNameAsc(); 28 | model.addAttribute("courses", courses); 29 | return "courses"; 30 | } 31 | 32 | @RequestMapping(value = "course/new") 33 | public String newCourse(Model model) { 34 | model.addAttribute("course", new Course()); 35 | model.addAttribute("title", "Add Course"); 36 | return "courseForm"; 37 | } 38 | 39 | @RequestMapping(value = "course/edit/{id}") 40 | public String editCourse(@PathVariable("id") Long courseId, Model model) { 41 | model.addAttribute("course", courseService.findCourseById(courseId)); 42 | model.addAttribute("title", "Edit Course"); 43 | return "courseForm"; 44 | } 45 | 46 | @RequestMapping("course/{id}") 47 | public String showCourse(@PathVariable("id") Long courseId, Model model) { 48 | model.addAttribute("course", courseService.findCourseById(courseId)); 49 | model.addAttribute("title", "Show Course"); 50 | return "courseShow"; 51 | } 52 | 53 | @RequestMapping(value = "saveCourse", method = RequestMethod.POST) 54 | public String saveCourse(@Valid @ModelAttribute("course") Course course, BindingResult bindingResult, @RequestParam("courseid") Long courseId, Model model) { 55 | if (!bindingResult.hasErrors()) { 56 | courseService.saveCourse(course); 57 | } else { 58 | String title = (courseId == null) ? "Add Course" : "Edit Course"; 59 | model.addAttribute("title", title); 60 | return "courseForm"; 61 | } 62 | return "redirect:/courses"; 63 | } 64 | 65 | @RequestMapping(value = "course/delete/{id}", method = RequestMethod.GET) 66 | public String deleteCourse(@PathVariable("id") Long courseId, Model model) { 67 | courseService.deleteCourseById(courseId); 68 | return "redirect:/courses"; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/course/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package course.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | @Controller 7 | public class IndexController { 8 | 9 | @RequestMapping("/") 10 | public String index() { 11 | return "index"; 12 | } 13 | 14 | @RequestMapping("/login") 15 | public String login() { 16 | return "login"; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/course/controller/SignupController.java: -------------------------------------------------------------------------------- 1 | package course.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.validation.BindingResult; 8 | import org.springframework.web.bind.annotation.ModelAttribute; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import org.springframework.web.servlet.mvc.support.RedirectAttributes; 12 | 13 | import javax.validation.Valid; 14 | 15 | import course.entity.User; 16 | import course.service.UserServiceImpl; 17 | 18 | @Controller 19 | public class SignupController { 20 | 21 | @Autowired 22 | private UserServiceImpl userService; 23 | 24 | @RequestMapping(value = "signup") 25 | public String signup(Model model) { 26 | model.addAttribute("signup", new User()); 27 | return "signup"; 28 | } 29 | 30 | @RequestMapping(value = "saveSignup", method = RequestMethod.POST) 31 | public String saveSignup(@Valid @ModelAttribute("signup") User user, BindingResult bindingResult, RedirectAttributes redirAttrs) { 32 | if (!bindingResult.hasErrors()) { // validation errors 33 | if (user.getPassword().equals(user.getPasswordCheck())) { // check password match 34 | if (userService.findByUsername(user.getUsername()) == null) { // validate username 35 | // encrypt password 36 | userService.encryptPassword(user); 37 | user.setRole("USER"); 38 | userService.saveUser(user); 39 | redirAttrs.addFlashAttribute("message", "User registered successfully!"); 40 | return "redirect:/login"; 41 | } else { 42 | bindingResult.rejectValue("username", "error.userexists", "Username already exists"); 43 | } 44 | } else { 45 | bindingResult.rejectValue("passwordCheck", "error.pwdmatch", "Passwords does not match"); 46 | } 47 | } 48 | return "signup"; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/course/controller/StudentController.java: -------------------------------------------------------------------------------- 1 | package course.controller; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import org.springframework.web.bind.annotation.RequestParam; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | import course.entity.Student; 15 | import course.entity.Course; 16 | import course.service.StudentServiceImpl; 17 | import course.service.CourseServiceImpl; 18 | import javax.validation.Valid; 19 | import org.springframework.validation.BindingResult; 20 | import org.springframework.web.bind.annotation.ModelAttribute; 21 | 22 | @Controller 23 | public class StudentController { 24 | 25 | @Autowired 26 | private StudentServiceImpl studentService; 27 | 28 | @Autowired 29 | private CourseServiceImpl courseService; 30 | 31 | @RequestMapping("students") 32 | public String index(Model model) { 33 | List students = (List) studentService.findAllByOrderByFirstNameAsc(); 34 | model.addAttribute("students", students); 35 | return "students"; 36 | } 37 | 38 | @RequestMapping(value = "student/new") 39 | public String newStudent(Model model) { 40 | model.addAttribute("student", new Student()); 41 | model.addAttribute("title", "Add Student"); 42 | return "studentForm"; 43 | } 44 | 45 | @RequestMapping(value = "student/edit/{id}") 46 | public String editStudent(@PathVariable("id") Long studentId, Model model) { 47 | model.addAttribute("student", studentService.findStudentById(studentId)); 48 | model.addAttribute("title", "Edit Student"); 49 | return "studentForm"; 50 | } 51 | 52 | @RequestMapping("student/{id}") 53 | public String showStudent(@PathVariable("id") Long studentId, Model model) { 54 | model.addAttribute("student", studentService.findStudentById(studentId)); 55 | model.addAttribute("title", "Show Student"); 56 | return "studentShow"; 57 | } 58 | 59 | @RequestMapping(value = "saveStudent", method = RequestMethod.POST) 60 | public String saveStudent(@Valid @ModelAttribute("student") Student student, BindingResult bindingResult, @RequestParam("id") Long studentId, Model model) { 61 | if (!bindingResult.hasErrors()) { 62 | studentService.saveStudent(student); 63 | } else { 64 | String title = (studentId == null) ? "Add Student" : "Edit Student"; 65 | model.addAttribute("title", title); 66 | return "studentForm"; 67 | } 68 | return "redirect:/students"; 69 | } 70 | 71 | @RequestMapping(value = "student/delete/{id}", method = RequestMethod.GET) 72 | public String deleteStudent(@PathVariable("id") Long studentId, Model model) { 73 | studentService.deleteStudentById(studentId); 74 | return "redirect:/students"; 75 | } 76 | 77 | @RequestMapping(value = "addStudentCourse/{id}", method = RequestMethod.GET) 78 | public String addStudentCourse(@PathVariable("id") Long studentId, Model model) { 79 | model.addAttribute("student", studentService.findStudentById(studentId)); 80 | model.addAttribute("courses", courseService.findAllCourses()); 81 | return "addStudentCourse"; 82 | } 83 | 84 | @RequestMapping(value = "student/{id}/courses", method = RequestMethod.GET) 85 | public String studentsAddCourse(@RequestParam(value = "action", required = true) String action, @PathVariable Long id, @RequestParam Long courseId, Model model) { 86 | Student student = studentService.findStudentById(id); 87 | Course course = courseService.findCourseById(courseId); 88 | 89 | if (!student.hasCourse(course)) { 90 | student.getCourses().add(course); 91 | } 92 | studentService.saveStudent(student); 93 | model.addAttribute("student", studentService.findStudentById(id)); 94 | model.addAttribute("courses", courseService.findAllCourses()); 95 | return "redirect:/students"; 96 | } 97 | 98 | @RequestMapping(value = "getstudents", method = RequestMethod.GET) 99 | public @ResponseBody 100 | List getStudents() { 101 | return (List) studentService.findAllStudents(); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/course/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package course.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.Model; 6 | import org.springframework.validation.BindingResult; 7 | import org.springframework.web.bind.annotation.ModelAttribute; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestParam; 12 | 13 | import javax.validation.Valid; 14 | import java.util.List; 15 | 16 | import course.entity.User; 17 | import course.service.UserServiceImpl; 18 | 19 | @Controller 20 | public class UserController { 21 | 22 | @Autowired 23 | private UserServiceImpl userService; 24 | 25 | @RequestMapping(value = "saveUser", method = RequestMethod.POST) 26 | public String saveUser(@Valid @ModelAttribute("user") User user, BindingResult bindingResult, @RequestParam(value = "id", required = false) Long userId, Model model) { 27 | if (!bindingResult.hasErrors()) { // validation errors 28 | if (user.getPassword() != null) { 29 | // encrypt password 30 | userService.encryptPassword(user); 31 | } 32 | if (userId == null) { // check if new user 33 | if (userService.findByUsername(user.getUsername()) == null) { // validate username 34 | userService.saveUser(user); 35 | } else { 36 | bindingResult.rejectValue("username", "error.userexists", "Username already exists"); 37 | } 38 | } else { 39 | userService.saveUser(user); 40 | } 41 | } else { 42 | String title = (userId == null) ? "Add User" : "Edit User"; 43 | model.addAttribute("title", title); 44 | return "userForm"; 45 | } 46 | return "redirect:/users"; 47 | } 48 | 49 | @RequestMapping("users") 50 | public String index(Model model) { 51 | List users = (List) userService.findAllByOrderByUsernameAsc(); 52 | model.addAttribute("users", users); 53 | return "users"; 54 | } 55 | 56 | @RequestMapping(value = "user/new") 57 | public String newUser(Model model) { 58 | model.addAttribute("user", new User()); 59 | model.addAttribute("title", "Add User"); 60 | return "userForm"; 61 | } 62 | 63 | @RequestMapping(value = "user/edit/{id}") 64 | public String editUser(@PathVariable("id") Long userId, Model model) { 65 | model.addAttribute("user", userService.findUserById(userId)); 66 | model.addAttribute("title", "Edit User"); 67 | return "userForm"; 68 | } 69 | 70 | @RequestMapping("user/{id}") 71 | public String showUser(@PathVariable("id") Long userId, Model model) { 72 | model.addAttribute("user", userService.findUserById(userId)); 73 | model.addAttribute("title", "Show User"); 74 | return "userShow"; 75 | } 76 | 77 | @RequestMapping(value = "user/delete/{id}", method = RequestMethod.GET) 78 | public String deleteUser(@PathVariable("id") Long userId, Model model) { 79 | userService.deleteUserById(userId); 80 | return "redirect:/users"; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/course/entity/Course.java: -------------------------------------------------------------------------------- 1 | package course.entity; 2 | 3 | import java.util.Set; 4 | 5 | import javax.persistence.*; 6 | import javax.validation.constraints.Size; 7 | 8 | @Entity 9 | public class Course { 10 | 11 | @Id 12 | @GeneratedValue(strategy = GenerationType.IDENTITY) 13 | @Column(name = "courseid") 14 | private Long courseid; 15 | 16 | @Size(min = 3, message = "Course is invalid") 17 | @Column(name = "coursename") 18 | private String name; 19 | 20 | @ManyToMany(mappedBy = "courses") 21 | private Set students; 22 | 23 | public Course() { 24 | } 25 | 26 | public Course(String name) { 27 | this.name = name; 28 | } 29 | 30 | public Long getCourseid() { 31 | return courseid; 32 | } 33 | 34 | public void setCourseid(Long courseid) { 35 | this.courseid = courseid; 36 | } 37 | 38 | public String getName() { 39 | return name; 40 | } 41 | 42 | public void setName(String name) { 43 | this.name = name; 44 | } 45 | 46 | public Set getStudents() { 47 | return students; 48 | } 49 | 50 | public void setStudents(Set students) { 51 | this.students = students; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/course/entity/Student.java: -------------------------------------------------------------------------------- 1 | package course.entity; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import javax.persistence.*; 7 | import javax.validation.constraints.Email; 8 | import javax.validation.constraints.Size; 9 | import org.hibernate.validator.constraints.NotEmpty; 10 | 11 | @Entity 12 | public class Student { 13 | 14 | private Long id; 15 | 16 | @Size(min = 3, message = "Firstname is invalid") 17 | private String firstName; 18 | 19 | @Size(min = 3, message = "Lastname is invalid") 20 | private String lastName; 21 | 22 | @Size(min = 2, message = "Department is invalid") 23 | private String department; 24 | 25 | @NotEmpty 26 | @Email 27 | private String email; 28 | 29 | private Set courses = new HashSet(0); 30 | 31 | public Student() { 32 | } 33 | 34 | public Student(String firstName, String lastName, String department, String email) { 35 | super(); 36 | this.firstName = firstName; 37 | this.lastName = lastName; 38 | this.department = department; 39 | this.email = email; 40 | } 41 | 42 | @Id 43 | @GeneratedValue(strategy = GenerationType.IDENTITY) 44 | public Long getId() { 45 | return id; 46 | } 47 | 48 | public void setId(Long id) { 49 | this.id = id; 50 | } 51 | 52 | @Column(name = "firstname") 53 | public String getFirstName() { 54 | return firstName; 55 | } 56 | 57 | public void setFirstName(String firstName) { 58 | this.firstName = firstName; 59 | } 60 | 61 | @Column(name = "lastname") 62 | public String getLastName() { 63 | return lastName; 64 | } 65 | 66 | public void setLastName(String lastName) { 67 | this.lastName = lastName; 68 | } 69 | 70 | @Column(name = "department") 71 | public String getDepartment() { 72 | return department; 73 | } 74 | 75 | public void setDepartment(String department) { 76 | this.department = department; 77 | } 78 | 79 | @Column(name = "email") 80 | public String getEmail() { 81 | return email; 82 | } 83 | 84 | public void setEmail(String email) { 85 | this.email = email; 86 | } 87 | 88 | @ManyToMany(cascade = CascadeType.MERGE) 89 | @JoinTable(name = "student_course", joinColumns = { 90 | @JoinColumn(name = "id")}, inverseJoinColumns = { 91 | @JoinColumn(name = "courseid") 92 | }) 93 | public Set getCourses() { 94 | return this.courses; 95 | } 96 | 97 | public void setCourses(Set courses) { 98 | this.courses = courses; 99 | } 100 | 101 | public boolean hasCourse(Course course) { 102 | for (Course studentCourse : getCourses()) { 103 | if (studentCourse.getCourseid() == course.getCourseid()) { 104 | return true; 105 | } 106 | } 107 | return false; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/main/java/course/entity/User.java: -------------------------------------------------------------------------------- 1 | package course.entity; 2 | 3 | import javax.validation.constraints.Size; 4 | import javax.persistence.*; 5 | 6 | @Entity 7 | public class User { 8 | 9 | @Id 10 | @GeneratedValue(strategy = GenerationType.IDENTITY) 11 | @Column(name = "id") 12 | private Long id; 13 | 14 | @Size(min = 3, message = "Username is invalid") 15 | @Column(name = "username", nullable = false) 16 | private String username; 17 | 18 | @Size(min = 4, message = "Password is invalid") 19 | @Column(name = "password", nullable = false) 20 | private String password; 21 | 22 | @Transient 23 | @Column(nullable = false, updatable = false) 24 | private String passwordCheck; 25 | 26 | @Column(name = "role") 27 | private String role; 28 | 29 | public User() { 30 | } 31 | 32 | public User(String username, String password, String role) { 33 | super(); 34 | this.username = username; 35 | this.password = password; 36 | this.role = role; 37 | } 38 | 39 | public Long getId() { 40 | return id; 41 | } 42 | 43 | public void setId(Long id) { 44 | this.id = id; 45 | } 46 | 47 | public String getUsername() { 48 | return username; 49 | } 50 | 51 | public void setUsername(String username) { 52 | this.username = username; 53 | } 54 | 55 | public String getPassword() { 56 | return password; 57 | } 58 | 59 | public void setPassword(String password) { 60 | this.password = password; 61 | } 62 | 63 | public String getPasswordCheck() { 64 | return passwordCheck; 65 | } 66 | 67 | public void setPasswordCheck(String passwordCheck) { 68 | this.passwordCheck = passwordCheck; 69 | } 70 | 71 | public String getRole() { 72 | return role; 73 | } 74 | 75 | public void setRole(String role) { 76 | this.role = role; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/course/repository/CourseRepository.java: -------------------------------------------------------------------------------- 1 | package course.repository; 2 | 3 | import course.entity.Course; 4 | import java.util.List; 5 | 6 | import org.springframework.data.repository.CrudRepository; 7 | 8 | public interface CourseRepository extends CrudRepository { 9 | 10 | Course findByName(String name); 11 | List findAllByOrderByNameAsc(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/course/repository/StudentRepository.java: -------------------------------------------------------------------------------- 1 | package course.repository; 2 | 3 | import course.entity.Student; 4 | import java.util.List; 5 | 6 | import org.springframework.data.repository.CrudRepository; 7 | 8 | public interface StudentRepository extends CrudRepository { 9 | 10 | Student findByFirstName(String firstName); 11 | List findAllByOrderByFirstNameAsc(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/course/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package course.repository; 2 | 3 | import course.entity.User; 4 | import java.util.List; 5 | import org.springframework.data.repository.CrudRepository; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | public interface UserRepository extends CrudRepository { 10 | 11 | User findByUsername(String username); 12 | List findAllByOrderByUsernameAsc(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/course/service/CourseServiceImpl.java: -------------------------------------------------------------------------------- 1 | package course.service; 2 | 3 | import course.entity.Course; 4 | import course.repository.CourseRepository; 5 | 6 | import java.util.List; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | @Service 12 | public class CourseServiceImpl { 13 | 14 | @Autowired 15 | private final CourseRepository repository; 16 | 17 | @Autowired 18 | public CourseServiceImpl(CourseRepository repository) { 19 | this.repository = repository; 20 | } 21 | 22 | public Course findCourseById(Long courseid) { 23 | return repository.findById(courseid).orElse(new Course()); 24 | } 25 | 26 | public List findAllByOrderByNameAsc() { 27 | return repository.findAllByOrderByNameAsc(); 28 | } 29 | 30 | public void saveCourse(Course course) { 31 | repository.save(course); 32 | } 33 | 34 | public void updateCourse(Course course) { 35 | repository.save(course); 36 | } 37 | 38 | public void deleteCourseById(Long id) { 39 | repository.deleteById(id); 40 | } 41 | 42 | public void deleteAllCourses() { 43 | repository.deleteAll(); 44 | } 45 | 46 | public List findAllCourses() { 47 | return (List) repository.findAll(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/course/service/StudentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package course.service; 2 | 3 | import course.entity.Student; 4 | import course.repository.StudentRepository; 5 | 6 | import java.util.List; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | @Service 12 | public class StudentServiceImpl { 13 | 14 | @Autowired 15 | private final StudentRepository repository; 16 | 17 | @Autowired 18 | public StudentServiceImpl(StudentRepository repository) { 19 | this.repository = repository; 20 | } 21 | 22 | public Student findStudentById(Long id) { 23 | return repository.findById(id).orElse(new Student()); 24 | } 25 | 26 | public List findAllByOrderByFirstNameAsc() { 27 | return repository.findAllByOrderByFirstNameAsc(); 28 | } 29 | 30 | public void saveStudent(Student student) { 31 | repository.save(student); 32 | } 33 | 34 | public void updateStudent(Student student) { 35 | repository.save(student); 36 | } 37 | 38 | public void deleteStudentById(Long id) { 39 | repository.deleteById(id); 40 | } 41 | 42 | public void deleteAllStudents() { 43 | repository.deleteAll(); 44 | } 45 | 46 | public List findAllStudents() { 47 | return (List) repository.findAll(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/course/service/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package course.service; 2 | 3 | import course.entity.User; 4 | import course.repository.UserRepository; 5 | 6 | import java.util.List; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.security.core.authority.AuthorityUtils; 10 | import org.springframework.security.core.userdetails.UserDetails; 11 | import org.springframework.security.core.userdetails.UserDetailsService; 12 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 13 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 14 | import org.springframework.stereotype.Service; 15 | 16 | /** 17 | * This class is used by spring controller to authenticate and authorize user 18 | * 19 | */ 20 | @Service 21 | public class UserServiceImpl implements UserDetailsService { 22 | 23 | @Autowired 24 | private final UserRepository repository; 25 | 26 | @Autowired 27 | public UserServiceImpl(UserRepository repository) { 28 | this.repository = repository; 29 | } 30 | 31 | public User findUserById(Long id) { 32 | return repository.findById(id).orElse(new User()); 33 | } 34 | 35 | public List findAllByOrderByUsernameAsc() { 36 | return repository.findAllByOrderByUsernameAsc(); 37 | } 38 | 39 | public User findByUsername(String username) { 40 | return repository.findByUsername(username); 41 | } 42 | 43 | public void saveUser(User user) { 44 | repository.save(user); 45 | } 46 | 47 | public void updateUser(User user) { 48 | repository.save(user); 49 | } 50 | 51 | public void deleteUserById(Long id) { 52 | repository.deleteById(id); 53 | } 54 | 55 | public void deleteAllUsers() { 56 | repository.deleteAll(); 57 | } 58 | 59 | public List findAllUsers() { 60 | return (List) repository.findAll(); 61 | } 62 | 63 | public User encryptPassword(User user) { 64 | String pwd = user.getPassword(); 65 | BCryptPasswordEncoder bc = new BCryptPasswordEncoder(); 66 | String hashPwd = bc.encode(pwd); 67 | user.setPassword(hashPwd); 68 | 69 | return user; 70 | } 71 | 72 | @Override 73 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 74 | User curruser = repository.findByUsername(username); 75 | 76 | UserDetails user = new org.springframework.security.core.userdetails.User(username, curruser.getPassword(), true, 77 | true, true, true, AuthorityUtils.createAuthorityList(curruser.getRole())); 78 | 79 | System.out.println("ROLE: " + curruser.getRole()); 80 | return user; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Database 2 | spring.datasource.url=jdbc:mysql://den1.mysql5.gear.host/springcourse 3 | spring.datasource.username=springcourse 4 | spring.datasource.password=Rz51X!?EP66E 5 | 6 | spring.jpa.hibernate.ddl-auto=update -------------------------------------------------------------------------------- /src/main/resources/static/css/font-awesome.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot?v=4.7.0');src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'),url('../fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'),url('../fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'),url('../fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em;text-align:center}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left{margin-right:.3em}.fa.fa-pull-right{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-feed:before,.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper-pp:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-resistance:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-y-combinator-square:before,.fa-yc-square:before,.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-intersex:before,.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-genderless:before{content:"\f22d"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}.fa-yc:before,.fa-y-combinator:before{content:"\f23b"}.fa-optin-monster:before{content:"\f23c"}.fa-opencart:before{content:"\f23d"}.fa-expeditedssl:before{content:"\f23e"}.fa-battery-4:before,.fa-battery:before,.fa-battery-full:before{content:"\f240"}.fa-battery-3:before,.fa-battery-three-quarters:before{content:"\f241"}.fa-battery-2:before,.fa-battery-half:before{content:"\f242"}.fa-battery-1:before,.fa-battery-quarter:before{content:"\f243"}.fa-battery-0:before,.fa-battery-empty:before{content:"\f244"}.fa-mouse-pointer:before{content:"\f245"}.fa-i-cursor:before{content:"\f246"}.fa-object-group:before{content:"\f247"}.fa-object-ungroup:before{content:"\f248"}.fa-sticky-note:before{content:"\f249"}.fa-sticky-note-o:before{content:"\f24a"}.fa-cc-jcb:before{content:"\f24b"}.fa-cc-diners-club:before{content:"\f24c"}.fa-clone:before{content:"\f24d"}.fa-balance-scale:before{content:"\f24e"}.fa-hourglass-o:before{content:"\f250"}.fa-hourglass-1:before,.fa-hourglass-start:before{content:"\f251"}.fa-hourglass-2:before,.fa-hourglass-half:before{content:"\f252"}.fa-hourglass-3:before,.fa-hourglass-end:before{content:"\f253"}.fa-hourglass:before{content:"\f254"}.fa-hand-grab-o:before,.fa-hand-rock-o:before{content:"\f255"}.fa-hand-stop-o:before,.fa-hand-paper-o:before{content:"\f256"}.fa-hand-scissors-o:before{content:"\f257"}.fa-hand-lizard-o:before{content:"\f258"}.fa-hand-spock-o:before{content:"\f259"}.fa-hand-pointer-o:before{content:"\f25a"}.fa-hand-peace-o:before{content:"\f25b"}.fa-trademark:before{content:"\f25c"}.fa-registered:before{content:"\f25d"}.fa-creative-commons:before{content:"\f25e"}.fa-gg:before{content:"\f260"}.fa-gg-circle:before{content:"\f261"}.fa-tripadvisor:before{content:"\f262"}.fa-odnoklassniki:before{content:"\f263"}.fa-odnoklassniki-square:before{content:"\f264"}.fa-get-pocket:before{content:"\f265"}.fa-wikipedia-w:before{content:"\f266"}.fa-safari:before{content:"\f267"}.fa-chrome:before{content:"\f268"}.fa-firefox:before{content:"\f269"}.fa-opera:before{content:"\f26a"}.fa-internet-explorer:before{content:"\f26b"}.fa-tv:before,.fa-television:before{content:"\f26c"}.fa-contao:before{content:"\f26d"}.fa-500px:before{content:"\f26e"}.fa-amazon:before{content:"\f270"}.fa-calendar-plus-o:before{content:"\f271"}.fa-calendar-minus-o:before{content:"\f272"}.fa-calendar-times-o:before{content:"\f273"}.fa-calendar-check-o:before{content:"\f274"}.fa-industry:before{content:"\f275"}.fa-map-pin:before{content:"\f276"}.fa-map-signs:before{content:"\f277"}.fa-map-o:before{content:"\f278"}.fa-map:before{content:"\f279"}.fa-commenting:before{content:"\f27a"}.fa-commenting-o:before{content:"\f27b"}.fa-houzz:before{content:"\f27c"}.fa-vimeo:before{content:"\f27d"}.fa-black-tie:before{content:"\f27e"}.fa-fonticons:before{content:"\f280"}.fa-reddit-alien:before{content:"\f281"}.fa-edge:before{content:"\f282"}.fa-credit-card-alt:before{content:"\f283"}.fa-codiepie:before{content:"\f284"}.fa-modx:before{content:"\f285"}.fa-fort-awesome:before{content:"\f286"}.fa-usb:before{content:"\f287"}.fa-product-hunt:before{content:"\f288"}.fa-mixcloud:before{content:"\f289"}.fa-scribd:before{content:"\f28a"}.fa-pause-circle:before{content:"\f28b"}.fa-pause-circle-o:before{content:"\f28c"}.fa-stop-circle:before{content:"\f28d"}.fa-stop-circle-o:before{content:"\f28e"}.fa-shopping-bag:before{content:"\f290"}.fa-shopping-basket:before{content:"\f291"}.fa-hashtag:before{content:"\f292"}.fa-bluetooth:before{content:"\f293"}.fa-bluetooth-b:before{content:"\f294"}.fa-percent:before{content:"\f295"}.fa-gitlab:before{content:"\f296"}.fa-wpbeginner:before{content:"\f297"}.fa-wpforms:before{content:"\f298"}.fa-envira:before{content:"\f299"}.fa-universal-access:before{content:"\f29a"}.fa-wheelchair-alt:before{content:"\f29b"}.fa-question-circle-o:before{content:"\f29c"}.fa-blind:before{content:"\f29d"}.fa-audio-description:before{content:"\f29e"}.fa-volume-control-phone:before{content:"\f2a0"}.fa-braille:before{content:"\f2a1"}.fa-assistive-listening-systems:before{content:"\f2a2"}.fa-asl-interpreting:before,.fa-american-sign-language-interpreting:before{content:"\f2a3"}.fa-deafness:before,.fa-hard-of-hearing:before,.fa-deaf:before{content:"\f2a4"}.fa-glide:before{content:"\f2a5"}.fa-glide-g:before{content:"\f2a6"}.fa-signing:before,.fa-sign-language:before{content:"\f2a7"}.fa-low-vision:before{content:"\f2a8"}.fa-viadeo:before{content:"\f2a9"}.fa-viadeo-square:before{content:"\f2aa"}.fa-snapchat:before{content:"\f2ab"}.fa-snapchat-ghost:before{content:"\f2ac"}.fa-snapchat-square:before{content:"\f2ad"}.fa-pied-piper:before{content:"\f2ae"}.fa-first-order:before{content:"\f2b0"}.fa-yoast:before{content:"\f2b1"}.fa-themeisle:before{content:"\f2b2"}.fa-google-plus-circle:before,.fa-google-plus-official:before{content:"\f2b3"}.fa-fa:before,.fa-font-awesome:before{content:"\f2b4"}.fa-handshake-o:before{content:"\f2b5"}.fa-envelope-open:before{content:"\f2b6"}.fa-envelope-open-o:before{content:"\f2b7"}.fa-linode:before{content:"\f2b8"}.fa-address-book:before{content:"\f2b9"}.fa-address-book-o:before{content:"\f2ba"}.fa-vcard:before,.fa-address-card:before{content:"\f2bb"}.fa-vcard-o:before,.fa-address-card-o:before{content:"\f2bc"}.fa-user-circle:before{content:"\f2bd"}.fa-user-circle-o:before{content:"\f2be"}.fa-user-o:before{content:"\f2c0"}.fa-id-badge:before{content:"\f2c1"}.fa-drivers-license:before,.fa-id-card:before{content:"\f2c2"}.fa-drivers-license-o:before,.fa-id-card-o:before{content:"\f2c3"}.fa-quora:before{content:"\f2c4"}.fa-free-code-camp:before{content:"\f2c5"}.fa-telegram:before{content:"\f2c6"}.fa-thermometer-4:before,.fa-thermometer:before,.fa-thermometer-full:before{content:"\f2c7"}.fa-thermometer-3:before,.fa-thermometer-three-quarters:before{content:"\f2c8"}.fa-thermometer-2:before,.fa-thermometer-half:before{content:"\f2c9"}.fa-thermometer-1:before,.fa-thermometer-quarter:before{content:"\f2ca"}.fa-thermometer-0:before,.fa-thermometer-empty:before{content:"\f2cb"}.fa-shower:before{content:"\f2cc"}.fa-bathtub:before,.fa-s15:before,.fa-bath:before{content:"\f2cd"}.fa-podcast:before{content:"\f2ce"}.fa-window-maximize:before{content:"\f2d0"}.fa-window-minimize:before{content:"\f2d1"}.fa-window-restore:before{content:"\f2d2"}.fa-times-rectangle:before,.fa-window-close:before{content:"\f2d3"}.fa-times-rectangle-o:before,.fa-window-close-o:before{content:"\f2d4"}.fa-bandcamp:before{content:"\f2d5"}.fa-grav:before{content:"\f2d6"}.fa-etsy:before{content:"\f2d7"}.fa-imdb:before{content:"\f2d8"}.fa-ravelry:before{content:"\f2d9"}.fa-eercast:before{content:"\f2da"}.fa-microchip:before{content:"\f2db"}.fa-snowflake-o:before{content:"\f2dc"}.fa-superpowers:before{content:"\f2dd"}.fa-wpexplorer:before{content:"\f2de"}.fa-meetup:before{content:"\f2e0"}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto} 5 | -------------------------------------------------------------------------------- /src/main/resources/static/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #333333; 3 | font-size: 14px; 4 | background-color: #fff; 5 | padding: 0; 6 | margin: 0; 7 | } 8 | body.layout-scroll-block { 9 | overflow: hidden; 10 | } 11 | h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { 12 | font-weight: 500; 13 | line-height: 1.1; 14 | } 15 | h2, .h2 { 16 | padding-bottom: 10px !important; 17 | } 18 | h3, .h3 { 19 | font-size: 24px; 20 | } 21 | 22 | .container-fluid { 23 | padding-left: 45px !important; 24 | padding-right: 45px !important; 25 | } 26 | 27 | .bg-login { 28 | background-color: #eaeaea; 29 | min-height: 650px !important; 30 | } 31 | .bg-login .container-login { 32 | max-width: 350px; 33 | margin: 0px auto !important; 34 | padding-top: 90px !important; 35 | } 36 | .bg-login .container-login a { 37 | color: #333333 !important; 38 | text-decoration: none; 39 | } 40 | 41 | .panel { 42 | margin-bottom: 20px; 43 | background-color: #fff; 44 | border: 1px solid transparent; 45 | border-top-color: transparent; 46 | border-right-color: transparent; 47 | border-bottom-color: transparent; 48 | border-left-color: transparent; 49 | border-radius: 4px; 50 | -webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.05); 51 | box-shadow: 0 1px 1px rgba(0,0,0,0.05); 52 | } 53 | .panel-default { 54 | border-color: #ddd; 55 | } 56 | .panel-body { 57 | padding: 15px; 58 | } 59 | .box-login { 60 | box-shadow: 1px 3px 12px #50575b; 61 | } 62 | input:focus { 63 | box-shadow: 1px 1px 5px #707577 !important; 64 | border: 1px solid #707577 !important; 65 | } 66 | .title-login { 67 | text-align: center; 68 | padding-bottom: 6px; 69 | } 70 | fieldset { 71 | background-color: #fff !important; 72 | } 73 | .form-group { 74 | margin-bottom: 15px; 75 | } 76 | .form-control { 77 | display: block; 78 | width: 100%; 79 | height: 34px; 80 | padding: 6px 12px; 81 | font-size: 14px; 82 | line-height: 1.42857143; 83 | color: #555; 84 | background-color: #fff; 85 | background-image: none; 86 | border: 1px solid #ccc; 87 | border-radius: 4px; 88 | -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); 89 | box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); 90 | -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; 91 | -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; 92 | transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; 93 | } 94 | .fa { 95 | display: inline-block; 96 | font: normal normal normal 14px/1 FontAwesome; 97 | font-size: 14px; 98 | font-size: inherit; 99 | text-rendering: auto; 100 | -webkit-font-smoothing: antialiased; 101 | -moz-osx-font-smoothing: grayscale; 102 | } 103 | .fa-user { 104 | float: left; 105 | position: relative; 106 | color: #343C41 !important; 107 | font-size: 16px !important; 108 | top: 25px; 109 | left: 12px; 110 | z-index: 2; 111 | } 112 | .fa-lock { 113 | float: left; 114 | position: relative; 115 | color: #343C41 !important; 116 | font-size: 16px !important; 117 | top: 25px; 118 | left: 12px; 119 | z-index: 2; 120 | } 121 | .input-login { 122 | padding-left: 34px !important; 123 | } 124 | 125 | .btn-login { 126 | background-color: #343C41 !important; 127 | color: #eee !important; 128 | border: 1px solid #000 !important; 129 | } 130 | .btn-logout { 131 | background-color: #343C41 !important; 132 | color: #eee !important; 133 | border: 1px solid #000 !important; 134 | } 135 | .alert { 136 | margin-top: 15px !important; 137 | } 138 | .col-md-4 { 139 | padding-right: 0px !important; 140 | padding-left: 0px !important; 141 | } 142 | .navbar-header a { 143 | font-weight: bold; 144 | } 145 | .menubar { 146 | float: left; 147 | width: auto; 148 | display: block; 149 | padding: .3em; 150 | outline: 0 none; 151 | } 152 | .menu-list { 153 | line-height: normal; 154 | margin: 0; 155 | padding: 0; 156 | border: 0; 157 | outline: 0; 158 | line-height: 1.3; 159 | text-decoration: none; 160 | list-style: none; 161 | } 162 | .menu-item { 163 | float: left; 164 | width: auto; 165 | clear: none; 166 | } 167 | 168 | .col-actions { 169 | text-align: center; 170 | width: 300px !important; 171 | } 172 | 173 | .show-buttons { 174 | padding-left: 15px; 175 | } 176 | 177 | .invalid-feedback-input { 178 | border: 1px solid #dc3545; 179 | } 180 | .invalid-feedback { 181 | margin-top: .25rem; 182 | color: #dc3545; 183 | } 184 | -------------------------------------------------------------------------------- /src/main/resources/static/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/src/main/resources/static/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /src/main/resources/static/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/src/main/resources/static/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /src/main/resources/static/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/src/main/resources/static/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /src/main/resources/static/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/src/main/resources/static/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /src/main/resources/static/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danilomeneghel/java-spring-boot/c60a418b767265c9415c010af2a53e48059af8af/src/main/resources/static/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /src/main/resources/templates/addStudentCourse.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |

Add Course

10 |
11 |
12 |
13 |
14 |
15 |
Student Info
16 |
17 | Name:
18 | Email:
19 | Department:
20 |
Courses: 21 | 22 |
   23 | 24 |
25 |
26 |
27 |
28 | 33 |
34 |
35 | Back 36 | 39 |
40 |
41 | 42 |
43 |
44 |
45 | 46 | -------------------------------------------------------------------------------- /src/main/resources/templates/courseForm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |

[[${title}]]

10 |
11 |
12 |
13 |
14 | 15 |
16 | 17 |

Course Error

18 |
19 |
20 | Back 21 | 24 |
25 |
26 |
27 |
28 |
29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /src/main/resources/templates/courseShow.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |

[[${title}]]

10 |
11 |
12 |
13 |
14 |
15 | 16 |
17 |

Id

18 |
19 |
20 | 21 |
22 |

name

23 |
24 |
25 |
26 | Back 27 | Edit 28 |
29 |
30 |
31 |
32 |
33 |
34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/templates/courses.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |

Courses

10 | Add Course 11 |

12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 25 |
CourseActions
20 | Show 21 | Edit 22 | Delete 23 |
26 |
27 | 28 | -------------------------------------------------------------------------------- /src/main/resources/templates/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 |
11 |

ERRO 404

12 |

Página não encontrada.

13 |
14 |
15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragments/header.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 |
8 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /src/main/resources/templates/fragments/headerinc.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | Course 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
10 |

Welcome, [[${#httpServletRequest.remoteUser}]]!

11 | Course Registration 12 |
13 |
14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/templates/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 45 | 46 | -------------------------------------------------------------------------------- /src/main/resources/templates/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 39 | 40 | -------------------------------------------------------------------------------- /src/main/resources/templates/studentForm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |

[[${title}]]

10 |
11 |
12 |
13 |
14 | 15 |
16 | 17 |

Firstname Error

18 |
19 |
20 | 21 |

Lastname Error

22 |
23 |
24 | 25 |

Department Error

26 |
27 |
28 | 29 |

Email Error

30 |
31 |
32 | Back 33 | 36 |
37 |
38 |
39 |
40 |
41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /src/main/resources/templates/studentShow.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |

[[${title}]]

10 |
11 |
12 |
13 |
14 |
15 | 16 |
17 |

Id

18 |
19 |
20 | 21 |
22 |

firstName

23 |

lastName

24 |
25 |
26 |
27 | 28 |
29 |

department

30 |
31 |
32 |
33 | 34 |
35 |

email

36 |
37 |
38 |
39 | Back 40 | Edit 41 |
42 |
43 |
44 |
45 |
46 |
47 | 48 | -------------------------------------------------------------------------------- /src/main/resources/templates/students.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |

Students

10 | Add Student 11 |

12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 29 | 34 | 35 |
NameEmailDepartmentCoursesActions
25 | 26 | , 27 | 28 | 30 | Course 31 | Edit 32 | Delete 33 |
36 |
37 | 38 | -------------------------------------------------------------------------------- /src/main/resources/templates/userForm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |

[[${title}]]

10 |
11 |
12 |
13 |
14 | 15 |
16 | 17 |

Username is invalid

18 |
19 |
20 | 21 |

Password is invalid

22 |
23 |
24 | 28 |
29 |
30 | Back 31 | 34 |
35 |
36 |
37 |
38 |
39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /src/main/resources/templates/userShow.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |

[[${title}]]

10 |
11 |
12 |
13 |
14 |
15 | 16 |
17 |

Id

18 |
19 |
20 | 21 |
22 |

username

23 |
24 |
25 |
26 | 27 |
28 |

role

29 |
30 |
31 |
32 | Back 33 | Edit 34 |
35 |
36 |
37 |
38 |
39 |
40 | 41 | -------------------------------------------------------------------------------- /src/main/resources/templates/users.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |

Users

10 | Add User 11 |

12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 26 | 27 |
UsernameRoleActions
22 | Show 23 | Edit 24 | Delete 25 |
28 |
29 | 30 | -------------------------------------------------------------------------------- /src/test/java/course/CrudbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package course; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.*; 5 | 6 | import static org.junit.Assert.*; 7 | 8 | import java.util.Optional; 9 | 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | 14 | import course.entity.Student; 15 | import course.repository.StudentRepository; 16 | import course.entity.User; 17 | import course.repository.UserRepository; 18 | 19 | @RunWith(SpringRunner.class) 20 | @DataJpaTest 21 | public class CrudbootApplicationTests { 22 | 23 | private UserRepository userRepository; 24 | 25 | @Autowired 26 | public void setUserRepository(UserRepository userRepository) { 27 | this.userRepository = userRepository; 28 | } 29 | 30 | private StudentRepository studentRepository; 31 | 32 | @Autowired 33 | public void setStudentRepository(StudentRepository studentRepository) { 34 | this.studentRepository = studentRepository; 35 | } 36 | 37 | @Test 38 | public void addUser() { 39 | User user = new User("testuser", "testuser", "USER"); 40 | 41 | assertNull(user.getId()); 42 | userRepository.save(user); 43 | assertNotNull(user.getId()); 44 | } 45 | 46 | @Test 47 | public void addStudent() { 48 | Student student = new Student("Test", "Student", "IT", "test@test.com"); 49 | 50 | studentRepository.save(student); 51 | Optional findStudent = studentRepository.findById(student.getId()); 52 | assertTrue(findStudent.isPresent()); 53 | } 54 | 55 | } 56 | --------------------------------------------------------------------------------