├── .gitignore
├── MyWallet
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── mywallet
│ │ │ ├── MyWalletApplication.java
│ │ │ ├── controller
│ │ │ ├── BankAccountController.java
│ │ │ ├── BeneficiaryController.java
│ │ │ ├── BillPaymentController.java
│ │ │ ├── LogInController.java
│ │ │ ├── TransactionController.java
│ │ │ └── WalletController.java
│ │ │ ├── exceptions
│ │ │ ├── BankAccountException.java
│ │ │ ├── BeneficiaryException.java
│ │ │ ├── BillPaymentException.java
│ │ │ ├── CustomerException.java
│ │ │ ├── ErrorDetails.java
│ │ │ ├── GlobalException.java
│ │ │ ├── LoginException.java
│ │ │ ├── TransactionException.java
│ │ │ └── WalletException.java
│ │ │ ├── model
│ │ │ ├── BankAccount.java
│ │ │ ├── Beneficiary.java
│ │ │ ├── BillPayment.java
│ │ │ ├── CurrentUserSession.java
│ │ │ ├── Customer.java
│ │ │ ├── Transaction.java
│ │ │ ├── UserLogin.java
│ │ │ ├── Wallet.java
│ │ │ └── dto
│ │ │ │ ├── BankAccountDTO.java
│ │ │ │ ├── BeneficiaryDTO.java
│ │ │ │ └── TransactionDTO.java
│ │ │ ├── repository
│ │ │ ├── BankAccountRepo.java
│ │ │ ├── BeneficiaryRepo.java
│ │ │ ├── BillPaymentRepo.java
│ │ │ ├── CurrentSessionRepo.java
│ │ │ ├── CustomerRepo.java
│ │ │ ├── TransactionRepo.java
│ │ │ └── WalletRepo.java
│ │ │ └── service
│ │ │ ├── BankAccountService.java
│ │ │ ├── BankAccountServiceImpl.java
│ │ │ ├── BeneficiaryService.java
│ │ │ ├── BeneficiaryServiceImpl.java
│ │ │ ├── BillPaymentService.java
│ │ │ ├── BillPaymentServiceImpl.java
│ │ │ ├── LoginService.java
│ │ │ ├── LoginServiceImpl.java
│ │ │ ├── TransactionService.java
│ │ │ ├── TransactionServiceImpl.java
│ │ │ ├── WalletService.java
│ │ │ └── WalletServiceImpl.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── mywallet
│ └── MyWalletApplicationTests.java
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | /.metadata/
2 |
--------------------------------------------------------------------------------
/MyWallet/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/MyWallet/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/abhishek-0713/MyWallet/3c1f8b3c8ffe2abae87fbcb8b10d68cc743ce7ad/MyWallet/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/MyWallet/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/MyWallet/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 | # https://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 | # Maven 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 /usr/local/etc/mavenrc ] ; then
40 | . /usr/local/etc/mavenrc
41 | fi
42 |
43 | if [ -f /etc/mavenrc ] ; then
44 | . /etc/mavenrc
45 | fi
46 |
47 | if [ -f "$HOME/.mavenrc" ] ; then
48 | . "$HOME/.mavenrc"
49 | fi
50 |
51 | fi
52 |
53 | # OS specific support. $var _must_ be set to either true or false.
54 | cygwin=false;
55 | darwin=false;
56 | mingw=false
57 | case "`uname`" in
58 | CYGWIN*) cygwin=true ;;
59 | MINGW*) mingw=true;;
60 | Darwin*) darwin=true
61 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
62 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
63 | if [ -z "$JAVA_HOME" ]; then
64 | if [ -x "/usr/libexec/java_home" ]; then
65 | export JAVA_HOME="`/usr/libexec/java_home`"
66 | else
67 | export JAVA_HOME="/Library/Java/Home"
68 | fi
69 | fi
70 | ;;
71 | esac
72 |
73 | if [ -z "$JAVA_HOME" ] ; then
74 | if [ -r /etc/gentoo-release ] ; then
75 | JAVA_HOME=`java-config --jre-home`
76 | fi
77 | fi
78 |
79 | if [ -z "$M2_HOME" ] ; then
80 | ## resolve links - $0 may be a link to maven's home
81 | PRG="$0"
82 |
83 | # need this for relative symlinks
84 | while [ -h "$PRG" ] ; do
85 | ls=`ls -ld "$PRG"`
86 | link=`expr "$ls" : '.*-> \(.*\)$'`
87 | if expr "$link" : '/.*' > /dev/null; then
88 | PRG="$link"
89 | else
90 | PRG="`dirname "$PRG"`/$link"
91 | fi
92 | done
93 |
94 | saveddir=`pwd`
95 |
96 | M2_HOME=`dirname "$PRG"`/..
97 |
98 | # make it fully qualified
99 | M2_HOME=`cd "$M2_HOME" && pwd`
100 |
101 | cd "$saveddir"
102 | # echo Using m2 at $M2_HOME
103 | fi
104 |
105 | # For Cygwin, ensure paths are in UNIX format before anything is touched
106 | if $cygwin ; then
107 | [ -n "$M2_HOME" ] &&
108 | M2_HOME=`cygpath --unix "$M2_HOME"`
109 | [ -n "$JAVA_HOME" ] &&
110 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
111 | [ -n "$CLASSPATH" ] &&
112 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
113 | fi
114 |
115 | # For Mingw, ensure paths are in UNIX format before anything is touched
116 | if $mingw ; then
117 | [ -n "$M2_HOME" ] &&
118 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
119 | [ -n "$JAVA_HOME" ] &&
120 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
121 | fi
122 |
123 | if [ -z "$JAVA_HOME" ]; then
124 | javaExecutable="`which javac`"
125 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
126 | # readlink(1) is not available as standard on Solaris 10.
127 | readLink=`which readlink`
128 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
129 | if $darwin ; then
130 | javaHome="`dirname \"$javaExecutable\"`"
131 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
132 | else
133 | javaExecutable="`readlink -f \"$javaExecutable\"`"
134 | fi
135 | javaHome="`dirname \"$javaExecutable\"`"
136 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
137 | JAVA_HOME="$javaHome"
138 | export JAVA_HOME
139 | fi
140 | fi
141 | fi
142 |
143 | if [ -z "$JAVACMD" ] ; then
144 | if [ -n "$JAVA_HOME" ] ; then
145 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
146 | # IBM's JDK on AIX uses strange locations for the executables
147 | JAVACMD="$JAVA_HOME/jre/sh/java"
148 | else
149 | JAVACMD="$JAVA_HOME/bin/java"
150 | fi
151 | else
152 | JAVACMD="`\\unset -f command; \\command -v java`"
153 | fi
154 | fi
155 |
156 | if [ ! -x "$JAVACMD" ] ; then
157 | echo "Error: JAVA_HOME is not defined correctly." >&2
158 | echo " We cannot execute $JAVACMD" >&2
159 | exit 1
160 | fi
161 |
162 | if [ -z "$JAVA_HOME" ] ; then
163 | echo "Warning: JAVA_HOME environment variable is not set."
164 | fi
165 |
166 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
167 |
168 | # traverses directory structure from process work directory to filesystem root
169 | # first directory with .mvn subdirectory is considered project base directory
170 | find_maven_basedir() {
171 |
172 | if [ -z "$1" ]
173 | then
174 | echo "Path not specified to find_maven_basedir"
175 | return 1
176 | fi
177 |
178 | basedir="$1"
179 | wdir="$1"
180 | while [ "$wdir" != '/' ] ; do
181 | if [ -d "$wdir"/.mvn ] ; then
182 | basedir=$wdir
183 | break
184 | fi
185 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
186 | if [ -d "${wdir}" ]; then
187 | wdir=`cd "$wdir/.."; pwd`
188 | fi
189 | # end of workaround
190 | done
191 | echo "${basedir}"
192 | }
193 |
194 | # concatenates all lines of a file
195 | concat_lines() {
196 | if [ -f "$1" ]; then
197 | echo "$(tr -s '\n' ' ' < "$1")"
198 | fi
199 | }
200 |
201 | BASE_DIR=`find_maven_basedir "$(pwd)"`
202 | if [ -z "$BASE_DIR" ]; then
203 | exit 1;
204 | fi
205 |
206 | ##########################################################################################
207 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
208 | # This allows using the maven wrapper in projects that prohibit checking in binary data.
209 | ##########################################################################################
210 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
211 | if [ "$MVNW_VERBOSE" = true ]; then
212 | echo "Found .mvn/wrapper/maven-wrapper.jar"
213 | fi
214 | else
215 | if [ "$MVNW_VERBOSE" = true ]; then
216 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
217 | fi
218 | if [ -n "$MVNW_REPOURL" ]; then
219 | jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
220 | else
221 | jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
222 | fi
223 | while IFS="=" read key value; do
224 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
225 | esac
226 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
227 | if [ "$MVNW_VERBOSE" = true ]; then
228 | echo "Downloading from: $jarUrl"
229 | fi
230 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
231 | if $cygwin; then
232 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
233 | fi
234 |
235 | if command -v wget > /dev/null; then
236 | if [ "$MVNW_VERBOSE" = true ]; then
237 | echo "Found wget ... using wget"
238 | fi
239 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
240 | wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
241 | else
242 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
243 | fi
244 | elif command -v curl > /dev/null; then
245 | if [ "$MVNW_VERBOSE" = true ]; then
246 | echo "Found curl ... using curl"
247 | fi
248 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
249 | curl -o "$wrapperJarPath" "$jarUrl" -f
250 | else
251 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
252 | fi
253 |
254 | else
255 | if [ "$MVNW_VERBOSE" = true ]; then
256 | echo "Falling back to using Java to download"
257 | fi
258 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
259 | # For Cygwin, switch paths to Windows format before running javac
260 | if $cygwin; then
261 | javaClass=`cygpath --path --windows "$javaClass"`
262 | fi
263 | if [ -e "$javaClass" ]; then
264 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
265 | if [ "$MVNW_VERBOSE" = true ]; then
266 | echo " - Compiling MavenWrapperDownloader.java ..."
267 | fi
268 | # Compiling the Java class
269 | ("$JAVA_HOME/bin/javac" "$javaClass")
270 | fi
271 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
272 | # Running the downloader
273 | if [ "$MVNW_VERBOSE" = true ]; then
274 | echo " - Running MavenWrapperDownloader.java ..."
275 | fi
276 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
277 | fi
278 | fi
279 | fi
280 | fi
281 | ##########################################################################################
282 | # End of extension
283 | ##########################################################################################
284 |
285 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
286 | if [ "$MVNW_VERBOSE" = true ]; then
287 | echo $MAVEN_PROJECTBASEDIR
288 | fi
289 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
290 |
291 | # For Cygwin, switch paths to Windows format before running java
292 | if $cygwin; then
293 | [ -n "$M2_HOME" ] &&
294 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
295 | [ -n "$JAVA_HOME" ] &&
296 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
297 | [ -n "$CLASSPATH" ] &&
298 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
299 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
300 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
301 | fi
302 |
303 | # Provide a "standardized" way to retrieve the CLI args that will
304 | # work with both Windows and non-Windows executions.
305 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
306 | export MAVEN_CMD_LINE_ARGS
307 |
308 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
309 |
310 | exec "$JAVACMD" \
311 | $MAVEN_OPTS \
312 | $MAVEN_DEBUG_OPTS \
313 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
314 | "-Dmaven.home=${M2_HOME}" \
315 | "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
316 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
317 |
--------------------------------------------------------------------------------
/MyWallet/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 https://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 Maven 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 keystroke 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 set title of command window
39 | title %0
40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
42 |
43 | @REM set %HOME% to equivalent of $HOME
44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45 |
46 | @REM Execute a user defined script before this one
47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
51 | :skipRcPre
52 |
53 | @setlocal
54 |
55 | set ERROR_CODE=0
56 |
57 | @REM To isolate internal variables from possible post scripts, we use another setlocal
58 | @setlocal
59 |
60 | @REM ==== START VALIDATION ====
61 | if not "%JAVA_HOME%" == "" goto OkJHome
62 |
63 | echo.
64 | echo Error: JAVA_HOME not found in your environment. >&2
65 | echo Please set the JAVA_HOME variable in your environment to match the >&2
66 | echo location of your Java installation. >&2
67 | echo.
68 | goto error
69 |
70 | :OkJHome
71 | if exist "%JAVA_HOME%\bin\java.exe" goto init
72 |
73 | echo.
74 | echo Error: JAVA_HOME is set to an invalid directory. >&2
75 | echo JAVA_HOME = "%JAVA_HOME%" >&2
76 | echo Please set the JAVA_HOME variable in your environment to match the >&2
77 | echo location of your Java installation. >&2
78 | echo.
79 | goto error
80 |
81 | @REM ==== END VALIDATION ====
82 |
83 | :init
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 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122 |
123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
124 |
125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127 | )
128 |
129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131 | if exist %WRAPPER_JAR% (
132 | if "%MVNW_VERBOSE%" == "true" (
133 | echo Found %WRAPPER_JAR%
134 | )
135 | ) else (
136 | if not "%MVNW_REPOURL%" == "" (
137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
138 | )
139 | if "%MVNW_VERBOSE%" == "true" (
140 | echo Couldn't find %WRAPPER_JAR%, downloading it ...
141 | echo Downloading from: %DOWNLOAD_URL%
142 | )
143 |
144 | powershell -Command "&{"^
145 | "$webclient = new-object System.Net.WebClient;"^
146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148 | "}"^
149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150 | "}"
151 | if "%MVNW_VERBOSE%" == "true" (
152 | echo Finished downloading %WRAPPER_JAR%
153 | )
154 | )
155 | @REM End of extension
156 |
157 | @REM Provide a "standardized" way to retrieve the CLI args that will
158 | @REM work with both Windows and non-Windows executions.
159 | set MAVEN_CMD_LINE_ARGS=%*
160 |
161 | %MAVEN_JAVA_EXE% ^
162 | %JVM_CONFIG_MAVEN_PROPS% ^
163 | %MAVEN_OPTS% ^
164 | %MAVEN_DEBUG_OPTS% ^
165 | -classpath %WRAPPER_JAR% ^
166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
168 | if ERRORLEVEL 1 goto error
169 | goto end
170 |
171 | :error
172 | set ERROR_CODE=1
173 |
174 | :end
175 | @endlocal & set ERROR_CODE=%ERROR_CODE%
176 |
177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
181 | :skipRcPost
182 |
183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause
185 |
186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
187 |
188 | cmd /C exit /B %ERROR_CODE%
189 |
--------------------------------------------------------------------------------
/MyWallet/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.7.7
9 |
10 |
11 | com.mywallet
12 | MyWallet
13 | 0.0.1-SNAPSHOT
14 | MyWallet
15 | Payment Wallet Application Using Spring Boot
16 |
17 | 17
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-data-jpa
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-starter-validation
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-devtools
36 | runtime
37 | true
38 |
39 |
40 | com.mysql
41 | mysql-connector-j
42 | runtime
43 |
44 |
45 | org.projectlombok
46 | lombok
47 | true
48 |
49 |
50 | org.springframework.boot
51 | spring-boot-starter-test
52 | test
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-starter
57 |
58 |
59 | org.springframework.restdocs
60 | spring-restdocs-mockmvc
61 | test
62 |
63 |
64 |
65 | org.springdoc
66 | springdoc-openapi-ui
67 | 1.6.14
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | org.asciidoctor
76 | asciidoctor-maven-plugin
77 | 1.5.8
78 |
79 |
80 | generate-docs
81 | prepare-package
82 |
83 | process-asciidoc
84 |
85 |
86 | html
87 | book
88 |
89 |
90 |
91 |
92 |
93 | org.springframework.restdocs
94 | spring-restdocs-asciidoctor
95 | ${spring-restdocs.version}
96 |
97 |
98 |
99 |
100 | org.springframework.boot
101 | spring-boot-maven-plugin
102 |
103 |
104 |
105 | org.projectlombok
106 | lombok
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/MyWalletApplication.java:
--------------------------------------------------------------------------------
1 | package com.mywallet;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class MyWalletApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(MyWalletApplication.class, args);
11 | }
12 |
13 |
14 |
15 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/controller/BankAccountController.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.controller;
2 |
3 | import com.mywallet.exceptions.BankAccountException;
4 | import com.mywallet.exceptions.CustomerException;
5 | import com.mywallet.model.BankAccount;
6 | import com.mywallet.model.Wallet;
7 | import com.mywallet.model.dto.BankAccountDTO;
8 | import com.mywallet.service.BankAccountService;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.http.HttpStatus;
11 | import org.springframework.http.ResponseEntity;
12 | import org.springframework.web.bind.annotation.*;
13 |
14 | import javax.validation.Valid;
15 | import java.util.List;
16 | import java.util.Optional;
17 |
18 | @RestController
19 | @RequestMapping("/customer/bankaccount")
20 | public class BankAccountController {
21 |
22 | @Autowired
23 | private BankAccountService bankAccountService;
24 |
25 |
26 | /*--------------------------------------- Add Bank Account Mapping -------------------------------------------*/
27 | @PostMapping("/add")
28 | public ResponseEntity addAccountMapping(@RequestParam String key,@Valid @RequestBody BankAccountDTO bankAccountDTO) throws BankAccountException, CustomerException{
29 |
30 | bankAccountService.addBankAccount(key, bankAccountDTO);
31 |
32 | return new ResponseEntity("Bank Account Added Successfully",HttpStatus.CREATED);
33 |
34 | }
35 |
36 |
37 | /*--------------------------------------- Delete Bank Account Mapping -------------------------------------------*/
38 | @DeleteMapping("/delete")
39 | public ResponseEntity removeAccountMapping(@RequestParam String key,@Valid @RequestBody BankAccountDTO bankAccount) throws BankAccountException, CustomerException{
40 |
41 | return new ResponseEntity<>(bankAccountService.removeBankAccount(key, bankAccount),HttpStatus.OK);
42 | }
43 |
44 |
45 | /*--------------------------------------- View Bank Account Mapping -------------------------------------------*/
46 | @GetMapping("/details")
47 | public ResponseEntity> getBankAccountDetailsMapping(@RequestParam String key, @RequestParam Integer accountNo) throws BankAccountException, CustomerException{
48 |
49 | return new ResponseEntity>(bankAccountService.viewBankAccount(key, accountNo),HttpStatus.OK);
50 |
51 | }
52 |
53 |
54 | /*--------------------------------------- View All Bank Account Mapping -------------------------------------------*/
55 | @GetMapping("/all")
56 | public ResponseEntity> getAllBankAccountMapping(@RequestParam String key) throws BankAccountException, CustomerException{
57 |
58 | return new ResponseEntity>(bankAccountService.viewAllBankAccounts(key),HttpStatus.FOUND);
59 |
60 | }
61 |
62 |
63 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/controller/BeneficiaryController.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.controller;
2 |
3 | import java.util.List;
4 |
5 | import javax.validation.Valid;
6 |
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.http.HttpStatus;
9 | import org.springframework.http.ResponseEntity;
10 | import org.springframework.web.bind.annotation.DeleteMapping;
11 | import org.springframework.web.bind.annotation.GetMapping;
12 | import org.springframework.web.bind.annotation.PostMapping;
13 | import org.springframework.web.bind.annotation.RequestBody;
14 | import org.springframework.web.bind.annotation.RequestMapping;
15 | import org.springframework.web.bind.annotation.RequestParam;
16 | import org.springframework.web.bind.annotation.RestController;
17 |
18 | import com.mywallet.exceptions.BeneficiaryException;
19 | import com.mywallet.exceptions.CustomerException;
20 | import com.mywallet.exceptions.WalletException;
21 | import com.mywallet.model.Beneficiary;
22 | import com.mywallet.model.dto.BeneficiaryDTO;
23 | import com.mywallet.service.BeneficiaryService;
24 |
25 | @RestController
26 | @RequestMapping("/beneficiaries")
27 | public class BeneficiaryController {
28 |
29 | @Autowired
30 | BeneficiaryService beneficiaryService;
31 |
32 |
33 | /*-------------------------------------------- Add Beneficiary Mapping -------------------------------------------------*/
34 | @PostMapping("/add")
35 | public ResponseEntity addBeneneficiaryMapping(@RequestBody Beneficiary beneficiary, @RequestParam String key) throws BeneficiaryException, WalletException, CustomerException {
36 |
37 | return new ResponseEntity(beneficiaryService.addBeneficiary(beneficiary, key),HttpStatus.ACCEPTED);
38 |
39 | }
40 |
41 |
42 | /*-------------------------------------------- View Beneficiary - walletId -------------------------------------------------*/
43 | @GetMapping("/view/walletId")
44 | public ResponseEntity getBeneneficiaryByWalletIdMapping(@RequestParam Integer walletId ,@RequestParam String key) throws BeneficiaryException, CustomerException{
45 |
46 | return new ResponseEntity((Beneficiary) beneficiaryService.findAllByWallet(walletId),HttpStatus.FOUND);
47 |
48 | }
49 |
50 |
51 | /*-------------------------------------------- View Beneficiary - Name -------------------------------------------------*/
52 | @GetMapping("/view/name")
53 | public ResponseEntity getBeneneficiaryByNameMapping(@RequestParam String name,@RequestParam String key) throws BeneficiaryException, CustomerException{
54 |
55 | return new ResponseEntity(beneficiaryService.viewBeneficiary(name,key),HttpStatus.FOUND);
56 |
57 | }
58 |
59 |
60 | /*-------------------------------------------- View All Beneficiary Mapping -------------------------------------------------*/
61 | @GetMapping("/viewall")
62 | public ResponseEntity> getAllBeneneficiaryMapping(@RequestParam String key) throws BeneficiaryException, CustomerException{
63 |
64 | return new ResponseEntity>(beneficiaryService.viewAllBeneficiary(key),HttpStatus.FOUND);
65 |
66 | }
67 |
68 |
69 | /*-------------------------------------------- Delete Beneficiary Mapping -------------------------------------------------*/
70 | @DeleteMapping("/delete")
71 | public ResponseEntity deleteBeneneficiaryMapping(@Valid @RequestBody BeneficiaryDTO beneficiary ,@RequestParam String key) throws BeneficiaryException, CustomerException{
72 |
73 | return new ResponseEntity(beneficiaryService.deleteBeneficiary(key,beneficiary),HttpStatus.OK);
74 |
75 | }
76 |
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/controller/BillPaymentController.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.controller;
2 |
3 | import com.mywallet.exceptions.BillPaymentException;
4 | import com.mywallet.exceptions.CustomerException;
5 | import com.mywallet.exceptions.TransactionException;
6 | import com.mywallet.exceptions.WalletException;
7 | import com.mywallet.service.BillPaymentService;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.http.HttpStatus;
10 | import org.springframework.http.ResponseEntity;
11 | import org.springframework.web.bind.annotation.PostMapping;
12 | import org.springframework.web.bind.annotation.RequestParam;
13 | import org.springframework.web.bind.annotation.RestController;
14 |
15 | import java.time.LocalDate;
16 |
17 | @RestController
18 | public class BillPaymentController {
19 |
20 | @Autowired
21 | private BillPaymentService billPayService;
22 |
23 |
24 | /*-------------------------------------------- Add Bill Payment Mapping -------------------------------------------------*/
25 | @PostMapping("/addBillPayment")
26 | public ResponseEntity addBillPayment(@RequestParam("targetMobile") String targetMobile, @RequestParam("Name") String Name, @RequestParam("amount") double amount, @RequestParam("BillType") String BillType, @RequestParam("key") String key) throws BillPaymentException, WalletException, CustomerException, TransactionException {
27 |
28 | LocalDate date=LocalDate.now();
29 | String output = billPayService.addBillPayment(targetMobile, Name, amount, BillType,date , 0, key);
30 |
31 | return new ResponseEntity(output,HttpStatus.OK);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/controller/LogInController.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.controller;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.http.HttpStatus;
5 | import org.springframework.http.ResponseEntity;
6 | import org.springframework.web.bind.annotation.PostMapping;
7 | import org.springframework.web.bind.annotation.RequestBody;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RequestParam;
10 | import org.springframework.web.bind.annotation.RestController;
11 |
12 | import com.mywallet.exceptions.LoginException;
13 | import com.mywallet.model.UserLogin;
14 | import com.mywallet.service.LoginService;
15 |
16 | @RestController
17 | @RequestMapping("/user")
18 | public class LogInController {
19 |
20 | @Autowired
21 | private LoginService loginService;
22 |
23 | @PostMapping("/login")
24 | public ResponseEntity loginMapping(@RequestBody UserLogin userLogin) throws LoginException{
25 |
26 | String output = loginService.login(userLogin);
27 |
28 | return new ResponseEntity(output,HttpStatus.OK);
29 | }
30 |
31 | @PostMapping("/logout")
32 | public ResponseEntity logoutMapping(@RequestParam String key) throws LoginException{
33 |
34 | String output = loginService.logout(key);
35 |
36 | return new ResponseEntity(output,HttpStatus.OK);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/controller/TransactionController.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.controller;
2 |
3 | import com.mywallet.exceptions.CustomerException;
4 | import com.mywallet.exceptions.TransactionException;
5 | import com.mywallet.exceptions.WalletException;
6 | import com.mywallet.model.Transaction;
7 | import com.mywallet.model.dto.TransactionDTO;
8 | import com.mywallet.service.TransactionService;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.http.HttpStatus;
11 | import org.springframework.http.ResponseEntity;
12 | import org.springframework.web.bind.annotation.*;
13 |
14 | import java.time.LocalDate;
15 | import java.util.ArrayList;
16 | import java.util.List;
17 |
18 | @RestController
19 | @RequestMapping("/transactions")
20 | public class TransactionController {
21 |
22 | @Autowired
23 | private TransactionService transactionService;
24 |
25 |
26 | /*---------------------------------------- Find Transaction - wallet ------------------------------------------*/
27 | @PostMapping("/wallet")
28 | public ResponseEntity> viewByWallet(@RequestParam String key) throws TransactionException, WalletException, CustomerException{
29 |
30 | List transactions= transactionService.findByWallet(key);
31 |
32 | List transactionDTOS = new ArrayList<>();
33 |
34 | for(Transaction t:transactions) {
35 |
36 | TransactionDTO transactionDTO = new TransactionDTO(t.getTransactionId(), t.getTransactionType(), t.getTransactionDate(),t.getAmount(), t.getDescription() );
37 | transactionDTOS.add(transactionDTO);
38 | }
39 | return new ResponseEntity>(transactionDTOS,HttpStatus.OK);
40 | }
41 |
42 |
43 | /*----------------------------------------- Find Transaction - tId ---------------------------------------------*/
44 | @GetMapping("/transactionId")
45 | public ResponseEntity findById(@RequestParam String key, @RequestParam Integer transactionId) throws TransactionException, CustomerException{
46 |
47 | Transaction t = transactionService.findByTransactionId(key,transactionId);
48 | TransactionDTO transactionDTO = new TransactionDTO(t.getTransactionId(), t.getTransactionType(), t.getTransactionDate(),t.getAmount(), t.getDescription() );
49 |
50 |
51 | return new ResponseEntity(transactionDTO, HttpStatus.CREATED);
52 | }
53 |
54 |
55 | /*---------------------------------------- Find Transaction - Type --------------------------------------------*/
56 | @GetMapping("/type")
57 | public ResponseEntity> viewAllTransacationByType(@RequestParam String key, @RequestParam String type) throws TransactionException, CustomerException{
58 |
59 | List transactions = transactionService.findByTransactionType(key,type);
60 |
61 | List transactionDTOS = new ArrayList<>();
62 | for(Transaction t:transactions) {
63 |
64 | TransactionDTO transactionDTO = new TransactionDTO(t.getTransactionId(), t.getTransactionType(), t.getTransactionDate(),t.getAmount(), t.getDescription() );
65 |
66 | transactionDTOS.add(transactionDTO);
67 | }
68 | return new ResponseEntity>(transactionDTOS, HttpStatus.ACCEPTED);
69 |
70 | }
71 |
72 |
73 | /*------------------------------------ View Transaction - Between 2 date ---------------------------------------*/
74 | @GetMapping("/between")
75 | public ResponseEntity> viewByTwoDate(@RequestParam String key, @RequestParam("one") String one, @RequestParam("two") String two) throws TransactionException, CustomerException{
76 |
77 | LocalDate firstDate= LocalDate.parse(one);
78 | LocalDate secondDate = LocalDate.parse(two);
79 | List transactions = transactionService.viewTransactionBetweenDate(key,firstDate, secondDate);
80 |
81 | List transactionDTOS = new ArrayList<>();
82 | for(Transaction t:transactions) {
83 |
84 | TransactionDTO transactionDTO = new TransactionDTO(t.getTransactionId(), t.getTransactionType(), t.getTransactionDate(),t.getAmount(), t.getDescription() );
85 |
86 | transactionDTOS.add(transactionDTO);
87 | }
88 | return new ResponseEntity>(transactionDTOS, HttpStatus.ACCEPTED);
89 |
90 | }
91 |
92 |
93 | /*----------------------------------------- View All Transaction ----------------------------------------------*/
94 | @GetMapping("/all")
95 | public ResponseEntity> viewAllTransactionByAdmin() throws TransactionException{
96 |
97 | List transactions = transactionService.viewAllTransaction();
98 |
99 | List transactionDTOS = new ArrayList<>();
100 |
101 | for(Transaction t:transactions) {
102 | TransactionDTO transactionDTO = new TransactionDTO(t.getTransactionId(), t.getTransactionType(), t.getTransactionDate(),t.getAmount(), t.getDescription() );
103 |
104 | transactionDTOS.add(transactionDTO);
105 | }
106 | return new ResponseEntity>(transactionDTOS, HttpStatus.OK);
107 | }
108 |
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/controller/WalletController.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.controller;
2 |
3 | import javax.validation.Valid;
4 |
5 | import com.mywallet.exceptions.BankAccountException;
6 | import com.mywallet.exceptions.TransactionException;
7 | import com.mywallet.exceptions.WalletException;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.http.HttpStatus;
10 | import org.springframework.http.ResponseEntity;
11 | import org.springframework.web.bind.annotation.*;
12 |
13 | import com.mywallet.exceptions.CustomerException;
14 | import com.mywallet.model.Customer;
15 | import com.mywallet.service.WalletService;
16 |
17 | import java.math.BigDecimal;
18 |
19 | @RestController
20 | @RequestMapping("/mywallet")
21 | public class WalletController {
22 |
23 | @Autowired
24 | public WalletService walletService;
25 |
26 | /*-------------------------------------------- Create Account ------------------------------------------------*/
27 | @PostMapping("/createaccount")
28 | public ResponseEntity createAccount(@Valid @RequestBody Customer customer) throws CustomerException{
29 |
30 | return new ResponseEntity(walletService.createCustomerAccount(customer), HttpStatus.CREATED);
31 | }
32 |
33 |
34 | /*-------------------------------------------- view Balance ------------------------------------------------*/
35 | @GetMapping("/balance")
36 | public ResponseEntity showBalance(@RequestParam String key, @RequestParam String mobileNumber) throws CustomerException{
37 |
38 | return new ResponseEntity(walletService.showBalance(mobileNumber, key), HttpStatus.ACCEPTED);
39 | }
40 |
41 |
42 | /*-------------------------------------------- Update Account ------------------------------------------------*/
43 | @PostMapping("/updateaccount")
44 | public ResponseEntity updateCustomerDetails(@Valid @RequestBody Customer customer, @RequestParam String key) throws CustomerException{
45 |
46 | return new ResponseEntity(walletService.updateAccount(customer,key), HttpStatus.ACCEPTED);
47 | }
48 |
49 |
50 | /*-------------------------------------------- Deposit Money to Wallet ------------------------------------------------*/
51 | @PostMapping("/deposit/wallet")
52 | public ResponseEntity depositToWallet(@RequestParam Integer accountNo, @RequestParam BigDecimal amount, @RequestParam String key) throws BankAccountException, CustomerException, TransactionException, WalletException {
53 |
54 | return new ResponseEntity(walletService.depositAmount(amount, accountNo, key), HttpStatus.OK);
55 | }
56 |
57 |
58 | /*-------------------------------------------- Fund Transfer ------------------------------------------------*/
59 | @PostMapping("/transfer/mobile")
60 | public ResponseEntity fundTransfer(@RequestParam String mobile, @RequestParam String name, @RequestParam BigDecimal amount, @RequestParam String key) throws WalletException, CustomerException, TransactionException{
61 |
62 | return new ResponseEntity(walletService.fundTransfer(mobile, name, amount, key), HttpStatus.OK);
63 | }
64 |
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/exceptions/BankAccountException.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.exceptions;
2 |
3 | public class BankAccountException extends Exception{
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 1L;
9 |
10 | public BankAccountException() {
11 | super();
12 | }
13 |
14 | public BankAccountException(String message) {
15 | super(message);
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/exceptions/BeneficiaryException.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.exceptions;
2 |
3 | public class BeneficiaryException extends Exception {
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 1L;
9 |
10 | public BeneficiaryException() {
11 | super();
12 | }
13 |
14 | public BeneficiaryException(String message) {
15 | super(message);
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/exceptions/BillPaymentException.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.exceptions;
2 |
3 | public class BillPaymentException extends Exception {
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 1L;
9 |
10 | public BillPaymentException() {
11 | super();
12 | }
13 |
14 | public BillPaymentException(String message) {
15 | super(message);
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/exceptions/CustomerException.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.exceptions;
2 |
3 | public class CustomerException extends Exception{
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 1L;
9 |
10 | public CustomerException() {
11 | super();
12 | }
13 |
14 | public CustomerException(String message) {
15 | super(message);
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/exceptions/ErrorDetails.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.exceptions;
2 |
3 | import java.time.LocalDateTime;
4 |
5 | import lombok.AllArgsConstructor;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 | import lombok.ToString;
9 |
10 | @Data
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | @ToString
14 | public class ErrorDetails {
15 |
16 | private LocalDateTime timeStamp;
17 |
18 | private String message ;
19 |
20 | private String description;
21 |
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/exceptions/GlobalException.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.exceptions;
2 |
3 | import java.time.LocalDateTime;
4 |
5 | import org.springframework.http.HttpStatus;
6 | import org.springframework.http.ResponseEntity;
7 | import org.springframework.web.bind.annotation.ControllerAdvice;
8 | import org.springframework.web.bind.annotation.ExceptionHandler;
9 | import org.springframework.web.context.request.WebRequest;
10 |
11 | @ControllerAdvice
12 | public class GlobalException {
13 |
14 | /* -------------------------------------- Login Exception ----------------------------------------------*/
15 |
16 | @ExceptionHandler(LoginException.class)
17 | public ResponseEntity mywalletExceptionHandler(LoginException loginException,WebRequest request){
18 |
19 | ErrorDetails err=new ErrorDetails(LocalDateTime.now(), loginException.getMessage(), request.getDescription(false));
20 |
21 | return new ResponseEntity(err, HttpStatus.BAD_REQUEST);
22 |
23 | }
24 |
25 | /* -------------------------------------- BankAccount Exception ----------------------------------------------*/
26 |
27 | @ExceptionHandler(BankAccountException.class)
28 | public ResponseEntity mywalletExceptionHandler(BankAccountException bankAccountException,WebRequest request){
29 |
30 | ErrorDetails errorDetails = new ErrorDetails(LocalDateTime.now(), bankAccountException.getMessage(), request.getDescription(false));
31 |
32 | return new ResponseEntity(errorDetails, HttpStatus.BAD_REQUEST);
33 | }
34 |
35 |
36 | /* -------------------------------------- Beneficiary Exception ----------------------------------------------*/
37 |
38 | @ExceptionHandler(BeneficiaryException.class)
39 | public ResponseEntity mywalletExceptionHandler(BeneficiaryException beneficiaryException ,WebRequest request){
40 |
41 | ErrorDetails errorDetails = new ErrorDetails(LocalDateTime.now(), beneficiaryException.getMessage(), request.getDescription(false));
42 |
43 | return new ResponseEntity(errorDetails, HttpStatus.BAD_REQUEST);
44 | }
45 |
46 |
47 | /* -------------------------------------- BillPayment Exception ----------------------------------------------*/
48 |
49 | @ExceptionHandler(BillPaymentException.class)
50 | public ResponseEntity mywalletExceptionHandler(BillPaymentException billPaymentException,WebRequest request){
51 |
52 | ErrorDetails errorDetails = new ErrorDetails(LocalDateTime.now(), billPaymentException.getMessage(), request.getDescription(false));
53 |
54 | return new ResponseEntity(errorDetails, HttpStatus.BAD_REQUEST);
55 | }
56 |
57 |
58 | /* -------------------------------------- Customer Exception ----------------------------------------------*/
59 |
60 | @ExceptionHandler(CustomerException.class)
61 | public ResponseEntity mywalletExceptionHandler(CustomerException customerException,WebRequest request){
62 |
63 | ErrorDetails errorDetails = new ErrorDetails(LocalDateTime.now(), customerException.getMessage(), request.getDescription(false));
64 |
65 | return new ResponseEntity(errorDetails, HttpStatus.BAD_REQUEST);
66 | }
67 |
68 | /* -------------------------------------- BankAccount Exception ----------------------------------------------*/
69 |
70 | @ExceptionHandler(TransactionException.class)
71 | public ResponseEntity mywalletExceptionHandler(TransactionException transactionException,WebRequest request){
72 |
73 | ErrorDetails errorDetails = new ErrorDetails(LocalDateTime.now(), transactionException.getMessage(), request.getDescription(false));
74 |
75 | return new ResponseEntity(errorDetails, HttpStatus.BAD_REQUEST);
76 | }
77 |
78 |
79 | /* -------------------------------------- Wallet Exception ----------------------------------------------*/
80 |
81 | @ExceptionHandler(WalletException.class)
82 | public ResponseEntity mywalletExceptionHandler(WalletException walletException,WebRequest request){
83 |
84 | ErrorDetails errorDetails = new ErrorDetails(LocalDateTime.now(), walletException.getMessage(), request.getDescription(false));
85 |
86 | return new ResponseEntity(errorDetails, HttpStatus.BAD_REQUEST);
87 | }
88 |
89 |
90 | /* -------------------------------------- Exception ----------------------------------------------*/
91 |
92 | @ExceptionHandler(Exception.class)
93 | public ResponseEntity mywalletExceptionHandler(Exception exception,WebRequest request){
94 |
95 | ErrorDetails errorDetails = new ErrorDetails(LocalDateTime.now(), exception.getMessage(), request.getDescription(false));
96 |
97 | return new ResponseEntity(errorDetails, HttpStatus.BAD_REQUEST);
98 | }
99 |
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/exceptions/LoginException.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.exceptions;
2 |
3 | public class LoginException extends Exception {
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 1L;
9 |
10 | public LoginException() {
11 | super();
12 | }
13 |
14 | public LoginException(String message) {
15 | super(message);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/exceptions/TransactionException.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.exceptions;
2 |
3 | public class TransactionException extends Exception{
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 1L;
9 |
10 | public TransactionException() {
11 | super();
12 | }
13 |
14 | public TransactionException(String message) {
15 | super(message);
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/exceptions/WalletException.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.exceptions;
2 |
3 | public class WalletException extends Exception{
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 1L;
9 |
10 | public WalletException() {
11 | super();
12 | }
13 |
14 | public WalletException(String message) {
15 | super(message);
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/model/BankAccount.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.model;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | import javax.persistence.CascadeType;
8 | import javax.persistence.Entity;
9 | import javax.persistence.Id;
10 | import javax.persistence.ManyToOne;
11 | import javax.validation.constraints.NotNull;
12 | import javax.validation.constraints.Size;
13 |
14 | @Entity
15 | @AllArgsConstructor
16 | @NoArgsConstructor
17 | @Data
18 | public class BankAccount {
19 |
20 | @Id
21 | @NotNull
22 | private Integer accountNo;
23 |
24 | @NotNull
25 | @Size(min = 5, max = 10,message = "Invalid IFSC Code [ 5-10 Characters only ]")
26 | private String IFSCCode;
27 |
28 | @NotNull
29 | @Size(min = 3, max = 15,message = "Invalid Bank Name [ 3-15 characters only ]")
30 | private String bankName;
31 |
32 | @NotNull
33 | private Double balance;
34 |
35 |
36 | @ManyToOne(cascade= CascadeType.PERSIST)
37 | private Wallet wallet;
38 |
39 |
40 | public BankAccount(@NotNull Integer accountNo, @NotNull String iFSCCode,
41 | @NotNull @Size(min = 4, max = 10, message = "Bank name not valid") String bankName,
42 | @NotNull Double balance) {
43 | super();
44 | this.accountNo = accountNo;
45 | IFSCCode = iFSCCode;
46 | this.bankName = bankName;
47 | this.balance = balance;
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/model/Beneficiary.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.model;
2 |
3 | import javax.persistence.CascadeType;
4 | import javax.persistence.Entity;
5 | import javax.persistence.Id;
6 | import javax.persistence.JoinColumn;
7 | import javax.persistence.ManyToOne;
8 | import javax.validation.constraints.NotNull;
9 | import javax.validation.constraints.Size;
10 |
11 | import lombok.AllArgsConstructor;
12 | import lombok.Data;
13 | import lombok.NoArgsConstructor;
14 |
15 | @Entity
16 | @Data
17 | @NoArgsConstructor
18 | @AllArgsConstructor
19 | public class Beneficiary {
20 |
21 | @Id
22 | @NotNull
23 | @Size(min = 10, max = 10 ,message = "Invalid Mobile Number [ 10 Digit Only ] ")
24 | private String beneficiaryMobileNumber;
25 |
26 | @NotNull
27 | @Size(min = 3, message = "Invalid Beneficiary name [ contains at least 3 characters ]")
28 | private String beneficiaryName;
29 |
30 |
31 | @ManyToOne(cascade = CascadeType.PERSIST)
32 | @JoinColumn(name = "walletId" ,referencedColumnName = "walletId")
33 | private Wallet wallet;
34 |
35 | public Beneficiary(String beneficiaryMobileNumber, String beneficiaryName) {
36 | this.beneficiaryMobileNumber = beneficiaryMobileNumber;
37 | this.beneficiaryName = beneficiaryName;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/model/BillPayment.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.model;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | import javax.persistence.*;
8 | import java.time.LocalDate;
9 |
10 | @Entity
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | @Data
14 | public class BillPayment {
15 |
16 | @Id
17 | @GeneratedValue(strategy = GenerationType.AUTO)
18 | private Integer billId;
19 |
20 | private Double amount;
21 |
22 | private String billType;
23 |
24 | private LocalDate billPaymentDate;
25 |
26 | @ManyToOne(cascade = CascadeType.ALL)
27 | private Wallet wallet;
28 |
29 |
30 | public BillPayment(Double amount, String billType, LocalDate billPaymentDate) {
31 | this.amount = amount;
32 | this.billType = billType;
33 | this.billPaymentDate = billPaymentDate;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/model/CurrentUserSession.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.model;
2 |
3 | import java.time.LocalDateTime;
4 |
5 | import javax.persistence.Column;
6 | import javax.persistence.Entity;
7 | import javax.persistence.Id;
8 |
9 | import lombok.AllArgsConstructor;
10 | import lombok.Data;
11 | import lombok.NoArgsConstructor;
12 |
13 | @Entity
14 | @Data
15 | @NoArgsConstructor
16 | @AllArgsConstructor
17 | public class CurrentUserSession {
18 |
19 | @Id
20 | @Column(unique = true)
21 | private Integer userId;
22 |
23 | private String uuid;
24 |
25 | private LocalDateTime localDateTime;
26 |
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/model/Customer.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.model;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.GenerationType;
6 | import javax.persistence.Id;
7 | import javax.validation.constraints.NotNull;
8 | import javax.validation.constraints.Size;
9 |
10 | import lombok.AllArgsConstructor;
11 | import lombok.Data;
12 | import lombok.NoArgsConstructor;
13 |
14 | @Entity
15 | @Data
16 | @NoArgsConstructor
17 | @AllArgsConstructor
18 | public class Customer {
19 |
20 | @Id
21 | @GeneratedValue(strategy =GenerationType.AUTO)
22 | private Integer customerId;
23 |
24 | @NotNull
25 | @Size(min = 3, message = "Invalid Customer name [ cotains at least 3 characters ]")
26 | private String customerName;
27 |
28 | @NotNull
29 | @Size(min = 10, max = 10 ,message = "Invalid Mobile Number [ 10 Digit Only ] ")
30 | private String mobileNumber;
31 |
32 | @NotNull
33 | @Size(min = 6, max = 12, message = "Invalid Password [ must be 6 to 8 characters ]")
34 | private String password;
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/model/Transaction.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.model;
2 |
3 | import java.time.LocalDate;
4 |
5 | import javax.persistence.CascadeType;
6 | import javax.persistence.Entity;
7 | import javax.persistence.GeneratedValue;
8 | import javax.persistence.GenerationType;
9 | import javax.persistence.Id;
10 | import javax.persistence.ManyToOne;
11 |
12 | import lombok.AllArgsConstructor;
13 | import lombok.Data;
14 | import lombok.NoArgsConstructor;
15 |
16 | @Entity
17 | @Data
18 | @NoArgsConstructor
19 | @AllArgsConstructor
20 | public class Transaction {
21 |
22 | @Id
23 | @GeneratedValue(strategy = GenerationType.IDENTITY)
24 | private Integer transactionId;
25 |
26 | private String transactionType;
27 |
28 | private LocalDate transactionDate;
29 |
30 | private double amount;
31 |
32 | private String Description;
33 |
34 |
35 | @ManyToOne(cascade = CascadeType.ALL)
36 | private Wallet wallet;
37 |
38 | public Transaction(String transactionType, LocalDate transactionDate, double amount, String description) {
39 | this.transactionType = transactionType;
40 | this.transactionDate = transactionDate;
41 | this.amount = amount;
42 | Description = description;
43 | }
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/model/UserLogin.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.model;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | @Data
8 | @NoArgsConstructor
9 | @AllArgsConstructor
10 | public class UserLogin {
11 |
12 | private String mobileNumber;
13 |
14 | private String password;
15 |
16 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/model/Wallet.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.model;
2 |
3 | import java.math.BigDecimal;
4 |
5 | import javax.persistence.CascadeType;
6 | import javax.persistence.Entity;
7 | import javax.persistence.GeneratedValue;
8 | import javax.persistence.GenerationType;
9 | import javax.persistence.Id;
10 | import javax.persistence.JoinColumn;
11 | import javax.persistence.OneToOne;
12 |
13 | import lombok.AllArgsConstructor;
14 | import lombok.Data;
15 | import lombok.NoArgsConstructor;
16 |
17 | @Entity
18 | @Data
19 | @NoArgsConstructor
20 | @AllArgsConstructor
21 | public class Wallet {
22 |
23 | @Id
24 | @GeneratedValue(strategy = GenerationType.AUTO)
25 | private Integer walletId;
26 |
27 | private BigDecimal balance;
28 |
29 | @OneToOne(cascade = CascadeType.PERSIST)
30 | @JoinColumn(name = "customer_Id")
31 | private Customer customer;
32 |
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/model/dto/BankAccountDTO.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.model.dto;
2 |
3 | import lombok.Data;
4 |
5 | import javax.validation.constraints.NotNull;
6 | import javax.validation.constraints.Size;
7 |
8 | @Data
9 | public class BankAccountDTO {
10 |
11 | @NotNull
12 | private Integer accountNo;
13 |
14 | @NotNull
15 | @Size(min = 5, max = 10,message = "Invalid IFSC Code [ 5-10 Characters only ]")
16 | private String IFSCCode;
17 |
18 | @NotNull
19 | @Size(min = 3, max = 15,message = "Invalid Bank Name [ 3-15 characters only ]")
20 | private String bankName;
21 |
22 | @NotNull
23 | private Double balance;
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/model/dto/BeneficiaryDTO.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.model.dto;
2 |
3 | import javax.validation.constraints.NotNull;
4 | import javax.validation.constraints.Size;
5 |
6 | import lombok.Data;
7 |
8 | @Data
9 | public class BeneficiaryDTO {
10 |
11 | @NotNull
12 | @Size(min = 10, max = 10 ,message = "Invalid Mobile Number [ 10 Digit Only ] ")
13 | private String beneficiaryMobileNumber;
14 |
15 | @NotNull
16 | @Size(min = 3, message = "Invalid Beneficiary name [ contains at least 3 characters ]")
17 | private String beneficiaryName;
18 |
19 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/model/dto/TransactionDTO.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.model.dto;
2 |
3 | import java.time.LocalDate;
4 |
5 | import lombok.AllArgsConstructor;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | @Data
10 | @NoArgsConstructor
11 | @AllArgsConstructor
12 | public class TransactionDTO {
13 |
14 | private Integer transactionId;
15 |
16 | private String transactionType;
17 |
18 | private LocalDate transactionDate;
19 |
20 | private double amount;
21 |
22 | private String Description;
23 |
24 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/repository/BankAccountRepo.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.repository;
2 |
3 | import com.mywallet.model.BankAccount;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.data.jpa.repository.Query;
6 | import org.springframework.stereotype.Repository;
7 |
8 | import java.util.List;
9 |
10 | @Repository
11 | public interface BankAccountRepo extends JpaRepository{
12 |
13 | @Query(value = "FROM BankAccount b INNER JOIN b.wallet w WHERE w.walletId=?1")
14 | public List findByWallet(Integer walletId);
15 |
16 | @Query(value = "FROM BankAccount b INNER JOIN b.wallet w WHERE w.walletId=?1")
17 | public List findAllByWallet(Integer walletId);
18 |
19 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/repository/BeneficiaryRepo.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.repository;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.data.jpa.repository.JpaRepository;
6 | import org.springframework.data.jpa.repository.Query;
7 | import org.springframework.stereotype.Repository;
8 |
9 | import com.mywallet.model.Beneficiary;
10 |
11 | @Repository
12 | public interface BeneficiaryRepo extends JpaRepository{
13 |
14 | @Query(value = "FROM Beneficiary b INNER JOIN b.wallet w WHERE w.walletId=?1 AND b.beneficiaryName =?2")
15 | public Beneficiary findByNameWallet(Integer walletId,String beneficiaryName);
16 |
17 | @Query(value = "FROM Beneficiary b INNER JOIN b.wallet w WHERE w.walletId=?1 AND b.beneficiaryMobileNumber =?2")
18 | public Beneficiary findByMobileWallet(Integer walletId,String beneficiaryMobileNumber);
19 |
20 | @Query(value = "FROM Beneficiary b INNER JOIN b.wallet w WHERE w.walletId=?1")
21 | public List findByWallet(Integer walletId);
22 |
23 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/repository/BillPaymentRepo.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.repository;
2 |
3 | import com.mywallet.model.BillPayment;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.stereotype.Repository;
6 |
7 | @Repository
8 | public interface BillPaymentRepo extends JpaRepository {
9 |
10 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/repository/CurrentSessionRepo.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.repository;
2 |
3 | import java.util.Optional;
4 |
5 | import org.springframework.data.jpa.repository.JpaRepository;
6 | import org.springframework.data.jpa.repository.Query;
7 | import org.springframework.stereotype.Repository;
8 |
9 | import com.mywallet.model.CurrentUserSession;
10 |
11 | @Repository
12 | public interface CurrentSessionRepo extends JpaRepository{
13 |
14 | public CurrentUserSession findByUuid(String uuid);
15 |
16 | @Query("FROM CurrentUserSession a WHERE a.userId=?1")
17 | public Optional findByUserId(Integer userId);
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/repository/CustomerRepo.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.repository;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.data.jpa.repository.JpaRepository;
6 | import org.springframework.data.jpa.repository.Query;
7 | import org.springframework.stereotype.Repository;
8 |
9 | import com.mywallet.model.Customer;
10 |
11 | @Repository
12 | public interface CustomerRepo extends JpaRepository {
13 |
14 | @Query("FROM Customer c WHERE c.mobileNumber=?1")
15 | public List findCustomerByMobile(String mobileNumber);
16 |
17 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/repository/TransactionRepo.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.repository;
2 |
3 | import java.time.LocalDate;
4 | import java.util.List;
5 |
6 | import org.springframework.data.jpa.repository.JpaRepository;
7 | import org.springframework.data.jpa.repository.Query;
8 | import org.springframework.stereotype.Repository;
9 | import com.mywallet.model.Transaction;
10 |
11 | @Repository
12 | public interface TransactionRepo extends JpaRepository{
13 |
14 | public List findByTransactionType(String transactionType);
15 |
16 | @Query(value = "FROM Transaction t INNER JOIN t.wallet w WHERE w.walletId=?1")
17 | public List findByWallet(Integer walletId);
18 |
19 | public List findByTransactionDate(LocalDate transactionDate);
20 |
21 | public List findByTransactionDateBetween(LocalDate startSate, LocalDate endDate);
22 |
23 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/repository/WalletRepo.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.repository;
2 |
3 |
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.data.jpa.repository.Query;
6 | import org.springframework.stereotype.Repository;
7 |
8 | import com.mywallet.model.Wallet;
9 |
10 | @Repository
11 | public interface WalletRepo extends JpaRepository {
12 |
13 | @Query("FROM Wallet w INNER JOIN w.customer c WHERE c.customerId=?1")
14 | public Wallet showCustomerWalletDetails(Integer customerId);
15 | }
16 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/service/BankAccountService.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.service;
2 |
3 | import com.mywallet.exceptions.BankAccountException;
4 | import com.mywallet.exceptions.CustomerException;
5 | import com.mywallet.model.BankAccount;
6 | import com.mywallet.model.Wallet;
7 | import com.mywallet.model.dto.BankAccountDTO;
8 |
9 | import java.util.List;
10 | import java.util.Optional;
11 |
12 | public interface BankAccountService {
13 |
14 | public Wallet addBankAccount(String key,BankAccountDTO bankAccountDTO) throws BankAccountException,CustomerException;
15 |
16 | public Wallet removeBankAccount(String key,BankAccountDTO bankAccountDTO) throws BankAccountException, CustomerException;
17 |
18 | public Optional viewBankAccount(String key, Integer accountNo) throws BankAccountException, CustomerException;
19 |
20 | public List viewAllBankAccounts(String key) throws BankAccountException, CustomerException;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/service/BankAccountServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.service;
2 |
3 | import com.mywallet.exceptions.BankAccountException;
4 | import com.mywallet.exceptions.CustomerException;
5 | import com.mywallet.model.BankAccount;
6 | import com.mywallet.model.CurrentUserSession;
7 | import com.mywallet.model.Wallet;
8 | import com.mywallet.model.dto.BankAccountDTO;
9 | import com.mywallet.repository.BankAccountRepo;
10 | import com.mywallet.repository.CurrentSessionRepo;
11 | import com.mywallet.repository.WalletRepo;
12 | import org.springframework.beans.factory.annotation.Autowired;
13 | import org.springframework.stereotype.Service;
14 |
15 | import java.util.List;
16 | import java.util.Optional;
17 |
18 | @Service
19 | public class BankAccountServiceImpl implements BankAccountService{
20 |
21 | @Autowired
22 | private BankAccountRepo bankAccountRepo;
23 |
24 | @Autowired
25 | private CurrentSessionRepo currentSessionRepo;
26 |
27 | @Autowired
28 | private WalletRepo walletRepo;
29 |
30 |
31 |
32 | /*--------------------------------------- Add Customer Bank Account -------------------------------------------*/
33 | @Override
34 | public Wallet addBankAccount(String key,BankAccountDTO bankAccountDTO) throws BankAccountException,CustomerException{
35 |
36 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
37 | if(currUserSession==null) {
38 | throw new CustomerException("No Customer LoggedIn");
39 | }
40 |
41 | Optional optional = bankAccountRepo.findById(bankAccountDTO.getAccountNo());
42 | if(optional.isEmpty()){
43 |
44 | Wallet wallet = walletRepo.showCustomerWalletDetails(currUserSession.getUserId());
45 |
46 | BankAccount createBankAccount = new BankAccount(bankAccountDTO.getAccountNo(), bankAccountDTO.getIFSCCode(), bankAccountDTO.getBankName(), bankAccountDTO.getBalance());
47 | createBankAccount.setWallet(wallet);
48 |
49 | bankAccountRepo.save(createBankAccount);
50 |
51 | return wallet;
52 | }
53 | throw new BankAccountException("Bank Account already exist With Given AccountNumber... Try Different");
54 |
55 |
56 | }
57 |
58 |
59 | /*--------------------------------------- Remove Customer Bank Account ----------------------------------------*/
60 | @Override
61 | public Wallet removeBankAccount(String key, BankAccountDTO bankAccountDTO) throws BankAccountException, CustomerException{
62 |
63 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
64 | if(currUserSession==null) {
65 | throw new CustomerException("No Customer LoggedIn");
66 | }
67 |
68 | Optional optional = bankAccountRepo.findById(bankAccountDTO.getAccountNo());
69 | if(optional.isPresent()) {
70 |
71 | bankAccountRepo.delete(optional.get());
72 | Wallet wallet = optional.get().getWallet();
73 |
74 | return wallet;
75 |
76 | }
77 | throw new BankAccountException("No Bank Account exist");
78 |
79 | }
80 |
81 |
82 | /*--------------------------------------- View Customer Bank Account ------------------------------------------*/
83 | @Override
84 | public Optional viewBankAccount(String key, Integer accountNo) throws BankAccountException,CustomerException{
85 |
86 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
87 | if(currUserSession == null) {
88 | throw new CustomerException("No Customer LoggedIn");
89 | }
90 |
91 |
92 | Optional bankAccount = bankAccountRepo.findById(accountNo);
93 | if(bankAccount == null) {
94 | throw new BankAccountException("No Bank Account exist");
95 | }
96 | return bankAccount;
97 | }
98 |
99 |
100 | /*------------------------------------- View Customers All Bank Account ---------------------------------------*/
101 | @Override
102 | public List viewAllBankAccounts(String key) throws BankAccountException,CustomerException{
103 |
104 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
105 | if(currUserSession == null) {
106 | throw new CustomerException("No Customer LoggedIn");
107 | }
108 |
109 | List bankAccounts = bankAccountRepo.findAllByWallet(walletRepo.showCustomerWalletDetails(currUserSession.getUserId()).getWalletId());
110 | if(bankAccounts == null) {
111 | throw new BankAccountException("No Bank Account exist");
112 | }
113 | return bankAccounts;
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/service/BeneficiaryService.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.service;
2 |
3 | import java.util.List;
4 |
5 | import com.mywallet.exceptions.BeneficiaryException;
6 | import com.mywallet.exceptions.CustomerException;
7 | import com.mywallet.exceptions.WalletException;
8 | import com.mywallet.model.Beneficiary;
9 | import com.mywallet.model.dto.BeneficiaryDTO;
10 |
11 | public interface BeneficiaryService {
12 |
13 | public Beneficiary addBeneficiary(Beneficiary beneficiary, String key) throws BeneficiaryException, CustomerException, WalletException;
14 |
15 | public List findAllByWallet(Integer walletId) throws BeneficiaryException;
16 |
17 | public Beneficiary viewBeneficiary(String beneficiaryName, String key) throws BeneficiaryException, CustomerException;
18 |
19 | public List viewAllBeneficiary(String key) throws BeneficiaryException, CustomerException;
20 |
21 | public Beneficiary deleteBeneficiary(String key, BeneficiaryDTO beneficiaryDTO) throws BeneficiaryException, CustomerException;
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/service/BeneficiaryServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.service;
2 |
3 | import java.util.List;
4 | import java.util.Optional;
5 |
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 |
9 | import com.mywallet.exceptions.BeneficiaryException;
10 | import com.mywallet.exceptions.CustomerException;
11 | import com.mywallet.exceptions.WalletException;
12 | import com.mywallet.model.Beneficiary;
13 | import com.mywallet.model.CurrentUserSession;
14 | import com.mywallet.model.Customer;
15 | import com.mywallet.model.Wallet;
16 | import com.mywallet.model.dto.BeneficiaryDTO;
17 | import com.mywallet.repository.BeneficiaryRepo;
18 | import com.mywallet.repository.CurrentSessionRepo;
19 | import com.mywallet.repository.CustomerRepo;
20 | import com.mywallet.repository.WalletRepo;
21 |
22 | @Service
23 | public class BeneficiaryServiceImpl implements BeneficiaryService {
24 |
25 | @Autowired
26 | private BeneficiaryRepo beneficiaryRepo;
27 |
28 | @Autowired
29 | private CurrentSessionRepo currentSessionRepo;
30 |
31 | @Autowired
32 | private WalletRepo walletRepo;
33 |
34 | @Autowired
35 | private CustomerRepo customerRepo;
36 |
37 |
38 | /*-------------------------------------------- Add Beneficiary -------------------------------------------------*/
39 | @Override
40 | public Beneficiary addBeneficiary(Beneficiary beneficiary,String key) throws BeneficiaryException, CustomerException, WalletException {
41 |
42 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
43 | if(currUserSession==null) {
44 | throw new CustomerException("No Customer LoggedIn");
45 | }
46 |
47 | Optional customer = customerRepo.findById(currUserSession.getUserId());
48 | Optional wallet = walletRepo.findById(walletRepo.showCustomerWalletDetails(currUserSession.getUserId()).getWalletId());
49 |
50 | if (!customer.isPresent()) {
51 | throw new CustomerException("Beneficiary is not Registered to the Application.");
52 | }
53 |
54 | if (!wallet.isPresent()){
55 | throw new WalletException("Invalid User.");
56 | }
57 |
58 | Optional optional=beneficiaryRepo.findById(beneficiary.getBeneficiaryMobileNumber());
59 |
60 | if(optional.isEmpty()) {
61 | return beneficiaryRepo.save(beneficiary);
62 | }
63 | throw new BeneficiaryException("Duplicate Details [ Beneficiary Already Exist ]");
64 |
65 |
66 | }
67 |
68 |
69 | /*-------------------------------------------- Find Beneficiary -------------------------------------------------*/
70 | @Override
71 | public List findAllByWallet(Integer walletId) throws BeneficiaryException {
72 |
73 | List beneficiaries = beneficiaryRepo.findByWallet(walletId);
74 |
75 | if(beneficiaries.isEmpty()) {
76 | throw new BeneficiaryException("No Beneficiary Exist");
77 | }
78 | return beneficiaries;
79 |
80 | }
81 |
82 |
83 | /*-------------------------------------------- View Beneficiary -------------------------------------------------*/
84 | @Override
85 | public Beneficiary viewBeneficiary(String beneficiaryName, String key) throws BeneficiaryException, CustomerException {
86 |
87 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
88 | if(currUserSession==null) {
89 | throw new CustomerException("No Customer LoggedIn");
90 | }
91 |
92 | Wallet wallet = walletRepo.showCustomerWalletDetails(currUserSession.getUserId());
93 |
94 | Beneficiary beneficiaries = beneficiaryRepo.findByNameWallet(wallet.getWalletId(),beneficiaryName);
95 |
96 | if(beneficiaries == null) {
97 | throw new BeneficiaryException("No Beneficiary Exist");
98 | }
99 | return beneficiaries;
100 |
101 | }
102 |
103 |
104 | /*-------------------------------------------- View All Beneficiary -------------------------------------------------*/
105 | @Override
106 | public List viewAllBeneficiary(String key) throws BeneficiaryException, CustomerException {
107 |
108 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
109 | if(currUserSession == null) {
110 | throw new CustomerException("No Customer LoggedIn");
111 | }
112 |
113 | Wallet wallet = walletRepo.showCustomerWalletDetails(currUserSession.getUserId());
114 |
115 | List beneficiaries = beneficiaryRepo.findByWallet(wallet.getWalletId());
116 |
117 | if(beneficiaries.isEmpty()) {
118 | throw new BeneficiaryException("No Beneficiary Exist");
119 | }
120 | return beneficiaries;
121 | }
122 |
123 |
124 | /*-------------------------------------------- Delete Beneficiary -------------------------------------------------*/
125 | @Override
126 | public Beneficiary deleteBeneficiary(String key, BeneficiaryDTO beneficiaryDTO) throws BeneficiaryException, CustomerException {
127 |
128 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
129 | if(currUserSession == null) {
130 | throw new CustomerException("No Customer LoggedIn");
131 | }
132 |
133 | Wallet wallet = walletRepo.showCustomerWalletDetails(currUserSession.getUserId());
134 |
135 | Beneficiary beneficiaries = beneficiaryRepo.findByMobileWallet(wallet.getWalletId(),beneficiaryDTO.getBeneficiaryMobileNumber());
136 |
137 | if(beneficiaries == null) {
138 | throw new BeneficiaryException("No Beneficiary found");
139 | }
140 |
141 | beneficiaryRepo.delete(beneficiaries);
142 |
143 | return beneficiaries;
144 | }
145 |
146 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/service/BillPaymentService.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.service;
2 |
3 | import com.mywallet.exceptions.BillPaymentException;
4 | import com.mywallet.exceptions.CustomerException;
5 | import com.mywallet.exceptions.TransactionException;
6 | import com.mywallet.exceptions.WalletException;
7 |
8 | import java.time.LocalDate;
9 |
10 | public interface BillPaymentService {
11 |
12 | public String addBillPayment(String targetMobile, String Name, double amount, String BillType, LocalDate paymentDate, Integer walletId, String key) throws BillPaymentException,WalletException,CustomerException,TransactionException;
13 |
14 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/service/BillPaymentServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.service;
2 |
3 | import com.mywallet.exceptions.BillPaymentException;
4 | import com.mywallet.exceptions.CustomerException;
5 | import com.mywallet.exceptions.TransactionException;
6 | import com.mywallet.exceptions.WalletException;
7 | import com.mywallet.model.BillPayment;
8 | import com.mywallet.repository.BillPaymentRepo;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.stereotype.Service;
11 |
12 | import java.math.BigDecimal;
13 | import java.time.LocalDate;
14 |
15 | @Service
16 | public class BillPaymentServiceImpl implements BillPaymentService{
17 |
18 | @Autowired
19 | private WalletService walletService;
20 |
21 | @Autowired
22 | private BillPaymentRepo billPaymentRepo;
23 |
24 |
25 | /*-------------------------------------------- Add Bill Payment -------------------------------------------------*/
26 | @Override
27 | public String addBillPayment(String targetMobile, String Name, double amount, String billType, LocalDate paymentDate, Integer walletId, String key) throws BillPaymentException {
28 |
29 | BigDecimal value = BigDecimal.valueOf(amount);
30 |
31 | // String str = walletService.fundTransfer(targetMobile, Name, value, key);
32 |
33 | BillPayment billPayment = new BillPayment(amount, billType, LocalDate.now());
34 |
35 | billPaymentRepo.save(billPayment);
36 |
37 | // return str;
38 |
39 | return "";
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/service/LoginService.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.service;
2 |
3 | import com.mywallet.exceptions.LoginException;
4 | import com.mywallet.model.UserLogin;
5 |
6 | public interface LoginService {
7 |
8 | public String login (UserLogin userLogin) throws LoginException;
9 |
10 | public String logout (String Key) throws LoginException;
11 | }
12 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/service/LoginServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.service;
2 |
3 | import java.time.LocalDateTime;
4 | import java.util.List;
5 | import java.util.Optional;
6 |
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.stereotype.Service;
9 |
10 | import com.mywallet.exceptions.LoginException;
11 | import com.mywallet.model.CurrentUserSession;
12 | import com.mywallet.model.Customer;
13 | import com.mywallet.model.UserLogin;
14 | import com.mywallet.repository.CurrentSessionRepo;
15 | import com.mywallet.repository.CustomerRepo;
16 |
17 | import net.bytebuddy.utility.RandomString;
18 |
19 | @Service
20 | public class LoginServiceImpl implements LoginService{
21 |
22 | @Autowired
23 | private CustomerRepo customerRepo;
24 |
25 | @Autowired
26 | private CurrentSessionRepo currentSessionRepo;
27 |
28 |
29 | /*------------------------------------------- Login --------------------------------------------------*/
30 |
31 | @Override
32 | public String login(UserLogin userLogin) throws LoginException {
33 |
34 | List customer= customerRepo.findCustomerByMobile(userLogin.getMobileNumber());
35 |
36 | Customer existingCustomer = customer.get(0);
37 |
38 | if(existingCustomer == null) {
39 | throw new LoginException("Invalid MobileNumber!");
40 | }
41 |
42 |
43 |
44 | Optional optional = currentSessionRepo.findByUserId(existingCustomer.getCustomerId());
45 |
46 | if(optional.isPresent()) {
47 |
48 | throw new LoginException("User Already Exists in the System.");
49 |
50 | }
51 |
52 | if(existingCustomer.getPassword().equals(userLogin.getPassword())) {
53 |
54 | String key= RandomString.make(6);
55 |
56 | CurrentUserSession currentUserSession = new CurrentUserSession(existingCustomer.getCustomerId(),key,LocalDateTime.now());
57 |
58 | currentSessionRepo.save(currentUserSession);
59 |
60 | return currentUserSession.toString();
61 | }
62 |
63 | throw new LoginException("Wrong password");
64 |
65 | }
66 |
67 |
68 | /*------------------------------------- Logout ----------------------------------------*/
69 |
70 | @Override
71 | public String logout(String key) throws LoginException {
72 |
73 | CurrentUserSession currentUserSession = currentSessionRepo.findByUuid(key);
74 |
75 | if(currentUserSession == null) {
76 | throw new LoginException("Invalid Unique userId (Session Key).");
77 |
78 | }
79 |
80 | currentSessionRepo.delete(currentUserSession);
81 |
82 | return "Logged Out Successfully!";
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/service/TransactionService.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.service;
2 |
3 | import java.time.LocalDate;
4 | import java.util.List;
5 |
6 | import com.mywallet.exceptions.CustomerException;
7 | import com.mywallet.exceptions.TransactionException;
8 | import com.mywallet.exceptions.WalletException;
9 | import com.mywallet.model.Transaction;
10 |
11 | public interface TransactionService {
12 |
13 | public Transaction addTransaction(Transaction transaction) throws TransactionException,WalletException;
14 |
15 | public List findByWallet(String key) throws TransactionException, WalletException, CustomerException;
16 |
17 | public Transaction findByTransactionId(String key, Integer transactionId)throws TransactionException, CustomerException;
18 |
19 | public List findByTransactionType(String key, String transactionType) throws TransactionException,CustomerException;
20 |
21 | public List viewTransactionBetweenDate(String key, LocalDate startDate, LocalDate endDate) throws TransactionException,CustomerException;
22 |
23 | public List viewAllTransaction()throws TransactionException;
24 |
25 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/service/TransactionServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.service;
2 |
3 | import java.time.LocalDate;
4 | import java.util.List;
5 | import java.util.Optional;
6 |
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.stereotype.Service;
9 |
10 | import com.mywallet.exceptions.CustomerException;
11 | import com.mywallet.exceptions.TransactionException;
12 | import com.mywallet.exceptions.WalletException;
13 | import com.mywallet.model.CurrentUserSession;
14 | import com.mywallet.model.Transaction;
15 | import com.mywallet.model.Wallet;
16 | import com.mywallet.repository.CurrentSessionRepo;
17 | import com.mywallet.repository.TransactionRepo;
18 | import com.mywallet.repository.WalletRepo;
19 |
20 | @Service
21 | public class TransactionServiceImpl implements TransactionService{
22 |
23 | @Autowired
24 | private CurrentSessionRepo currentSessionRepo;
25 |
26 | @Autowired
27 | private TransactionRepo transactionRepository;
28 |
29 | @Autowired
30 | private WalletRepo walletRepository;
31 |
32 | /*-------------------------------------------- Add Transaction ------------------------------------------------*/
33 | @Override
34 | public Transaction addTransaction(Transaction tran) throws TransactionException, WalletException {
35 | Optional wallet= walletRepository.findById(tran.getWallet().getWalletId());
36 | if(!wallet.isPresent())throw new WalletException("Wallet id worng.");
37 | if(transactionRepository.save(tran) != null)return tran;
38 | throw new TransactionException("Data is null");
39 | }
40 |
41 |
42 | /*---------------------------------------- Find Transaction - wallet ------------------------------------------*/
43 | @Override
44 | public List findByWallet(String key) throws TransactionException, WalletException, CustomerException {
45 |
46 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
47 | if(currUserSession==null) {
48 | throw new CustomerException("No Customer LoggedIn");
49 | }
50 |
51 | Wallet wallet = walletRepository.showCustomerWalletDetails(currUserSession.getUserId());
52 |
53 | Optional optional = walletRepository.findById(wallet.getWalletId());
54 | if(!optional.isPresent()){
55 | throw new WalletException("Invalid walletId");
56 | }
57 |
58 | List transactions = transactionRepository.findByWallet(wallet.getWalletId());
59 | if(transactions.isEmpty()){
60 | throw new TransactionException("No Transactions to Show");
61 | }
62 | return transactions;
63 | }
64 |
65 |
66 | /*----------------------------------------- Find Transaction - tId ---------------------------------------------*/
67 | @Override
68 | public Transaction findByTransactionId(String key, Integer transactionId) throws TransactionException, CustomerException {
69 |
70 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
71 | if(currUserSession==null) {
72 | throw new CustomerException("No Customer LoggedIn");
73 | }
74 |
75 | Optional transaction = transactionRepository.findById(transactionId);
76 |
77 | if(!transaction.isPresent()){
78 | throw new TransactionException("Invalid transactionId");
79 | }
80 | return transaction.get();
81 |
82 | }
83 |
84 |
85 | /*---------------------------------------- Find Transaction - Type --------------------------------------------*/
86 | @Override
87 | public List findByTransactionType(String key, String transactionType) throws TransactionException, CustomerException {
88 |
89 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
90 | if(currUserSession==null) {
91 | throw new CustomerException("No Customer LoggedIn");
92 | }
93 |
94 | List transactions = transactionRepository.findByTransactionType(transactionType);
95 | if(transactions.isEmpty()){
96 | throw new TransactionException("No Transactions to Show");
97 | }
98 | return transactions;
99 | }
100 |
101 |
102 | /*------------------------------------ View Transaction - Between 2 date ---------------------------------------*/
103 | @Override
104 | public List viewTransactionBetweenDate(String key, LocalDate startDate, LocalDate endDate) throws TransactionException, CustomerException {
105 |
106 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
107 | if(currUserSession==null) {
108 | throw new CustomerException("No Customer LoggedIn");
109 | }
110 |
111 | LocalDate localDate = LocalDate.now();
112 | if(startDate.isAfter(localDate)){
113 | throw new TransactionException("Invalid Start Date [ Future Date ]");
114 | }
115 | if(endDate.isAfter(localDate)){
116 | throw new TransactionException("Invalid End Date [ Future Date ]");
117 | }
118 | if(startDate.isAfter(endDate)) {
119 | throw new TransactionException("Invalid Start Date ");
120 | }
121 |
122 | List transactions= transactionRepository.findByTransactionDateBetween(startDate, endDate);
123 | if(transactions.isEmpty()){
124 | throw new TransactionException("No Transactions to Show");
125 | }
126 | return transactions;
127 | }
128 |
129 |
130 | /*----------------------------------------- View All Transaction ----------------------------------------------*/
131 | @Override
132 | public List viewAllTransaction() throws TransactionException {
133 |
134 | List transactions = transactionRepository.findAll();
135 |
136 | if(transactions.isEmpty()){
137 | throw new TransactionException("No Transactions to Show");
138 | }
139 | return transactions;
140 | }
141 |
142 |
143 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/service/WalletService.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.service;
2 |
3 | import com.mywallet.exceptions.BankAccountException;
4 | import com.mywallet.exceptions.CustomerException;
5 | import com.mywallet.exceptions.TransactionException;
6 | import com.mywallet.exceptions.WalletException;
7 | import com.mywallet.model.Customer;
8 | import com.mywallet.model.Wallet;
9 |
10 | import java.math.BigDecimal;
11 |
12 | public interface WalletService {
13 |
14 | public Customer createCustomerAccount(Customer customer) throws CustomerException;
15 |
16 | public BigDecimal showBalance(String mobile, String key) throws CustomerException;
17 |
18 | public String fundTransfer(String name, String targetMobileNumber, BigDecimal amount, String key) throws WalletException, TransactionException, CustomerException;
19 |
20 | public String depositAmount(BigDecimal amount, Integer accountNo, String key) throws BankAccountException, WalletException, CustomerException, TransactionException;
21 |
22 | // public List getList(Customer customer, String key) throws CustomerException;
23 |
24 | public Customer updateAccount(Customer customer, String key) throws CustomerException;
25 |
26 | public String addMoney(Wallet wallet, Integer accountNo, BigDecimal amount, String key) throws WalletException, BankAccountException, CustomerException, TransactionException;
27 |
28 | }
--------------------------------------------------------------------------------
/MyWallet/src/main/java/com/mywallet/service/WalletServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.mywallet.service;
2 |
3 | import com.mywallet.exceptions.BankAccountException;
4 | import com.mywallet.exceptions.CustomerException;
5 | import com.mywallet.exceptions.TransactionException;
6 | import com.mywallet.exceptions.WalletException;
7 | import com.mywallet.model.*;
8 | import com.mywallet.repository.*;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.stereotype.Service;
11 |
12 | import java.math.BigDecimal;
13 | import java.time.LocalDate;
14 | import java.util.List;
15 | import java.util.Optional;
16 |
17 | @Service
18 | public class WalletServiceImpl implements WalletService {
19 |
20 | @Autowired
21 | private WalletRepo walletRepo;
22 |
23 | @Autowired
24 | private CustomerRepo customerRepo;
25 |
26 | @Autowired
27 | private CurrentSessionRepo currentSessionRepo;
28 |
29 | @Autowired
30 | private BeneficiaryRepo beneficiaryRepo;
31 |
32 | @Autowired
33 | private TransactionService transactionService;
34 |
35 | @Autowired
36 | private BankAccountRepo bankAccountRepo;
37 |
38 | /*----------------------------------------- Create Wallet Account ---------------------------------------------*/
39 | @Override
40 | public Customer createCustomerAccount(Customer customer) throws CustomerException {
41 |
42 | List customers = customerRepo.findCustomerByMobile(customer.getMobileNumber());
43 |
44 | if(customers.isEmpty()) {
45 |
46 | Wallet wallet = new Wallet();
47 | wallet.setBalance(BigDecimal.valueOf(0));
48 |
49 | wallet.setCustomer(customer);
50 | walletRepo.save(wallet);
51 |
52 | return customerRepo.save(customer);
53 | }
54 | throw new CustomerException("Duplicate Mobile Number [ Already Registered with different customer ] ");
55 |
56 | }
57 |
58 |
59 | /*------------------------------------------ Show Wallet Balance ----------------------------------------------*/
60 | @Override
61 | public BigDecimal showBalance(String mobile, String key) throws CustomerException {
62 |
63 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
64 | if(currUserSession==null) {
65 | throw new CustomerException("No Customer LoggedIn");
66 | }
67 |
68 | Integer userId = currUserSession.getUserId();
69 | Wallet wallet = walletRepo.showCustomerWalletDetails(userId);
70 |
71 | return wallet.getBalance();
72 |
73 | }
74 |
75 |
76 | /*--------------------------------------------- Fund Transfer -------------------------------------------------*/
77 | @Override
78 | public String fundTransfer( String name, String targetMobileNumber, BigDecimal amount, String key) throws WalletException, CustomerException, TransactionException {
79 |
80 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
81 | if(currUserSession==null) {
82 | throw new CustomerException("No Customer LoggedIn");
83 | }
84 |
85 |
86 | Integer userId = currUserSession.getUserId();
87 | Wallet wallet = walletRepo.showCustomerWalletDetails(userId);
88 |
89 | Beneficiary beneficiary = new Beneficiary(targetMobileNumber, name);
90 |
91 | List beneficiaries = beneficiaryRepo.findByWallet(wallet.getWalletId());
92 |
93 | if(!beneficiaries.contains(beneficiary)) beneficiaryRepo.save(beneficiary);
94 |
95 |
96 | List customers = customerRepo.findCustomerByMobile(targetMobileNumber);
97 |
98 | if(customers.isEmpty()) {
99 | throw new CustomerException("Customer with mobile number "+ targetMobileNumber +" does not exist");
100 | }
101 |
102 | Wallet targetWallet = walletRepo.showCustomerWalletDetails(customers.get(0).getCustomerId());
103 |
104 | if(wallet.getBalance().compareTo(amount)<0) throw new WalletException("Add more amount in wallet for transaction");
105 |
106 | targetWallet.setBalance(targetWallet.getBalance().add(amount));
107 | walletRepo.save(targetWallet);
108 |
109 | wallet.setBalance(wallet.getBalance().subtract(amount));
110 | walletRepo.save(wallet);
111 |
112 |
113 | Transaction transaction = new Transaction("Bank transfer", LocalDate.now(), amount.doubleValue(),amount +" transferred to "+ targetMobileNumber);
114 | transaction.setWallet(wallet);
115 |
116 | transactionService.addTransaction(transaction);
117 |
118 | return "Fund Transferred successfully";
119 | }
120 |
121 |
122 | /*--------------------------------------------- Deposit Amount ------------------------------------------------*/
123 | @Override
124 | public String depositAmount(BigDecimal amount, Integer accountNo, String key) throws BankAccountException, CustomerException, WalletException, TransactionException {
125 |
126 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
127 | if(currUserSession==null) {
128 | throw new CustomerException("No Customer LoggedIn");
129 | }
130 |
131 | Integer userId = currUserSession.getUserId();
132 | Wallet wallet = walletRepo.showCustomerWalletDetails(userId);
133 |
134 | List accounts = bankAccountRepo.findAllByWallet(wallet.getWalletId());
135 |
136 | if(accounts.isEmpty()) {
137 | throw new BankAccountException("Add bank account for transaction");
138 | }
139 |
140 | BankAccount bankAccount = null;
141 |
142 | for(BankAccount b : accounts) {
143 | if((b.getAccountNo().toString()).equals(accountNo.toString())) {
144 | bankAccount = b;
145 | break;
146 | }
147 |
148 | }
149 |
150 | if(bankAccount==null){
151 | throw new BankAccountException("Bank account number does not match the data of saved accounts");
152 | }
153 |
154 | if(bankAccount.getBalance() < amount.doubleValue()) {
155 | throw new BankAccountException("Insufficient balance in account");
156 | }
157 |
158 | bankAccount.setBalance(bankAccount.getBalance() - amount.doubleValue());
159 | wallet.setBalance(wallet.getBalance().add(amount));
160 |
161 | bankAccountRepo.save(bankAccount);
162 |
163 | double value = amount.doubleValue();
164 | Transaction transaction = new Transaction("Bank transfer", LocalDate.now(), value,"transferred from bank "+bankAccount.getBankName()+" to wallet");
165 | transaction.setWallet(wallet);
166 |
167 |
168 | transactionService.addTransaction(transaction);
169 |
170 |
171 | return "Your bank account no "+ accountNo +" debited for "+ amount +" Rs" ;
172 |
173 | }
174 |
175 |
176 | // /*------------------------------------------- View Customers Li -----------------------------------------------*/
177 | // @Override
178 | // public List getList(Customer customer, String key) throws CustomerException {
179 | // return null;
180 | // }
181 |
182 |
183 | /*--------------------------------------------- Update Account ------------------------------------------------*/
184 | @Override
185 | public Customer updateAccount(Customer customer, String key) throws CustomerException {
186 |
187 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
188 | if(currUserSession==null) {
189 | throw new CustomerException("No Customer LoggedIn");
190 | }
191 |
192 | Optional customer1 = customerRepo.findById(currUserSession.getUserId());
193 |
194 |
195 | if(!customer1.isPresent()) {
196 | throw new CustomerException("Customer with given CustomerId not exist");
197 | }
198 |
199 | customer.setCustomerId(currUserSession.getUserId());
200 |
201 | return customerRepo.save(customer);
202 | }
203 |
204 |
205 | /*------------------------------------------ Add Money To Wallet ----------------------------------------------*/
206 | @Override
207 | public String addMoney(Wallet wallet, Integer accountNo, BigDecimal amount, String key) throws WalletException, BankAccountException, CustomerException, TransactionException {
208 |
209 | CurrentUserSession currUserSession = currentSessionRepo.findByUuid(key);
210 | if(currUserSession==null) {
211 | throw new CustomerException("No Customer LoggedIn");
212 | }
213 |
214 | Integer userId = currUserSession.getUserId();
215 | wallet = walletRepo.showCustomerWalletDetails(userId);
216 |
217 | List accounts = bankAccountRepo.findAllByWallet(wallet.getWalletId());
218 |
219 | if(accounts.isEmpty()) {
220 | throw new BankAccountException("Add bank account for transaction");
221 | }
222 |
223 | BankAccount bankAccount = null;
224 |
225 | for(BankAccount b: accounts) {
226 | if((b.getAccountNo().toString()).equals(accountNo.toString())) {
227 | bankAccount = b;
228 | break;
229 | }
230 |
231 | }
232 |
233 | if(bankAccount == null){
234 | throw new BankAccountException("Bank account number does not match the data of saved accounts");
235 | }
236 |
237 | if(bankAccount.getBalance() < amount.doubleValue()) {
238 | throw new BankAccountException("Insufficient balance in account");
239 | }
240 |
241 | bankAccount.setBalance(bankAccount.getBalance() - amount.doubleValue());
242 | wallet.setBalance(wallet.getBalance().add(amount));
243 |
244 | bankAccountRepo.save(bankAccount);
245 |
246 | double value = amount.doubleValue();
247 | Transaction transaction = new Transaction("Bank transfer", LocalDate.now(), value,"transferred from bank "+bankAccount.getBankName()+" to wallet");
248 | transaction.setWallet(wallet);
249 |
250 |
251 | transactionService.addTransaction(transaction);
252 |
253 |
254 | return "Your bank account no "+ accountNo +" debited for "+ amount +" Rs" ;
255 |
256 | }
257 |
258 | }
259 |
--------------------------------------------------------------------------------
/MyWallet/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #changing the server port
2 | server.port=8484
3 |
4 | #db specific properties
5 | spring.datasource.url=jdbc:mysql://localhost:3306/mywallet
6 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
7 |
8 | #db default user
9 | #spring.datasource.username=root
10 | #spring.datasource.password=root
11 |
12 | #db Abhishek-0713
13 | spring.datasource.username=root
14 | spring.datasource.password=Abhi@0713
15 |
16 |
17 | #ORM s/w specific properties
18 | spring.jpa.hibernate.ddl-auto=update
19 | spring.jpa.show-sql=true
20 |
21 | spring.mvc.throw-exception-if-no-handler-found=true
22 | spring.web.resources.add-mappings=false
23 |
24 | spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER
25 |
--------------------------------------------------------------------------------
/MyWallet/src/test/java/com/mywallet/MyWalletApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.mywallet;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class MyWalletApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MyWallet - Payment wallet Application
2 |
3 |
4 |
5 |
6 |
7 | This is the Payment Wallet Application in Java using Spring Boot with Source Code.
8 |
9 | This is restful service for the payment wallet application with all neccessary API. This project is developed to allow customers to make payments using wallets while making any purchase using the application.
10 |
11 |
12 | #
13 | ### Team Members
14 |
15 | - Alok Shekhawat | [Github](https://github.com/aloks31)
16 |
17 | - Dileep Kumar Yadav | [Github](https://github.com/dileep8920)
18 |
19 | - Graghavendramurty | [Github](https://github.com/GandhamRaghavendra)
20 |
21 | - Musavvir Shaikh | [Github](https://github.com/shaikh9560)
22 |
23 |
24 | - Abhishek D. Patil | [Github](https://github.com/abhishek-0713) - Team Lead
25 |
26 |
27 |
28 |
29 |
30 | ## Modules:
31 |
32 | - Wallet Module
33 |
34 | - Customer Module
35 |
36 | - Bill Payment Module
37 |
38 | - Transaction Module
39 |
40 | - Beneficiary Module
41 |
42 | - Bank Account Module
43 |
44 | ### Funcionality of the application includes :
45 |
46 | 1. User can able to add BankAcconuts to their wallet.
47 |
48 | 2. User can able to transfer money from bank to wallet, wallet to wallet also can add money to wallet using mobile number.
49 |
50 | 3. Apart from that user can see his all transactions by type , by tansactions Id, by transaction date.
51 |
52 | 4. User can also add Beneficiary to their account.
53 |
54 | 5. This is construct week group project of 5 collaborative team members built in 4 days.
55 |
56 |
57 |
58 | ## Tech Stack
59 |
60 | - Advance Java
61 |
62 | - AWS
63 |
64 | - Spring Boot
65 |
66 | - MySQL
67 |
68 | - Hibernate
69 |
70 | - Maven
71 |
72 | - Swagger
73 |
74 | - Lombok
75 |
76 | ## ER Diagram :
77 |
78 | 
79 |
80 |
81 | ## Swagger UI :
82 |
83 | ### server url
84 | `` http://localhost:8484/swagger-ui/index.html ``
85 |
86 | ### Schema
87 |
88 | 
89 |
90 |
95 |
--------------------------------------------------------------------------------