From 8bfc98cc71947e75a8911ddeacdf92d7537f0bd8 Mon Sep 17 00:00:00 2001 From: aswinsundar Date: Tue, 21 Mar 2023 10:52:06 +0530 Subject: [PATCH] initial commit --- .gitignore | 33 + README.md | 10 + mvnw | 310 ++++++++ mvnw.cmd | 182 +++++ pom.xml | 77 ++ .../html/Entity/PetRegisterEntity.java | 445 +++++++++++ .../html/Repository/PetRepository.java | 15 + .../html/Service/PetRegisterService.java | 23 + .../com/okayjava/html/ServletInitializer.java | 13 + .../html/SpringbootHtmlApplication.java | 13 + .../html/controller/AcceptReject.java | 255 +++++++ .../okayjava/html/controller/Acknowledge.java | 69 ++ .../html/controller/IndexController.java | 201 +++++ .../html/exceptions/CustomExceptions.java | 7 + .../html/exceptions/ExceptionHAndlers.java | 15 + .../com/okayjava/html/model/Customer.java | 38 + .../com/okayjava/html/model/PetRegister.java | 527 ++++++++++++++ .../com/okayjava/html/model/RazorPay.java | 147 ++++ .../com/okayjava/html/model/Response.java | 24 + .../com/okayjava/html/model/payments.java | 23 + .../okayjava/html/utils/imageCompress.java | 44 ++ src/main/resources/application.properties | 14 + .../resources/templates/acknowledged.html | 138 ++++ src/main/resources/templates/head.html | 49 ++ src/main/resources/templates/index.html | 688 ++++++++++++++++++ src/main/resources/templates/navbar.html | 31 + .../resources/templates/razorpayment.html | 170 +++++ src/main/resources/templates/welcome.html | 123 ++++ .../html/SpringbootHtmlApplicationTests.java | 13 + 29 files changed, 3697 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 mvnw create mode 100644 mvnw.cmd create mode 100644 pom.xml create mode 100644 src/main/java/com/okayjava/html/Entity/PetRegisterEntity.java create mode 100644 src/main/java/com/okayjava/html/Repository/PetRepository.java create mode 100644 src/main/java/com/okayjava/html/Service/PetRegisterService.java create mode 100644 src/main/java/com/okayjava/html/ServletInitializer.java create mode 100644 src/main/java/com/okayjava/html/SpringbootHtmlApplication.java create mode 100644 src/main/java/com/okayjava/html/controller/AcceptReject.java create mode 100644 src/main/java/com/okayjava/html/controller/Acknowledge.java create mode 100644 src/main/java/com/okayjava/html/controller/IndexController.java create mode 100644 src/main/java/com/okayjava/html/exceptions/CustomExceptions.java create mode 100644 src/main/java/com/okayjava/html/exceptions/ExceptionHAndlers.java create mode 100644 src/main/java/com/okayjava/html/model/Customer.java create mode 100644 src/main/java/com/okayjava/html/model/PetRegister.java create mode 100644 src/main/java/com/okayjava/html/model/RazorPay.java create mode 100644 src/main/java/com/okayjava/html/model/Response.java create mode 100644 src/main/java/com/okayjava/html/model/payments.java create mode 100644 src/main/java/com/okayjava/html/utils/imageCompress.java create mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/templates/acknowledged.html create mode 100644 src/main/resources/templates/head.html create mode 100644 src/main/resources/templates/index.html create mode 100644 src/main/resources/templates/navbar.html create mode 100644 src/main/resources/templates/razorpayment.html create mode 100644 src/main/resources/templates/welcome.html create mode 100644 src/test/java/com/okayjava/html/SpringbootHtmlApplicationTests.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..b3c0ffa --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# springboot-html + +Springboot with HTML - take user input +Watch the video here - https://youtu.be/GMNGPry979k + +## Getting started + +Watch the video here +https://youtu.be/GMNGPry979k + diff --git a/mvnw b/mvnw new file mode 100644 index 0000000..a16b543 --- /dev/null +++ b/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..ce462c4 --- /dev/null +++ b/pom.xml @@ -0,0 +1,77 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.6.1 + + + com.okayjava.html + pet-registry + 0.0.1 + war + pet-registry + Pet Registration + + 1.8 + 8 + 8 + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-jdbc + + + mysql + mysql-connector-java + runtime + + + org.projectlombok + lombok + true + + + com.razorpay + razorpay-java + 1.3.9 + + + com.google.code.gson + gson + 2.6.2 + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + package + + + + diff --git a/src/main/java/com/okayjava/html/Entity/PetRegisterEntity.java b/src/main/java/com/okayjava/html/Entity/PetRegisterEntity.java new file mode 100644 index 0000000..61eca0a --- /dev/null +++ b/src/main/java/com/okayjava/html/Entity/PetRegisterEntity.java @@ -0,0 +1,445 @@ +package com.okayjava.html.Entity; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.persistence.*; + + +@Data +//@AllArgsConstructor +@NoArgsConstructor +@Entity +@Table(name = "PETREGISTER") +public class PetRegisterEntity { + @Id + private long Id; + + public String getPaymentid() { + return paymentid; + } + + public void setPaymentid(String paymentid) { + this.paymentid = paymentid; + } + + public long getId() { + return Id; + } + @Lob + private byte[] addressProofPhoto; + @Lob + private byte[] petPhoto; + + private String paymentid; + + public byte[] getAddressProofPhoto() { + return addressProofPhoto; + } + + public void setAddressProofPhoto(byte[] addressProofPhoto) { + this.addressProofPhoto = addressProofPhoto; + } + + public byte[] getPetPhoto() { + return petPhoto; + } + + public void setPetPhoto(byte[] petPhoto) { + this.petPhoto = petPhoto; + } + + public byte[] getVaccinationCertificatePhoto() { + return vaccinationCertificatePhoto; + } + + public void setVaccinationCertificatePhoto(byte[] vaccinationCertificatePhoto) { + this.vaccinationCertificatePhoto = vaccinationCertificatePhoto; + } + @Lob + private byte[] vaccinationCertificatePhoto; + + public void setId(long id) { + Id = id; + } + + public byte[] getApplicantPhoto() { + return applicantPhoto; + } + + public void setApplicantPhoto(byte[] applicantPhoto) { + this.applicantPhoto = applicantPhoto; + } + + public String getName() { + return name; + } + + private String comments; + private String status; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments = comments; + } + + public void setName(String name) { + this.name = name; + } + + public String getPetID() { + return petID; + } + + public void setPetID(String petID) { + this.petID = petID; + } + + + public String getAgeyears() { + return Ageyears; + } + + @Lob + private byte[] applicantPhoto; + private String name; + private String petID; + private String zone; + private String division; + private String title; + private String fname; + private String doornumber; + private String street; + private String area; + private String city; + private String phone; + private String pincode; + private String state; + private String email; + private String pancardnumber; + private String aadhar; + private String votercard; + private String previouslicense; + private String petname; + private String species; + private String identificationmark; + private String breed; + private String petcolor; + private String gender; + private String VeterinaryConsultant; + private String TNVCNo; + + public String getDivision() { + return division; + } + + public void setDivision(String division) { + this.division = division; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDoornumber() { + return doornumber; + } + + public void setDoornumber(String doornumber) { + this.doornumber = doornumber; + } + + public String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street = street; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPincode() { + return pincode; + } + + public void setPincode(String pincode) { + this.pincode = pincode; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getPancardnumber() { + return pancardnumber; + } + + public void setPancardnumber(String pancardnumber) { + this.pancardnumber = pancardnumber; + } + + public String getAadhar() { + return aadhar; + } + + public void setAadhar(String aadhar) { + this.aadhar = aadhar; + } + + public String getVotercard() { + return votercard; + } + + public void setVotercard(String votercard) { + this.votercard = votercard; + } + + public String getPreviouslicense() { + return previouslicense; + } + + public void setPreviouslicense(String previouslicense) { + this.previouslicense = previouslicense; + } + public String getPetname() { + return petname; + } + + public void setPetname(String petname) { + this.petname = petname; + } + + public String getSpecies() { + return species; + } + + public void setSpecies(String species) { + this.species = species; + } + + public String getIdentificationmark() { + return identificationmark; + } + + public void setIdentificationmark(String identificationmark) { + this.identificationmark = identificationmark; + } + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + public String getPetcolor() { + return petcolor; + } + + public void setPetcolor(String petcolor) { + this.petcolor = petcolor; + } + + public String getVeterinaryConsultant() { + return VeterinaryConsultant; + } + + public void setVeterinaryConsultant(String veterinaryConsultant) { + VeterinaryConsultant = veterinaryConsultant; + } + + + public String getSterilization() { + return sterilization; + } + + public void setSterilization(String sterilization) { + this.sterilization = sterilization; + } + + public void setAgeyears(String ageyears) { + Ageyears = ageyears; + } + + private String Ageyears; + + public String getMonths() { + return Months; + } + + public void setMonths(String months) { + Months = months; + } + + private String Months; + + public String getARVdate() { + return ARVdate; + } + + public void setARVdate(String ARVddate) { + this.ARVdate = ARVdate; + } + + private String ARVdate; + + public String getLastdate() { + return Lastdate; + } + + public void setLastdate(String Lastdate) { + this.Lastdate = Lastdate; + } + + private String Lastdate; + + private String sterilization; + + private String adopted; + + private String AntiRabies_vaccination; + + private String Other_vaccination; + + + public String getZone() { + return zone; + } + + public void setZone(String zone) { + this.zone = zone; + } + + public String getPan() { + return pancardnumber; + } + public void setPan(String pancardnumber) { + this.pancardnumber = pancardnumber; + } + + public String getFname() { + return fname; + } + public void setFname(String fname) { + this.fname = fname; + } + + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + public String getTNVCNo() { + return TNVCNo; + } + public void setTNVCNo(String TNVCNo) { + this.TNVCNo = TNVCNo; + } + + public String getGender() { + return gender; + } + public void setGender(String gender) { + this.gender = gender; + } + public String getAdopted() { + return adopted; + } + + public String getAntiRabies_vaccination(){ + return AntiRabies_vaccination; + } + public String getOther_Vaccination(){ + String Other_Vaccination = null; + return null; + } + public PetRegisterEntity(long id, String petID, String zone, String division, + String title, String fname, String doornumber, + String street, String area, String city, String phone, String pincode, + String state, String email, String pancardnumber, String aadhar, String votercard, + String previouslicense, String petname, String species, String identificationmark, + String breed, String petcolor, String gender, String veterinaryConsultant, + String TNVCNo, String ageyears, String months, String ARVdate, String Lastdate, + String sterilization, String adopted, String Other_Vaccination, String AntiRabies_vaccination) { + Id = id; + this.petID = petID; + this.zone = zone; + this.division = division; + this.title = title; + this.fname = fname; + this.doornumber = doornumber; + this.street = street; + this.area = area; + this.city = city; + this.phone = phone; + this.pincode = pincode; + this.state = state; + this.email = email; + this.pancardnumber = pancardnumber; + this.aadhar = aadhar; + this.votercard = votercard; + this.previouslicense = previouslicense; + this.petname = petname; + this.species = species; + this.identificationmark = identificationmark; + this.breed = breed; + this.petcolor = petcolor; + this.gender = gender; + VeterinaryConsultant = veterinaryConsultant; + this.TNVCNo = TNVCNo; + Ageyears = ageyears; + Months = months; + this.ARVdate = ARVdate; + this.Lastdate = Lastdate; + this.sterilization = sterilization; + this.adopted = adopted; + this.AntiRabies_vaccination = AntiRabies_vaccination; + } + + public void setAdopted(String adopted) { + this.adopted = adopted; + } +} \ No newline at end of file diff --git a/src/main/java/com/okayjava/html/Repository/PetRepository.java b/src/main/java/com/okayjava/html/Repository/PetRepository.java new file mode 100644 index 0000000..8132e77 --- /dev/null +++ b/src/main/java/com/okayjava/html/Repository/PetRepository.java @@ -0,0 +1,15 @@ +package com.okayjava.html.Repository; +import com.okayjava.html.Entity.PetRegisterEntity; +import org.springframework.data.jpa.repository.JpaRepository; + +import javax.persistence.Id; + +public interface PetRepository extends JpaRepository { + PetRepository findByName(String name); +} + +// +// +//public interface PetRepository extends JpaRepository { +// Pet findByName(String name); +//} diff --git a/src/main/java/com/okayjava/html/Service/PetRegisterService.java b/src/main/java/com/okayjava/html/Service/PetRegisterService.java new file mode 100644 index 0000000..9c8a733 --- /dev/null +++ b/src/main/java/com/okayjava/html/Service/PetRegisterService.java @@ -0,0 +1,23 @@ +package com.okayjava.html.Service; + +import com.okayjava.html.Repository.PetRepository; +import com.okayjava.html.Entity.PetRegisterEntity; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class PetRegisterService { + @Autowired + private PetRepository petRepository; + + public PetRegisterEntity addPetRegister(PetRegisterEntity petregister) { + return petRepository.save(petregister); + + } + public List getAllpetregister() { + List emps = (List) petRepository.findAll(); + return emps; + } +} diff --git a/src/main/java/com/okayjava/html/ServletInitializer.java b/src/main/java/com/okayjava/html/ServletInitializer.java new file mode 100644 index 0000000..77487da --- /dev/null +++ b/src/main/java/com/okayjava/html/ServletInitializer.java @@ -0,0 +1,13 @@ +package com.okayjava.html; + +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +public class ServletInitializer extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(SpringbootHtmlApplication.class); + } + +} \ No newline at end of file diff --git a/src/main/java/com/okayjava/html/SpringbootHtmlApplication.java b/src/main/java/com/okayjava/html/SpringbootHtmlApplication.java new file mode 100644 index 0000000..460d6f6 --- /dev/null +++ b/src/main/java/com/okayjava/html/SpringbootHtmlApplication.java @@ -0,0 +1,13 @@ +package com.okayjava.html; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringbootHtmlApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringbootHtmlApplication.class, args); + } + +} diff --git a/src/main/java/com/okayjava/html/controller/AcceptReject.java b/src/main/java/com/okayjava/html/controller/AcceptReject.java new file mode 100644 index 0000000..e0bfd78 --- /dev/null +++ b/src/main/java/com/okayjava/html/controller/AcceptReject.java @@ -0,0 +1,255 @@ +package com.okayjava.html.controller; + +import com.google.gson.Gson; +import com.okayjava.html.model.*; +import com.razorpay.Order; +import java.math.BigDecimal; +import java.math.RoundingMode; + +import org.hibernate.cfg.Environment; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + + +import com.okayjava.html.Repository.PetRepository; +import com.razorpay.RazorpayClient; +import com.razorpay.RazorpayException; +import com.razorpay.VirtualAccount; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; + +@Controller +public class AcceptReject { + @Autowired + private JdbcTemplate jdbcTemplate; + private PetRepository petRepository; + + private RazorpayClient client; + private static Gson gson = new Gson(); + + @Value("${razoramount}") + private Integer rAmount; + + /** + * add your secretId and secretValue you got from your RazorPay account. + */ + private static final String SECRET_ID = "rzp_live_dZkTTP32cjf3wj"; + private static final String SECRET_KEY = "pPgFK4AwzQoBC7zoPKSPl1At"; + public AcceptReject() throws RazorpayException { + this.client = new RazorpayClient(SECRET_ID, SECRET_KEY); + } + @RequestMapping(value = "/decisionMaking", params = "reject", method = RequestMethod.POST) + public String Reject(@RequestParam("petsID") String petID, Model model, + @RequestParam("comments") String comments) { + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); + LocalDateTime now = LocalDateTime.now(); + System.out.println(dtf.format(now)); + + String sql = "update petregister set comments = concat(comments, '. " + comments + + " as on " + dtf.format(now) + "'), status = 'Rejected' where petid='" + petID + "'"; + + System.out.println(sql); + jdbcTemplate.update(sql); + + model.addAttribute("petsID", petID); + System.out.println(comments); + + List petRegisters = jdbcTemplate.query("select * from petregister", (rs, rowNum) -> { + PetRegister petRegister = new PetRegister(rs.getString("petID"), rs.getString("zone"), + rs.getString("division"), rs.getString("title"), rs.getString("fname"), + rs.getString("doornumber"), rs.getString("street"), rs.getString("area"), rs.getString("city"), rs.getString("phone"), + rs.getString("pincode"), rs.getString("state"), rs.getString("email"), rs.getString("pancardnumber"), + rs.getString("aadhar"), rs.getString("votercard"), rs.getString("previouslicense"), rs.getString("petname"), + rs.getString("species"), rs.getString("identificationmark"), rs.getString("breed"), rs.getString("petcolor"), + rs.getString("gender"), rs.getString("Veterinary_Consultant"), rs.getString("TNVCNo"), + rs.getString("Ageyears"), rs.getString("months"), rs.getString("ARVdate"), rs.getString("Lastdate"), rs.getString("sterilization"), + rs.getString("adopted"), "NA", rs.getBytes("applicant_photo"), + rs.getBytes("address_proof_photo"), rs.getBytes("vaccination_certificate_photo"), + rs.getBytes("pet_photo"), rs.getString("comments"), rs.getString("status"), + rs.getString("paymentid")); + +// System.out.println(petRegister); + + return petRegister; + }); +// System.out.println(petRegisters); + model.addAttribute("pets", petRegisters); +// model.addAttribute("comments", comments); + return "welcome"; + } + + @RequestMapping(value = "/decisionMaking", params = "Accept", method = RequestMethod.POST) + public String Accept(@RequestParam("petsID") String petID, Model model, + @RequestParam("comments") String comments) throws RazorpayException { + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); + LocalDateTime now = LocalDateTime.now(); + System.out.println(dtf.format(now)); + + String sql = "update petregister set comments = concat(comments, '. " + comments + + " as on " + dtf.format(now) + "'), status = 'Accepted' where petid='" + petID + "'"; + + System.out.println(sql); + jdbcTemplate.update(sql); + + model.addAttribute("petsID", petID); + System.out.println(comments); + + List petRegisters = jdbcTemplate.query("select * from petregister where paymentid is null", (rs, rowNum) -> { + PetRegister petRegister = new PetRegister(rs.getString("petID"), rs.getString("zone"), + rs.getString("division"), rs.getString("title"), rs.getString("fname"), + rs.getString("doornumber"), rs.getString("street"), rs.getString("area"), rs.getString("city"), rs.getString("phone"), + rs.getString("pincode"), rs.getString("state"), rs.getString("email"), rs.getString("pancardnumber"), + rs.getString("aadhar"), rs.getString("votercard"), rs.getString("previouslicense"), rs.getString("petname"), + rs.getString("species"), rs.getString("identificationmark"), rs.getString("breed"), rs.getString("petcolor"), + rs.getString("gender"), rs.getString("Veterinary_Consultant"), rs.getString("TNVCNo"), + rs.getString("Ageyears"), rs.getString("months"), rs.getString("ARVdate"), rs.getString("Lastdate"), rs.getString("sterilization"), + rs.getString("adopted"), "NA", rs.getBytes("applicant_photo"), + rs.getBytes("address_proof_photo"), rs.getBytes("vaccination_certificate_photo"), + rs.getBytes("pet_photo"), rs.getString("comments"), rs.getString("status"), + rs.getString("paymentid")); + +// System.out.println(petRegister); + + return petRegister; + }); + +// RazorpayClient razorpay = new RazorpayClient("rzp_test_JOC0wRKpLH1cVW", "9EzSlxvJbTyQ2Hg0Us5ZX4VD"); +// +// JSONObject orderRequest = new JSONObject(); +// orderRequest.put("amount",1000); +// orderRequest.put("currency","INR"); +// orderRequest.put("receipt", "receipt#1"); +// orderRequest.put("payment_capture", 1); +// JSONObject notes = new JSONObject(); +// notes.put("notes_key_1","Pet Registration Charges"); +// orderRequest.put("notes",notes); +// System.out.println("orderRequest: " + orderRequest); +// +// Order order = razorpay.Orders.create(orderRequest); +// +// JSONObject params = new JSONObject(); +// params.put("count","100"); +// +// List orders = razorpay.Orders.fetchAll(params); +// System.out.println(orders); + +// List virtualAccounts = razorpay.VirtualAccounts.fetchAll(); +// System.out.println(virtualAccounts); + model.addAttribute("pets", petRegisters); + model.addAttribute("rAmount", rAmount); +// model.addAttribute("comments", comments); + return "razorpayment"; + } + + @GetMapping("/GetRazorPayment/petid={petID}") + public String getrazorpayment(ModelMap model, @PathVariable String petID){ + model.addAttribute("petsID", petID); + return "razorpayment"; + } + + @RequestMapping(value="/updatePayment", method=RequestMethod.POST) + @ResponseBody + public ResponseEntity upPayment(@RequestBody payments payid) { + + try { + + /** + * creating an order in RazorPay. + * new order will have order id. you can get this order id by calling order.get("id") + */ + System.out.println(payid.getPaymentid()); + System.out.println(payid.getPetsID()); + String sql = "update petregister set paymentid = '" + payid.getPaymentid() + + "' where petid='" + payid.getPetsID() + "'"; + + System.out.println(sql); + jdbcTemplate.update(sql); + + return new ResponseEntity(gson.toJson(payid.getPaymentid()), + HttpStatus.OK); + } catch (Exception e) { + e.printStackTrace(); + } + return new ResponseEntity(gson.toJson(getResponse(new RazorPay(), 500)), + HttpStatus.EXPECTATION_FAILED); + } + + @RequestMapping(value="/createPayment", method=RequestMethod.POST) + @ResponseBody + public ResponseEntity createOrder(@RequestBody Customer customer) { + + try { + + /** + * creating an order in RazorPay. + * new order will have order id. you can get this order id by calling order.get("id") + */ + Order order = createRazorPayOrder( customer.getAmount() ); + RazorPay razorPay = getRazorPay((String)order.get("id"), customer); + + return new ResponseEntity(gson.toJson(getResponse(razorPay, 200)), + HttpStatus.OK); + } catch (RazorpayException e) { + e.printStackTrace(); + } + return new ResponseEntity(gson.toJson(getResponse(new RazorPay(), 500)), + HttpStatus.EXPECTATION_FAILED); + } + + private Response getResponse(RazorPay razorPay, int statusCode) { + Response response = new Response(); + response.setStatusCode(statusCode); + response.setRazorPay(razorPay); + return response; + } + + private RazorPay getRazorPay(String orderId, Customer customer) { + RazorPay razorPay = new RazorPay(); + razorPay.setApplicationFee(convertRupeeToPaise(customer.getAmount())); + razorPay.setCustomerName(customer.getCustomerName()); + razorPay.setCustomerEmail(customer.getEmail()); + razorPay.setCustomerContact(customer.getPhoneNumber()); + razorPay.setMerchantName("PETS"); + razorPay.setPurchaseDescription("PET REGISTRATION"); + razorPay.setRazorpayOrderId(orderId); + razorPay.setSecretKey(SECRET_ID); + razorPay.setImageURL("/logo"); + razorPay.setTheme("#F37254"); + razorPay.setNotes("notes"+orderId); + + return razorPay; + } + + private Order createRazorPayOrder(String amount) throws RazorpayException { + + JSONObject options = new JSONObject(); + options.put("amount", convertRupeeToPaise(amount)); + options.put("currency", "INR"); + options.put("receipt", "txn_123456"); + options.put("payment_capture", 1); // You can enable this if you want to do Auto Capture. + return client.Orders.create(options); + } + + private String convertRupeeToPaise(String paise) { + BigDecimal b = new BigDecimal(paise); + BigDecimal value = b.multiply(new BigDecimal("100")); + return value.setScale(0, RoundingMode.UP).toString(); + + } + +} diff --git a/src/main/java/com/okayjava/html/controller/Acknowledge.java b/src/main/java/com/okayjava/html/controller/Acknowledge.java new file mode 100644 index 0000000..cd0e2e4 --- /dev/null +++ b/src/main/java/com/okayjava/html/controller/Acknowledge.java @@ -0,0 +1,69 @@ +package com.okayjava.html.controller; + +import com.okayjava.html.Repository.PetRepository; +import com.okayjava.html.model.PetRegister; +import com.okayjava.html.utils.imageCompress; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.Base64; +import java.util.List; + +@Controller +public class Acknowledge { + @Autowired + private JdbcTemplate jdbcTemplate; + private PetRepository petRepository; + + @PostMapping("/Acknowledgeregister") + public String acknowledgeRegister(@RequestParam("petsID") String petID, Model model){ + System.out.println(petID); + + List petRegisters = jdbcTemplate.query("select * from petregister where petID = '" + petID + "'" + , (rs, rowNum) -> { + PetRegister petRegister = new PetRegister(rs.getString("petID"), rs.getString("zone"), + rs.getString("division"), rs.getString("title"), rs.getString("Fname"), + rs.getString("doornumber"), rs.getString("street"), rs.getString("area"), rs.getString("city"), rs.getString("phone"), + rs.getString("pincode"), rs.getString("state"), rs.getString("email"), rs.getString("pancardnumber"), + rs.getString("aadhar"), rs.getString("votercard"), rs.getString("previouslicense"), rs.getString("petname"), + rs.getString("species"), rs.getString("identificationmark"), rs.getString("breed"), rs.getString("petcolor"), + rs.getString("gender"), rs.getString("Veterinary_Consultant"), rs.getString("TNVCNo"), + rs.getString("Ageyears"), rs.getString("months"), + rs.getString("ARVdate"), rs.getString("Lastdate"), + rs.getString("sterilization"), + rs.getString("adopted"), "NA", + imageCompress.decompressImage( rs.getBytes("applicant_photo")), + imageCompress.decompressImage( rs.getBytes("address_proof_photo")), + imageCompress.decompressImage( rs.getBytes("vaccination_certificate_photo")), + imageCompress.decompressImage( rs.getBytes("pet_photo")), + rs.getString("comments"), rs.getString("status"), + rs.getString("paymentid")); + System.out.println(petRegister); + return petRegister; + }); + + try { + petRegisters.get(0).setPet_photo(Base64.getEncoder().encodeToString(petRegisters.get(0).getPetPhoto_bytes())); + petRegisters.get(0).setVaccination_certificate_photo(Base64.getEncoder().encodeToString(petRegisters.get(0).getVaccinationCertificatePhoto_bytes())); + + + System.out.println(petRegisters.get(0).getApplicant_photo_bytes().length > 5); + if (petRegisters.get(0).getApplicant_photo_bytes().length > 5) { + petRegisters.get(0).setApplicant_photo(Base64.getEncoder().encodeToString(petRegisters.get(0).getApplicant_photo_bytes())); + } + } + catch (Exception ex){ + petRegisters.get(0).setApplicant_photo("NA"); + System.out.println(ex); + + } + model.addAttribute("pets", petRegisters); +// model.addAttribute("petID", petRegisters.get(0).getApplicant_photo()); + + return "acknowledged"; + } +} diff --git a/src/main/java/com/okayjava/html/controller/IndexController.java b/src/main/java/com/okayjava/html/controller/IndexController.java new file mode 100644 index 0000000..31bb5ab --- /dev/null +++ b/src/main/java/com/okayjava/html/controller/IndexController.java @@ -0,0 +1,201 @@ +package com.okayjava.html.controller; +import java.time.format.DateTimeFormatter; +import java.time.LocalDateTime; + +import com.okayjava.html.utils.imageCompress; +import com.okayjava.html.Repository.PetRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.ui.ModelMap; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; +import com.okayjava.html.Service.PetRegisterService; + +import com.okayjava.html.model.PetRegister; +import com.okayjava.html.Entity.PetRegisterEntity; +import org.springframework.web.multipart.MaxUploadSizeExceededException; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.time.Instant; +import java.util.Base64; +import java.util.List; + +@Controller +public class IndexController { + + @Autowired + private JdbcTemplate jdbcTemplate; + private PetRepository petRepository; + @GetMapping("/index") + public String index() { + + return "index"; + } + + @GetMapping("/GetRegisteredPetdetails") + public String getRegisteredPetdetails(ModelMap model){ + List petRegisters = jdbcTemplate.query("select * from petregister ", (rs, rowNum) -> { + PetRegister petRegister = new PetRegister(rs.getString("petID"), rs.getString("zone"), + rs.getString("division"), rs.getString("title"), rs.getString("fname"), + rs.getString("doornumber"), rs.getString("street"), rs.getString("area"), rs.getString("city"), rs.getString("phone"), + rs.getString("pincode"), rs.getString("state"), rs.getString("email"), rs.getString("pancardnumber"), + rs.getString("aadhar"), rs.getString("votercard"), rs.getString("previouslicense"), rs.getString("petname"), + rs.getString("species"), rs.getString("identificationmark"), rs.getString("breed"), rs.getString("petcolor"), + rs.getString("gender"), rs.getString("Veterinary_Consultant"), rs.getString("TNVCNo"), + rs.getString("Ageyears"), rs.getString("months"), rs.getString("ARVdate"), rs.getString("Lastdate"), rs.getString("sterilization"), + rs.getString("adopted"), rs.getString("id"), rs.getBytes("applicant_photo"), + rs.getBytes("address_proof_photo"), rs.getBytes("vaccination_certificate_photo"), + rs.getBytes("pet_photo"), rs.getString("comments"), rs.getString("status"), + rs.getString("paymentid")); + +// System.out.println(petRegister); + + return petRegister; + }); + System.out.println(petRegisters); + model.addAttribute("pets", petRegisters); + + return "welcome"; + } + + @ExceptionHandler(MaxUploadSizeExceededException.class) + @RequestMapping("/register") + public String userRegistration(@ModelAttribute PetRegister pet, Model model, + @RequestParam("applicantPhoto") MultipartFile applicantPhotoFile, + @RequestParam("addressProofPhoto") MultipartFile addressProofPhotoFile, + @RequestParam("petPhoto") MultipartFile petPhotoFile, + @RequestParam("vaccinationCertificatePhoto") MultipartFile vaccinationCertificatePhotoFile) + throws IOException { + try { + + System.out.println(pet.toString()); + // validate +// System.out.println(pet.getFname()); +// System.out.println(pet.getEmail()); +// System.out.println(pet.getAadhar()); +// System.out.println(pet.getPan()); +// System.out.println(pet.getAdopted()); +// System.out.println(pet.getAgeyears()); +// System.out.println(pet.getARVdate()); +// System.out.println(pet.getAntiRabies_vaccination()); +// System.out.println(pet.getLastdate()); +// System.out.println(pet.getArea()); +// System.out.println(pet.getBreed()); +// System.out.println(pet.getCity()); +// System.out.println(pet.getDivision()); +// System.out.println(pet.getDoornumber()); +// System.out.println(pet.getIdentificationmark()); +// System.out.println(pet.getPetcolor()); +// System.out.println(pet.getPreviouslicense()); +// System.out.println(pet.getSpecies()); +// System.out.println(pet.getSterilization()); +// System.out.println(pet.getVeterinaryConsultant()); +// System.out.println(pet.getTNVCNo()); +// System.out.println(pet.getTitle()); +// System.out.println(pet.getStreet()); +// System.out.println(pet.getPincode()); + System.out.println(pet.getPetID()); + + model.addAttribute("firstname", pet.getFname()); + model.addAttribute("email", pet.getEmail()); + model.addAttribute("aadhar", pet.getAadhar()); + model.addAttribute("pan", pet.getPan()); + model.addAttribute("adopted", pet.getAdopted()); + model.addAttribute("AntiRabies_vaccination", pet.getAntiRabies_vaccination()); + model.addAttribute("ageyears", pet.getAgeyears()); + model.addAttribute("ARVdate", pet.getARVdate()); + model.addAttribute("Lastdate", pet.getLastdate()); + model.addAttribute("area", pet.getArea()); + model.addAttribute("breed", pet.getBreed()); + model.addAttribute("city", pet.getCity()); + model.addAttribute("division", pet.getDivision()); + model.addAttribute("doornumber", pet.getDoornumber()); + model.addAttribute("identificationmark", pet.getIdentificationmark()); + model.addAttribute("petcolour", pet.getPetcolor()); + model.addAttribute("previouslicense", pet.getPreviouslicense()); + model.addAttribute("species", pet.getSpecies()); + model.addAttribute("sterilization", pet.getSterilization()); + model.addAttribute("veterinaryconsultant", pet.getVeterinaryConsultant()); + model.addAttribute("TNVCNo", pet.getTNVCNo()); + model.addAttribute("title", pet.getTitle()); + model.addAttribute("street", pet.getStreet()); + model.addAttribute("pincode", pet.getPincode()); + model.addAttribute("state", pet.getPetID()); + long id = Instant.now().toEpochMilli(); + + String sql = "INSERT INTO petregister (Id, petID, zone, division, title," + + "fname, doornumber, street, area, city, phone," + + "pincode, state, email, pancardnumber, aadhar, votercard, previouslicense," + + "petname, species, identificationmark, breed, petcolor, gender, veterinary_consultant," + + "tnvcno, ageyears, months, arvdate, lastdate, sterilization, adopted, applicant_photo, " + + "address_proof_photo, vaccination_certificate_photo, pet_photo, comments) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + jdbcTemplate.update(sql, id, "PetReg_" + String.valueOf(id), pet.getZone(), + pet.getDivision(), pet.getTitle(), pet.getFname(), + pet.getDoornumber(), pet.getStreet(), pet.getArea(), pet.getCity(), pet.getPhone(), + pet.getPincode(), pet.getState(), pet.getEmail(), pet.getPancardnumber(), + pet.getAadhar(), pet.getVotercard(), pet.getPreviouslicense(), pet.getPetname(), + pet.getSpecies(), pet.getIdentificationmark(), pet.getBreed(), pet.getPetcolor(), + pet.getGender(), pet.getVeterinaryConsultant(), pet.getTNVCNo(), + pet.getAgeyears(), pet.getMonths(), pet.getARVdate(), pet.getLastdate(), pet.getSterilization(), + pet.getAdopted(), imageCompress.compressImage(applicantPhotoFile.getBytes()), + imageCompress.compressImage(addressProofPhotoFile.getBytes()), + imageCompress.compressImage(petPhotoFile.getBytes()), + imageCompress.compressImage(vaccinationCertificatePhotoFile.getBytes()), "NA"); + + System.out.println("bytes"); + System.out.println(imageCompress.compressImage(applicantPhotoFile.getBytes())); + List petRegisters = jdbcTemplate.query("select * from petregister where paymentid is null", (rs, rowNum) -> { + PetRegister petRegister = new PetRegister(rs.getString("petID"), rs.getString("zone"), + rs.getString("division"), rs.getString("title"), rs.getString("fname"), + rs.getString("doornumber"), rs.getString("street"), rs.getString("area"), rs.getString("city"), rs.getString("phone"), + rs.getString("pincode"), rs.getString("state"), rs.getString("email"), rs.getString("pancardnumber"), + rs.getString("aadhar"), rs.getString("votercard"), rs.getString("previouslicense"), rs.getString("petname"), + rs.getString("species"), rs.getString("identificationmark"), rs.getString("breed"), rs.getString("petcolor"), + rs.getString("gender"), rs.getString("Veterinary_Consultant"), rs.getString("TNVCNo"), + rs.getString("Ageyears"), rs.getString("months"), rs.getString("ARVdate"), rs.getString("Lastdate"), rs.getString("sterilization"), + rs.getString("adopted"), rs.getString("id"), rs.getBytes("applicant_photo"), + rs.getBytes("address_proof_photo"), rs.getBytes("vaccination_certificate_photo"), + rs.getBytes("pet_photo"), rs.getString("comments"), rs.getString("status"), + rs.getString("paymentid")); + +// System.out.println(petRegister); + + return petRegister; + }); + System.out.println(petRegisters); + model.addAttribute("pets", petRegisters); + +// petRepository.save(new PetRegisterEntity(1,"test",pet.getZone(), +// pet.getDivision(),pet.getTitle(), pet.getFname(), +// pet.getDoornumber(), pet.getStreet(), pet.getArea(), pet.getCity(), pet.getPhone(), +// pet.getPincode(), pet.getState(), pet.getEmail(), pet.getPancardnumber(), +// pet.getAadhar(), pet.getVotercard(), pet.getPreviouslicense(), pet.getPetname(), +// pet.getSpecies(), pet.getIdentificationmark(), pet.getBreed(), pet.getPetcolor(), +// pet.getGender(), pet.getVeterinaryConsultant(), pet.getTNVCNo(), +// pet.getAgeyears(), pet.getMonths(), pet.getARVdate(), pet.getLastdate(), pet.getSterilization(), pet.getAntiRabies_vaccination(), +// pet.getAdopted())); +// try { + +// String fileName = StringUtils.cleanPath(applicantPhotoFile.getOriginalFilename()); +// if(fileName.contains("..")) +// { +// System.out.println("not a a valid applicantPhoto File"); +// } +// System.out.println(applicantPhotoFile.getOriginalFilename()); +// System.out.println(applicantPhotoFile.getContentType()); +// System.out.println(applicantPhotoFile.getSize()); +// System.out.println(Base64.getEncoder().encodeToString(applicantPhotoFile.getBytes())); +// } catch (IOException e) { +// e.printStackTrace(); +// } + } + catch (Exception ex){ + System.out.println(ex); + } + return "welcome"; + } +} diff --git a/src/main/java/com/okayjava/html/exceptions/CustomExceptions.java b/src/main/java/com/okayjava/html/exceptions/CustomExceptions.java new file mode 100644 index 0000000..951b029 --- /dev/null +++ b/src/main/java/com/okayjava/html/exceptions/CustomExceptions.java @@ -0,0 +1,7 @@ +package com.okayjava.html.exceptions; + +public class CustomExceptions extends Exception{ + public CustomExceptions(){ + super("Pet Exceptions"); + } +} diff --git a/src/main/java/com/okayjava/html/exceptions/ExceptionHAndlers.java b/src/main/java/com/okayjava/html/exceptions/ExceptionHAndlers.java new file mode 100644 index 0000000..2a73c6a --- /dev/null +++ b/src/main/java/com/okayjava/html/exceptions/ExceptionHAndlers.java @@ -0,0 +1,15 @@ +package com.okayjava.html.exceptions; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.multipart.MaxUploadSizeExceededException; + +@ControllerAdvice +public class ExceptionHAndlers { + @ExceptionHandler(MaxUploadSizeExceededException.class) + public ResponseEntity PetMessage(MaxUploadSizeExceededException exp){ + return new ResponseEntity<>(exp.getMessage(), HttpStatus.INSUFFICIENT_STORAGE); + } +} diff --git a/src/main/java/com/okayjava/html/model/Customer.java b/src/main/java/com/okayjava/html/model/Customer.java new file mode 100644 index 0000000..6f9a454 --- /dev/null +++ b/src/main/java/com/okayjava/html/model/Customer.java @@ -0,0 +1,38 @@ +package com.okayjava.html.model; + +public class Customer { + + private String customerName; + private String email; + private String phoneNumber; + private String amount; + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + public String getPhoneNumber() { + return phoneNumber; + } + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + public String getAmount() { + return amount; + } + public void setAmount(String amount) { + this.amount = amount; + } + public String getCustomerName() { + return customerName; + } + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + + + + +} diff --git a/src/main/java/com/okayjava/html/model/PetRegister.java b/src/main/java/com/okayjava/html/model/PetRegister.java new file mode 100644 index 0000000..0da97ef --- /dev/null +++ b/src/main/java/com/okayjava/html/model/PetRegister.java @@ -0,0 +1,527 @@ +package com.okayjava.html.model; + +import org.springframework.web.multipart.MultipartFile; + +public class PetRegister { + +// private MultipartFile applicantPhoto; + + public String getPaymentid() { + return paymentid; + } + + public void setPaymentid(String paymentid) { + this.paymentid = paymentid; + } + + private String paymentid; + + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments = comments; + } + + private String comments; + + private String name; + + private byte[] addressProofPhoto_bytes; + + + public byte[] getAddressProofPhoto_bytes() { + return addressProofPhoto_bytes; + } + + public void setAddressProofPhoto_bytes(byte[] addressProofPhoto_bytes) { + this.addressProofPhoto_bytes = addressProofPhoto_bytes; + } + + public byte[] getPetPhoto_bytes() { + return petPhoto_bytes; + } + + public void setPetPhoto_bytes(byte[] petPhoto_bytes) { + this.petPhoto_bytes = petPhoto_bytes; + } + + public byte[] getVaccinationCertificatePhoto_bytes() { + return vaccinationCertificatePhoto_bytes; + } + + public void setVaccinationCertificatePhoto_bytes(byte[] vaccinationCertificatePhoto_bytes) { + this.vaccinationCertificatePhoto_bytes = vaccinationCertificatePhoto_bytes; + } + + private byte[] petPhoto_bytes; + private byte[] vaccinationCertificatePhoto_bytes; + + public byte[] getApplicant_photo_bytes() { + return applicant_photo_bytes; + } + + public void setApplicant_photo_bytes(byte[] applicant_photo_bytes) { + this.applicant_photo_bytes = applicant_photo_bytes; + } + private String address_proof_photo; + + private String pet_photo; + + public String getAddress_proof_photo() { + return address_proof_photo; + } + + public void setAddress_proof_photo(String address_proof_photo) { + this.address_proof_photo = address_proof_photo; + } + + public String getPet_photo() { + return pet_photo; + } + + public void setPet_photo(String pet_photo) { + this.pet_photo = pet_photo; + } + + public String getVaccination_certificate_photo() { + return vaccination_certificate_photo; + } + + public void setVaccination_certificate_photo(String vaccination_certificate_photo) { + this.vaccination_certificate_photo = vaccination_certificate_photo; + } + + private String vaccination_certificate_photo; + + + public String getApplicant_photo() { + return applicant_photo; + } + private byte[] applicant_photo_bytes; + public void setApplicant_photo(String applicant_photo) { + this.applicant_photo = applicant_photo; + } + + private String applicant_photo; + private String petID; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + public String getPetID() { + return petID; + } + + public void setPetID(String petID) { + this.petID = petID; + } + + private String zone; + private String division; + private String title; + private String fname; + private String doornumber; + + private String street; + private String area; + private String city; + private String phone; + private String pincode; + + private String state; + + + private String email; + private String pancardnumber; + + private String aadhar; + + private String votercard; + private String previouslicense; + + private String petname; + + private String species; + + private String identificationmark; + + private String breed; + + private String petcolor; + + private String gender; + + private String VeterinaryConsultant; + + private String TNVCNo; + + public String getAgeyears() { + return Ageyears; + } + + public String getDivision() { + return division; + } + + public void setDivision(String division) { + this.division = division; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDoornumber() { + return doornumber; + } + + public void setDoornumber(String doornumber) { + this.doornumber = doornumber; + } + + public String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street = street; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPincode() { + return pincode; + } + + public void setPincode(String pincode) { + this.pincode = pincode; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getPancardnumber() { + return pancardnumber; + } + + public void setPancardnumber(String pancardnumber) { + this.pancardnumber = pancardnumber; + } + + public String getAadhar() { + return aadhar; + } + + public void setAadhar(String aadhar) { + this.aadhar = aadhar; + } + + public String getVotercard() { + return votercard; + } + + public void setVotercard(String votercard) { + this.votercard = votercard; + } + + public String getPreviouslicense() { + return previouslicense; + } + + public void setPreviouslicense(String previouslicense) { + this.previouslicense = previouslicense; + } + + public String getPetname() { + return petname; + } + + public void setPetname(String petname) { + this.petname = petname; + } + + public String getSpecies() { + return species; + } + + public void setSpecies(String species) { + this.species = species; + } + + public String getIdentificationmark() { + return identificationmark; + } + + public void setIdentificationmark(String identificationmark) { + this.identificationmark = identificationmark; + } + + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + public String getPetcolor() { + return petcolor; + } + + public void setPetcolor(String petcolor) { + this.petcolor = petcolor; + } + + public String getVeterinaryConsultant() { + return VeterinaryConsultant; + } + + public void setVeterinaryConsultant(String veterinaryConsultant) { + VeterinaryConsultant = veterinaryConsultant; + } + + public String getSterilization() { + return sterilization; + } + + public void setSterilization(String sterilization) { + this.sterilization = sterilization; + } + + public void setAgeyears(String ageyears) { + Ageyears = ageyears; + } + + private String Ageyears; + + public String getMonths() { + return Months; + } + + public void setMonths(String months) { + Months = months; + } + + private String Months; + + public String getARVdate() { + return ARVdate; + } + + public void setARVdate(String ARVdate) { + this.ARVdate = ARVdate; + } + + private String ARVdate; + + public String getLastdate() { + return Lastdate; + } + + public void setLastdate(String Lastdate) { + this.Lastdate = Lastdate; + } + + private String Lastdate; + + private String sterilization; + + private String adopted; + private String AntiRabies_vaccination; + + private String months; + + + public String getZone() { + return zone; + } + + public void setZone(String zone) { + this.zone = zone; + } + + public String getPan() { + return pancardnumber; + } + public void setPan(String pancardnumber) { + this.pancardnumber = pancardnumber; + } + + public String getFname() { + return fname; + } + public void setFname(String fname) { + this.fname = fname; + } + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + public String getTNVCNo() { + return TNVCNo; + } + public void setTNVCNo(String TNVCNo) { + this.TNVCNo = TNVCNo; + } + private String status; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getGender() { + return gender; + } + public void setGender(String gender) { + this.gender = gender; + } + public String getAdopted() { + return adopted; + } + public void setAdopted(String adopted) { + this.adopted = adopted; + } + + public String getAntiRabies_vaccination() { + return AntiRabies_vaccination; + } + public void setAntiRabies_vaccination(String AntiRabies_vaccination){ + this.AntiRabies_vaccination = AntiRabies_vaccination; + } + + public PetRegister(String petID, String zone, String division, String title, String fname, + String doornumber, String street, String area, + String city, String phone, String pincode, String state, String email, + String pancardnumber, String aadhar, String votercard, String previouslicense, + String petname, String species, String identificationmark, String breed, + String petcolor, String gender, String veterinaryConsultant, String TNVCNo, + String ageyears, String months, String ARVdate, String Lastdate, + String sterilization, String adopted, String name, byte[] applicant_photo, + byte[] addressProofPhoto_bytes, byte[] vaccinationCertificatePhoto_bytes, + byte[] petPhoto_bytes, String comments, String status, String paymentid) { + + setPaymentid(paymentid); + setStatus(status); + setComments(comments); + setApplicant_photo_bytes(applicant_photo); + setAddressProofPhoto_bytes(addressProofPhoto_bytes); + setVaccinationCertificatePhoto_bytes(vaccinationCertificatePhoto_bytes); + setPetPhoto_bytes(petPhoto_bytes); + setApplicant_photo_bytes(applicant_photo); + setZone(zone); + setDivision(division); + setTitle(title); + setFname(fname); + setDoornumber(doornumber); + setStreet(street); + setArea(area); + setCity(city); + setPhone(phone); + setPincode(pincode); + setState(state); + setEmail(email); + setPancardnumber(pancardnumber); + setAadhar(aadhar); + setVotercard(votercard); + setPreviouslicense(previouslicense); + setPetname(petname); + setSpecies(species); + setIdentificationmark(identificationmark); + setBreed(breed); + this.petcolor = petcolor; + this.gender = gender; + this.VeterinaryConsultant = veterinaryConsultant; + this.TNVCNo = TNVCNo; + this.Ageyears = ageyears; + this.Months = months; + this.ARVdate = ARVdate; + this.Lastdate = Lastdate; + this.sterilization = sterilization; + this.adopted = adopted; +// this.AntiRabies_vaccination = AntiRabies_vaccination; + this.petID = petID; + this.name = name; + } + + @Override + public String toString() { + return "PetRegister [zone= " + zone +", " + + "division= " + division +", " + + "title= " + title +", " + + "fname= " + fname + ", " + + "doornumber= " + doornumber +", " + + "street= " + street +", " + + "area= " + area +", " + + "city= " + city +", " + + "phone= " + phone +", " + + "pincode= " + pincode +", " + + "state= " + state +", " + + "email= " + email + ", " + + "pancardnumber= " + pancardnumber +", " + + "aadhar= " + aadhar +", " + + "votercard= " + votercard +", " + + "previouslicense= " + previouslicense +", " + + "petname= " + petname +", " + + "species= " + species +", " + + "identificationmark= " + identificationmark +", " + + "breed= " + breed +", " + + "petcolor= " + petcolor +", " + + "gender= " + gender +", " + + "VeterinaryConsultant= " + VeterinaryConsultant +", " + + "TNVCNo= " + TNVCNo +", " + + "Ageyears= " + Ageyears +", " + + "AgeMonths= " + Months +", " + + "AgeMonths= " + ARVdate +", " + + "AgeMonths= " + Lastdate +", " + + "AgeMonths= " + sterilization +", " + + + "adopted= " + adopted + ", " + + "AntiRabies_vaccination= " + AntiRabies_vaccination + "]"; + } + + + +} diff --git a/src/main/java/com/okayjava/html/model/RazorPay.java b/src/main/java/com/okayjava/html/model/RazorPay.java new file mode 100644 index 0000000..c3bd168 --- /dev/null +++ b/src/main/java/com/okayjava/html/model/RazorPay.java @@ -0,0 +1,147 @@ +package com.okayjava.html.model; + + +/** + * + * + * wrapper for RazorPay payment + * + * + */ + +public class RazorPay { + + + private String applicationFee; + + private String razorpayOrderId; + + private String secretKey; + + private String paymentId; + + private String notes; + + private String imageURL; + + private String theme; + + private String merchantName; + + private String purchaseDescription; + + private String customerName; + + private String customerEmail; + + private String customerContact; + + public RazorPay() { + + } + + public RazorPay(String applicationFee) { + this.applicationFee = applicationFee; + } + + public String getApplicationFee() { + return applicationFee; + } + + public void setApplicationFee(String applicationFee) { + this.applicationFee = applicationFee; + } + + public String getRazorpayOrderId() { + return razorpayOrderId; + } + + public void setRazorpayOrderId(String razorpayOrderId) { + this.razorpayOrderId = razorpayOrderId; + } + + public String getSecretKey() { + return secretKey; + } + + public void setSecretKey(String secretKey) { + this.secretKey = secretKey; + } + + public String getMerchantName() { + return merchantName; + } + + public void setMerchantName(String merchantName) { + this.merchantName = merchantName; + } + + public String getPurchaseDescription() { + return purchaseDescription; + } + + public void setPurchaseDescription(String purchaseDescription) { + this.purchaseDescription = purchaseDescription; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getCustomerEmail() { + return customerEmail; + } + + public void setCustomerEmail(String customerEmail) { + this.customerEmail = customerEmail; + } + + public String getCustomerContact() { + return customerContact; + } + + public void setCustomerContact(String customerContact) { + this.customerContact = customerContact; + } + + public String getPaymentId() { + return paymentId; + } + + public void setPaymentId(String paymentId) { + this.paymentId = paymentId; + } + + public String getNotes() { + return notes; + } + + public void setNotes(String notes) { + this.notes = notes; + } + + public String getImageURL() { + return imageURL; + } + + public void setImageURL(String imageURL) { + this.imageURL = imageURL; + } + + public String getTheme() { + return theme; + } + + public void setTheme(String theme) { + this.theme = theme; + } + + + + +} + diff --git a/src/main/java/com/okayjava/html/model/Response.java b/src/main/java/com/okayjava/html/model/Response.java new file mode 100644 index 0000000..8c08415 --- /dev/null +++ b/src/main/java/com/okayjava/html/model/Response.java @@ -0,0 +1,24 @@ +package com.okayjava.html.model; + +public class Response { + + private int statusCode; + private RazorPay razorPay; + + public int getStatusCode() { + return statusCode; + } + public void setStatusCode(int statusCode) { + this.statusCode = statusCode; + } + public RazorPay getRazorPay() { + return razorPay; + } + + public void setRazorPay(RazorPay razorPay) { + this.razorPay = razorPay; + } + + + +} diff --git a/src/main/java/com/okayjava/html/model/payments.java b/src/main/java/com/okayjava/html/model/payments.java new file mode 100644 index 0000000..78fd757 --- /dev/null +++ b/src/main/java/com/okayjava/html/model/payments.java @@ -0,0 +1,23 @@ +package com.okayjava.html.model; + +public class payments { + + private String paymentid; + + public String getPetsID() { + return petsID; + } + + public void setPetsID(String petsID) { + this.petsID = petsID; + } + + private String petsID; + public String getPaymentid() { + return paymentid; + } + + public void setPaymentid(String paymentid) { + this.paymentid = paymentid; + } +} diff --git a/src/main/java/com/okayjava/html/utils/imageCompress.java b/src/main/java/com/okayjava/html/utils/imageCompress.java new file mode 100644 index 0000000..58ec1a0 --- /dev/null +++ b/src/main/java/com/okayjava/html/utils/imageCompress.java @@ -0,0 +1,44 @@ +package com.okayjava.html.utils; + +import java.io.ByteArrayOutputStream; +import java.util.zip.Deflater; +import java.util.zip.Inflater; + +public class imageCompress { + public static byte[] compressImage(byte[] data) { + Deflater deflater = new Deflater(); + deflater.setLevel(Deflater.BEST_COMPRESSION); + deflater.setInput(data); + deflater.finish(); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length); + byte[] tmp = new byte[4*1024]; + while (!deflater.finished()) { + int size = deflater.deflate(tmp); + outputStream.write(tmp, 0, size); + } + try { + outputStream.close(); + } catch (Exception ignored) { + } + return outputStream.toByteArray(); + } + + + + public static byte[] decompressImage(byte[] data) { + Inflater inflater = new Inflater(); + inflater.setInput(data); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length); + byte[] tmp = new byte[4*1024]; + try { + while (!inflater.finished()) { + int count = inflater.inflate(tmp); + outputStream.write(tmp, 0, count); + } + outputStream.close(); + } catch (Exception ignored) { + } + return outputStream.toByteArray(); + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..22c0786 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,14 @@ +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.url = jdbc:mysql://localhost:3306/pet +spring.datasource.username = root +spring.datasource.password = Test@1234 +spring.jpa.show-sql = true +spring.jpa.hibernate.ddl-auto = update +spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect +server.port=9191 +spring.servlet.multipart.enabled=true +spring.servlet.multipart.file-size-threshold=5KB +spring.servlet.multipart.max-file-size=2MB +spring.servlet.multipart.max-request-size=10MB + +razoramount = 50 \ No newline at end of file diff --git a/src/main/resources/templates/acknowledged.html b/src/main/resources/templates/acknowledged.html new file mode 100644 index 0000000..5664fa4 --- /dev/null +++ b/src/main/resources/templates/acknowledged.html @@ -0,0 +1,138 @@ + + + + + + + + + acknowledged + + +
+ +
+ + + + +
+
Zone
+
+
+
+
Division
+
+
+
+
Name
+
+
+
+ +
+
Address
+
+
+
+
+
+
+
+
+
Owner details
+
+
+
+
+
+
+
+
+
Pet details
+
+
+
+
+
+
+ +
+ +
+
Veterinary Consultant
+
+
+
+
+
+
+
+
+
+
+ +
+
Applicant Photo
+
+
+ +
+
Applicant Address Proof Photo
+
+
+ +
Pet photo
+
+
+
+ +
+
Rabies Vaccination Certification
+
+
+ +
+
Previous Comments
+
<
+
+ +
+
+ + + +
+ + + +
+ + +
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/head.html b/src/main/resources/templates/head.html new file mode 100644 index 0000000..5f68b82 --- /dev/null +++ b/src/main/resources/templates/head.html @@ -0,0 +1,49 @@ + + + + + + + + + + + Pet Registration + + + + + + + + diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html new file mode 100644 index 0000000..f269df2 --- /dev/null +++ b/src/main/resources/templates/index.html @@ -0,0 +1,688 @@ + + + + + +
+ +
Greater Chennai Corporation
+ +
Public Health Department
+ +
Veterinary Section
+ +
+
Application Form for Pet Animal License Under Section 116 of
+ +
The Chennai City Municipal Corporation Act 1919
+ +
+ + +
+
+
    +
  1. PET OWNER DETAILS /
  2. + உரிமையாளரின் விபரம்: +
    +
      +
      +
    1. + Name of the Owner/ +
      + உரிமையாளரின் பெயர்:* + +
      +
      +
      +
      + + + +
      + +
      +
      + + +
      + +
      +
      + + +
    2. +
      +
    3. + Address / + உரிமையாளரின் வசிப்பிடம்: +
      +
      +
      +
      + + +
      +
      + +
      +
      + +
      +
      +
      + + +
      +
      + +
      +
      +
      +
      +
      + + +
      +
      + +
      +
      +
      +
      +
      + + +
      +
      + + +
      +
      +
      +
      +
      + + +
      +
      + +
      +
      +
      +
        +

        Know Your Zone And Division

        + +
        + + + + + + + + +
        + + +
        +
        +
        + + +
        +
        + + +
        +
        +
        +
        +
        +
        +
        + + +
        +
        + +
        +
        +
        +
        +
        +
        + + +
        +
        + +
        +
        + +
        +
        + +
        +
        + + +
        +
        + +
        +
        +
        +
        +
        + + +
        +
        + +
        +
        +
        +
        +
        +
        + + +
        +
        + +
        +
        +
        + +
        +
        + + +
      + +
      +
      +
    4. +
    + + +
  3. PET DETAILS:
  4. + செல்லப்பிராணியின் விபரம்: +
    +
    +
      +
      +
      + + +
      +
      + +
      +
      +
      +
      +
      + + +
      +
      + + +
      +
      +
      +
      +
      +
      + +
      +
      + +
      +
      +
      +
      +
      +
      +
      + + +
      +
      + +
      +
      +
      +
      +
      + +
      +
      + + +
      +
      + +
      +
      +
      +
      +
      +
      +
      + + +
      +
      + +
      +
      +
      +
      +
      +
      +
      + + +
      +
      + +
      +
      + + +
      +
      + +
      +
      +
      +
      +
      + +
      +
      + + + +
      +
      + + Yes + + + + No +
      +
      + +
      +
      +
      +
      + +
      +
      +
      + + + +
      +
      +
      +
      +
      + + Yes + + + No + +
      +
      + +
      +
      +
      + +
      +
      + + +
      +
      +
      + + + + + + No + +
      + + +
      +
      +
      +
      +
      + +
      +
      + + +
      +
      + + +
      +
      + +
      +
      +
      +
      +
      +
      +
      +
      + + +
      +
      + +
      +
      +
      +
      +
      +
      + + +
      + +
      + Dog: +
      +
      +
      + + + + +
      +
      + + + + +
      +
      + + + +
      +
      + + +

      +
      +
      + + +
      + +
      +
      +
      + + +
      +
      + +

      + +
      +
      + +
      +
      +
      +
      + +
      +
      + +
      +
      +
      +
      +
      + VETERINARY CONSULTANT DETAILS / + சிகிச்சை அளிக்கும் கால்நடை மருத்துவரின் விபரம்: +
      +
      +
      +
      + + +
      +
      + +
      +
      +
      +
      +
      +
      +
      +
      + + +
      +
      + +
      +
      +
      +
      +
      + Attachment Details / + இணைக்கப்பட வேண்டிய விவரங்கள்:* +
      +
      +
      +
      + + +
      +
      + +
      +
      +
      +
      +
      + + +
      +
      + +
      +
      +
      +
      +
      +
      + + +
      +
      + +
      +
      +
      +
      +
      +
      + + +
      +
      + +
      +
      +
    +
+
+
+
+
+ Declaration / + உறுதிமொழி: +
+
+ +
+ +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/navbar.html b/src/main/resources/templates/navbar.html new file mode 100644 index 0000000..eaf8e10 --- /dev/null +++ b/src/main/resources/templates/navbar.html @@ -0,0 +1,31 @@ + + + + +
+ + + + diff --git a/src/main/resources/templates/razorpayment.html b/src/main/resources/templates/razorpayment.html new file mode 100644 index 0000000..8e3e5c5 --- /dev/null +++ b/src/main/resources/templates/razorpayment.html @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + +
+
+ + + + + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + + + + +
+ + +
+
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/welcome.html b/src/main/resources/templates/welcome.html new file mode 100644 index 0000000..9671537 --- /dev/null +++ b/src/main/resources/templates/welcome.html @@ -0,0 +1,123 @@ + + + + + + + + + Pet Registry + + + +
+ +
+ +

Welcome to Pet Registration Acknowledgement

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OperationsStatusPayment IDTitleFirst Namedivisiondoornumberstreetareacityphonepincodestateemailpancardnumberaadharvotercardpreviouslicensepetnamespeciesidentificationmarkbreedpetcolorgenderveterinary_consultanttnvcnoageyearsmonthsarvdateLastdatesterilizationadoptedantirabies_vaccination
+
+
+ + +
+
+
+
+ + \ No newline at end of file diff --git a/src/test/java/com/okayjava/html/SpringbootHtmlApplicationTests.java b/src/test/java/com/okayjava/html/SpringbootHtmlApplicationTests.java new file mode 100644 index 0000000..7e3972d --- /dev/null +++ b/src/test/java/com/okayjava/html/SpringbootHtmlApplicationTests.java @@ -0,0 +1,13 @@ +package com.okayjava.html; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class SpringbootHtmlApplicationTests { + + @Test + void contextLoads() { + } + +}