From ddfb35ddc3b05c058d69adf9feba1a43dfafd7fc Mon Sep 17 00:00:00 2001 From: example <1916008@saec.ac.in> Date: Fri, 26 Dec 2025 15:06:02 +0530 Subject: [PATCH] Initial commit on 26 December,2025 --- .gitattributes | 2 + .gitignore | 33 + .mvn/wrapper/maven-wrapper.properties | 3 + mvnw | 295 + mvnw.cmd | 189 + pom.xml | 140 + .../GccItCellServicesApplication.java | 17 + .../AuditorAwareConfiguration.java | 41 + .../configuration/RateLimitConfiguration.java | 42 + .../configuration/SecurityConfiguration.java | 136 + .../configuration/WebConfiguration.java | 37 + .../springboot/controller/HomeController.java | 70 + .../controller/UrlDataController.java | 61 + .../interceptor/RateLimitInterceptor.java | 102 + .../springboot/mapper/OtpLogMapper.java | 38 + .../springboot/mapper/StatusMapper.java | 19 + .../springboot/mapper/UrlCategoryMapper.java | 29 + .../springboot/mapper/UrlDataMapper.java | 48 + .../springboot/model/AppUser.java | 70 + .../springboot/model/OtpLog.java | 102 + .../springboot/model/Status.java | 35 + .../springboot/model/UrlCategory.java | 106 + .../springboot/model/UrlData.java | 136 + .../springboot/model/UserRole.java | 66 + .../repository/AppUserRepository.java | 25 + .../repository/OtpLogRepository.java | 15 + .../repository/StatusRepository.java | 11 + .../repository/UrlCategoryRepository.java | 18 + .../repository/UrlDataRepository.java | 28 + .../request_dto/AddUrlDataRequestDTO.java | 22 + .../request_dto/AppUserRequestDTO.java | 17 + .../request_dto/GetOtpRequestDTO.java | 18 + .../request_dto/OtpLogRequestDTO.java | 22 + .../request_dto/UpdateUrlDataRequestDTO.java | 22 + .../request_dto/UrlCategoryRequestDTO.java | 18 + .../request_dto/UrlDataRequestDTO.java | 26 + .../request_dto/VerifyOtpRequestDTO.java | 19 + .../response_dto/OtpLogResponseDTO.java | 23 + .../response_dto/ServiceResponseDTO.java | 23 + .../response_dto/StatusResponseDTO.java | 23 + .../response_dto/UrlCategoryResponseDTO.java | 19 + .../response_dto/UrlDataResponseDTO.java | 37 + .../rest_controller/HomeRestController.java | 192 + .../UrlDataRestController.java | 43 + .../springboot/service/HomeService.java | 279 + .../service/UrlDataCacheService.java | 174 + .../springboot/service/UrlDataService.java | 280 + .../util/MobileNumberTokenStore.java | 28 + .../springboot/util/UrlCacheScheduler.java | 21 + .../util/UrlDataCacheInitializer.java | 22 + ...itional-spring-configuration-metadata.json | 9 + .../resources/application-local.properties | 33 + .../resources/application-prod.properties | 29 + src/main/resources/application.properties | 2 + .../bootstrap-5.3.2/css/bootstrap.min.css | 11794 ++++++++++++++++ .../bootstrap-5.3.2/js/bootstrap.min.js | 2212 +++ .../static/assets/css/body-form-styles.css | 193 + .../static/assets/css/datatable-styles.css | 114 + .../static/assets/css/header-styles.css | 77 + .../static/assets/css/home-styles.css | 295 + .../static/assets/css/login-form-styles.css | 272 + .../css/dataTables.bootstrap5.min.css | 532 + .../js/dataTables.bootstrap5.min.js | 80 + .../js/jquery.dataTables.min.js | 2990 ++++ .../css/buttons.bootstrap5.min.css | 248 + .../js/buttons.bootstrap5.min.js | 70 + .../js/buttons.html5.min.js | 538 + .../js/buttons.print.min.js | 79 + .../js/dataTables.buttons.min.js | 764 + .../assets/font-awesome-6.5.1/css/all.min.css | 6995 +++++++++ .../webfonts/fa-brands-400.ttf | Bin 0 -> 207972 bytes .../webfonts/fa-brands-400.woff2 | Bin 0 -> 117372 bytes .../webfonts/fa-regular-400.ttf | Bin 0 -> 68004 bytes .../webfonts/fa-regular-400.woff2 | Bin 0 -> 25452 bytes .../webfonts/fa-solid-900.ttf | Bin 0 -> 419720 bytes .../webfonts/fa-solid-900.woff2 | Bin 0 -> 156496 bytes .../webfonts/fa-v4compatibility.ttf | Bin 0 -> 10832 bytes .../webfonts/fa-v4compatibility.woff2 | Bin 0 -> 4792 bytes .../assets/font-awesome-6.5.2/css/all.min.css | 7023 +++++++++ .../webfonts/fa-brands-400.ttf | Bin 0 -> 209128 bytes .../webfonts/fa-brands-400.woff2 | Bin 0 -> 117852 bytes .../webfonts/fa-regular-400.ttf | Bin 0 -> 67860 bytes .../webfonts/fa-regular-400.woff2 | Bin 0 -> 25392 bytes .../webfonts/fa-solid-900.ttf | Bin 0 -> 420332 bytes .../webfonts/fa-solid-900.woff2 | Bin 0 -> 156400 bytes .../webfonts/fa-v4compatibility.ttf | Bin 0 -> 10832 bytes .../webfonts/fa-v4compatibility.woff2 | Bin 0 -> 4792 bytes .../static/assets/header-images/gcc1.png | Bin 0 -> 209045 bytes .../jquery-3.6.4/js/jquery-3.6.4.min.js | 3244 +++++ .../static/assets/js/add-url-data-script.js | 93 + .../static/assets/js/fetch-csrf-script.js | 20 + .../static/assets/js/go-back-script.js | 3 + .../resources/static/assets/js/home-script.js | 420 + .../static/assets/js/login-script.js | 28 + .../assets/js/update-url-data-script.js | 136 + .../assets/js/view-login-details-script.js | 56 + .../assets/popper-2.11.8/js/popper.min.js | 1123 ++ .../poppins-v23-devanagari-100.woff2 | Bin 0 -> 42344 bytes .../poppins-v23-devanagari-200.woff2 | Bin 0 -> 45680 bytes .../poppins-v23-devanagari-300.woff2 | Bin 0 -> 45916 bytes .../poppins-v23-devanagari-500.woff2 | Bin 0 -> 45400 bytes .../poppins-v23-devanagari-600.woff2 | Bin 0 -> 45884 bytes .../poppins-v23-devanagari-700.woff2 | Bin 0 -> 45620 bytes .../poppins-v23-devanagari-regular.woff2 | Bin 0 -> 45916 bytes .../latin-ext/poppins-v23-latin-ext-100.woff2 | Bin 0 -> 10324 bytes .../latin-ext/poppins-v23-latin-ext-200.woff2 | Bin 0 -> 10808 bytes .../latin-ext/poppins-v23-latin-ext-300.woff2 | Bin 0 -> 10760 bytes .../latin-ext/poppins-v23-latin-ext-500.woff2 | Bin 0 -> 10708 bytes .../latin-ext/poppins-v23-latin-ext-600.woff2 | Bin 0 -> 10992 bytes .../latin-ext/poppins-v23-latin-ext-700.woff2 | Bin 0 -> 10712 bytes .../poppins-v23-latin-ext-regular.woff2 | Bin 0 -> 10892 bytes .../fonts/latin/poppins-v23-latin-100.woff2 | Bin 0 -> 7484 bytes .../fonts/latin/poppins-v23-latin-200.woff2 | Bin 0 -> 7932 bytes .../fonts/latin/poppins-v23-latin-300.woff2 | Bin 0 -> 7840 bytes .../fonts/latin/poppins-v23-latin-500.woff2 | Bin 0 -> 7748 bytes .../fonts/latin/poppins-v23-latin-600.woff2 | Bin 0 -> 8000 bytes .../fonts/latin/poppins-v23-latin-700.woff2 | Bin 0 -> 7816 bytes .../latin/poppins-v23-latin-regular.woff2 | Bin 0 -> 7884 bytes .../resources/templates/fragments/footer.html | 19 + .../resources/templates/fragments/header.html | 22 + .../resources/templates/fragments/navbar.html | 66 + src/main/resources/templates/home/home.html | 81 + src/main/resources/templates/home/login.html | 88 + .../templates/home/view-login-details.html | 71 + .../templates/modals/login-modal.html | 30 + .../templates/urls/add-url-data.html | 86 + .../urls/get-urls-by-url-category.html | 80 + .../templates/urls/update-url-data.html | 110 + 128 files changed, 43367 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .mvn/wrapper/maven-wrapper.properties create mode 100644 mvnw create mode 100644 mvnw.cmd create mode 100644 pom.xml create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/GccItCellServicesApplication.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/configuration/AuditorAwareConfiguration.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/configuration/RateLimitConfiguration.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/configuration/SecurityConfiguration.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/configuration/WebConfiguration.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/controller/HomeController.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/controller/UrlDataController.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/interceptor/RateLimitInterceptor.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/mapper/OtpLogMapper.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/mapper/StatusMapper.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/mapper/UrlCategoryMapper.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/mapper/UrlDataMapper.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/model/AppUser.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/model/OtpLog.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/model/Status.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/model/UrlCategory.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/model/UrlData.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/model/UserRole.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/repository/AppUserRepository.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/repository/OtpLogRepository.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/repository/StatusRepository.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/repository/UrlCategoryRepository.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/repository/UrlDataRepository.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/request_dto/AddUrlDataRequestDTO.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/request_dto/AppUserRequestDTO.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/request_dto/GetOtpRequestDTO.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/request_dto/OtpLogRequestDTO.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/request_dto/UpdateUrlDataRequestDTO.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/request_dto/UrlCategoryRequestDTO.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/request_dto/UrlDataRequestDTO.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/request_dto/VerifyOtpRequestDTO.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/response_dto/OtpLogResponseDTO.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/response_dto/ServiceResponseDTO.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/response_dto/StatusResponseDTO.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/response_dto/UrlCategoryResponseDTO.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/response_dto/UrlDataResponseDTO.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/rest_controller/HomeRestController.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/rest_controller/UrlDataRestController.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/service/HomeService.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/service/UrlDataCacheService.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/service/UrlDataService.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/util/MobileNumberTokenStore.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/util/UrlCacheScheduler.java create mode 100644 src/main/java/com/gcc_it_cell_services/springboot/util/UrlDataCacheInitializer.java create mode 100644 src/main/resources/META-INF/additional-spring-configuration-metadata.json create mode 100644 src/main/resources/application-local.properties create mode 100644 src/main/resources/application-prod.properties create mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/static/assets/bootstrap-5.3.2/css/bootstrap.min.css create mode 100644 src/main/resources/static/assets/bootstrap-5.3.2/js/bootstrap.min.js create mode 100644 src/main/resources/static/assets/css/body-form-styles.css create mode 100644 src/main/resources/static/assets/css/datatable-styles.css create mode 100644 src/main/resources/static/assets/css/header-styles.css create mode 100644 src/main/resources/static/assets/css/home-styles.css create mode 100644 src/main/resources/static/assets/css/login-form-styles.css create mode 100644 src/main/resources/static/assets/datatables-1.13.6/css/dataTables.bootstrap5.min.css create mode 100644 src/main/resources/static/assets/datatables-1.13.6/js/dataTables.bootstrap5.min.js create mode 100644 src/main/resources/static/assets/datatables-1.13.6/js/jquery.dataTables.min.js create mode 100644 src/main/resources/static/assets/datatables-buttons-2.4.1/css/buttons.bootstrap5.min.css create mode 100644 src/main/resources/static/assets/datatables-buttons-2.4.1/js/buttons.bootstrap5.min.js create mode 100644 src/main/resources/static/assets/datatables-buttons-2.4.1/js/buttons.html5.min.js create mode 100644 src/main/resources/static/assets/datatables-buttons-2.4.1/js/buttons.print.min.js create mode 100644 src/main/resources/static/assets/datatables-buttons-2.4.1/js/dataTables.buttons.min.js create mode 100644 src/main/resources/static/assets/font-awesome-6.5.1/css/all.min.css create mode 100644 src/main/resources/static/assets/font-awesome-6.5.1/webfonts/fa-brands-400.ttf create mode 100644 src/main/resources/static/assets/font-awesome-6.5.1/webfonts/fa-brands-400.woff2 create mode 100644 src/main/resources/static/assets/font-awesome-6.5.1/webfonts/fa-regular-400.ttf create mode 100644 src/main/resources/static/assets/font-awesome-6.5.1/webfonts/fa-regular-400.woff2 create mode 100644 src/main/resources/static/assets/font-awesome-6.5.1/webfonts/fa-solid-900.ttf create mode 100644 src/main/resources/static/assets/font-awesome-6.5.1/webfonts/fa-solid-900.woff2 create mode 100644 src/main/resources/static/assets/font-awesome-6.5.1/webfonts/fa-v4compatibility.ttf create mode 100644 src/main/resources/static/assets/font-awesome-6.5.1/webfonts/fa-v4compatibility.woff2 create mode 100644 src/main/resources/static/assets/font-awesome-6.5.2/css/all.min.css create mode 100644 src/main/resources/static/assets/font-awesome-6.5.2/webfonts/fa-brands-400.ttf create mode 100644 src/main/resources/static/assets/font-awesome-6.5.2/webfonts/fa-brands-400.woff2 create mode 100644 src/main/resources/static/assets/font-awesome-6.5.2/webfonts/fa-regular-400.ttf create mode 100644 src/main/resources/static/assets/font-awesome-6.5.2/webfonts/fa-regular-400.woff2 create mode 100644 src/main/resources/static/assets/font-awesome-6.5.2/webfonts/fa-solid-900.ttf create mode 100644 src/main/resources/static/assets/font-awesome-6.5.2/webfonts/fa-solid-900.woff2 create mode 100644 src/main/resources/static/assets/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf create mode 100644 src/main/resources/static/assets/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2 create mode 100644 src/main/resources/static/assets/header-images/gcc1.png create mode 100644 src/main/resources/static/assets/jquery-3.6.4/js/jquery-3.6.4.min.js create mode 100644 src/main/resources/static/assets/js/add-url-data-script.js create mode 100644 src/main/resources/static/assets/js/fetch-csrf-script.js create mode 100644 src/main/resources/static/assets/js/go-back-script.js create mode 100644 src/main/resources/static/assets/js/home-script.js create mode 100644 src/main/resources/static/assets/js/login-script.js create mode 100644 src/main/resources/static/assets/js/update-url-data-script.js create mode 100644 src/main/resources/static/assets/js/view-login-details-script.js create mode 100644 src/main/resources/static/assets/popper-2.11.8/js/popper.min.js create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/devanagari/poppins-v23-devanagari-100.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/devanagari/poppins-v23-devanagari-200.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/devanagari/poppins-v23-devanagari-300.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/devanagari/poppins-v23-devanagari-500.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/devanagari/poppins-v23-devanagari-600.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/devanagari/poppins-v23-devanagari-700.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/devanagari/poppins-v23-devanagari-regular.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/latin-ext/poppins-v23-latin-ext-100.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/latin-ext/poppins-v23-latin-ext-200.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/latin-ext/poppins-v23-latin-ext-300.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/latin-ext/poppins-v23-latin-ext-500.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/latin-ext/poppins-v23-latin-ext-600.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/latin-ext/poppins-v23-latin-ext-700.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/latin-ext/poppins-v23-latin-ext-regular.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/latin/poppins-v23-latin-100.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/latin/poppins-v23-latin-200.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/latin/poppins-v23-latin-300.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/latin/poppins-v23-latin-500.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/latin/poppins-v23-latin-600.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/latin/poppins-v23-latin-700.woff2 create mode 100644 src/main/resources/static/assets/poppins-23.0/fonts/latin/poppins-v23-latin-regular.woff2 create mode 100644 src/main/resources/templates/fragments/footer.html create mode 100644 src/main/resources/templates/fragments/header.html create mode 100644 src/main/resources/templates/fragments/navbar.html create mode 100644 src/main/resources/templates/home/home.html create mode 100644 src/main/resources/templates/home/login.html create mode 100644 src/main/resources/templates/home/view-login-details.html create mode 100644 src/main/resources/templates/modals/login-modal.html create mode 100644 src/main/resources/templates/urls/add-url-data.html create mode 100644 src/main/resources/templates/urls/get-urls-by-url-category.html create mode 100644 src/main/resources/templates/urls/update-url-data.html diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3b41682 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +/mvnw text eol=lf +*.cmd text eol=crlf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..667aaef --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..c0bcafe --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,3 @@ +wrapperVersion=3.3.4 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip diff --git a/mvnw b/mvnw new file mode 100644 index 0000000..bd8896b --- /dev/null +++ b/mvnw @@ -0,0 +1,295 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.3.4 +# +# Optional ENV vars +# ----------------- +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output +# ---------------------------------------------------------------------------- + +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x + +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac + +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" + + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 + fi + fi + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi + fi +} + +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" + done + printf %x\\n $h +} + +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } + +die() { + printf %s\\n "$1" >&2 + exit 1 +} + +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} + +scriptDir="$(dirname "$0")" +scriptName="$(basename "$0")" + +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} + +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" +fi + +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac + +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" +fi + +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" +fi + +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v + +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac + +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then + distributionSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 + fi +fi + +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" +else + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +actualDistributionDir="" + +# First try the expected directory name (for regular distributions) +if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then + if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then + actualDistributionDir="$distributionUrlNameMain" + fi +fi + +# If not found, search for any directory with the Maven executable (for snapshots) +if [ -z "$actualDistributionDir" ]; then + # enable globbing to iterate over items + set +f + for dir in "$TMP_DOWNLOAD_DIR"/*; do + if [ -d "$dir" ]; then + if [ -f "$dir/bin/$MVN_CMD" ]; then + actualDistributionDir="$(basename "$dir")" + break + fi + fi + done + set -f +fi + +if [ -z "$actualDistributionDir" ]; then + verbose "Contents of $TMP_DOWNLOAD_DIR:" + verbose "$(ls -la "$TMP_DOWNLOAD_DIR")" + die "Could not find Maven distribution directory in extracted archive" +fi + +verbose "Found extracted Maven distribution directory: $actualDistributionDir" +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" + +clean || : +exec_maven "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..92450f9 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,189 @@ +<# : batch portion +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.3.4 +@REM +@REM Optional ENV vars +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output +@REM ---------------------------------------------------------------------------- + +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) +) +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' + +$MAVEN_M2_PATH = "$HOME/.m2" +if ($env:MAVEN_USER_HOME) { + $MAVEN_M2_PATH = "$env:MAVEN_USER_HOME" +} + +if (-not (Test-Path -Path $MAVEN_M2_PATH)) { + New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null +} + +$MAVEN_WRAPPER_DISTS = $null +if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) { + $MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists" +} else { + $MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists" +} + +$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain" +$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +$actualDistributionDir = "" + +# First try the expected directory name (for regular distributions) +$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain" +$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD" +if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) { + $actualDistributionDir = $distributionUrlNameMain +} + +# If not found, search for any directory with the Maven executable (for snapshots) +if (!$actualDistributionDir) { + Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object { + $testPath = Join-Path $_.FullName "bin/$MVN_CMD" + if (Test-Path -Path $testPath -PathType Leaf) { + $actualDistributionDir = $_.Name + } + } +} + +if (!$actualDistributionDir) { + Write-Error "Could not find Maven distribution directory in extracted archive" +} + +Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir" +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..e57c59a --- /dev/null +++ b/pom.xml @@ -0,0 +1,140 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + + 2.5.4 + + + com.gcc_it_cell_services + gcc-it-cell-services + 0.0.1-SNAPSHOT + gcc-it-cell-services + Springboot Project For GCC IT cell services + + + + + + + + + + + + + + + 17 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-data-rest + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + com.oracle.database.jdbc + ojdbc11 + runtime + + + com.mysql + mysql-connector-j + 8.0.33 + runtime + + + org.projectlombok + lombok + true + 1.18.32 + + + com.github.vladimir-bukhtoyarov + bucket4j-core + 7.6.0 + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter-security + 2.5.4 + + + org.springframework.security + spring-security-test + test + + + + + + gcc-it-cell-services + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + + org.projectlombok + lombok + 1.18.32 + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/gcc_it_cell_services/springboot/GccItCellServicesApplication.java b/src/main/java/com/gcc_it_cell_services/springboot/GccItCellServicesApplication.java new file mode 100644 index 0000000..0860f96 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/GccItCellServicesApplication.java @@ -0,0 +1,17 @@ +package com.gcc_it_cell_services.springboot; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.springframework.scheduling.annotation.EnableScheduling; + +@SpringBootApplication +@EnableJpaAuditing(auditorAwareRef = "auditorAware") +@EnableScheduling +public class GccItCellServicesApplication { + + public static void main(String[] args) { + SpringApplication.run(GccItCellServicesApplication.class, args); + } + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/configuration/AuditorAwareConfiguration.java b/src/main/java/com/gcc_it_cell_services/springboot/configuration/AuditorAwareConfiguration.java new file mode 100644 index 0000000..0818dc5 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/configuration/AuditorAwareConfiguration.java @@ -0,0 +1,41 @@ +package com.gcc_it_cell_services.springboot.configuration; + +import java.util.Optional; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.AuditorAware; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import com.gcc_it_cell_services.springboot.model.AppUser; +import com.gcc_it_cell_services.springboot.repository.AppUserRepository; + +@Component("auditorAware") +public class AuditorAwareConfiguration implements AuditorAware { + + @Autowired + private AppUserRepository appUsrRepo; + + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true) + public Optional getCurrentAuditor() { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + + if (authentication == null || !authentication.isAuthenticated()) { + return Optional.empty(); + } + + // If it's already AppUser, no need to hit DB + Object principal = authentication.getPrincipal(); + if (principal instanceof AppUser user) { + return Optional.of(user); + } + + // Fetch AppUser from DB using username + String username = authentication.getName(); + return appUsrRepo.findByUsrName(username); + } +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/configuration/RateLimitConfiguration.java b/src/main/java/com/gcc_it_cell_services/springboot/configuration/RateLimitConfiguration.java new file mode 100644 index 0000000..add12f0 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/configuration/RateLimitConfiguration.java @@ -0,0 +1,42 @@ +package com.gcc_it_cell_services.springboot.configuration; + +import java.time.Duration; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.springframework.context.annotation.Configuration; + +import io.github.bucket4j.Bandwidth; +import io.github.bucket4j.Bucket; + +@Configuration +public class RateLimitConfiguration { + + // Map to store buckets for each key + private final Map rateLimitCache = new ConcurrentHashMap(); + + public Bucket resolveBucket(String key) { + return rateLimitCache.computeIfAbsent(key, newKey -> createNewBucket(newKey)); + } + + private Bucket createNewBucket(String key) { + // Set different limits based on key type + if (key.startsWith("OTP_")) { + // OTP = 5 req/min + return Bucket.builder().addLimit(Bandwidth.simple(5, Duration.ofMinutes(1))).build(); + } else if (key.startsWith("LOGIN_")) { + // Login = 5 req/min + return Bucket.builder().addLimit(Bandwidth.simple(5, Duration.ofMinutes(1))).build(); + } else if (key.startsWith("IP_")) { + // Public IP = 35 req/min + return Bucket.builder().addLimit(Bandwidth.simple(35, Duration.ofMinutes(1))).build(); + } else if (key.startsWith("USER_")) { + // Authenticated = 50/min + return Bucket.builder().addLimit(Bandwidth.simple(35, Duration.ofMinutes(1))).build(); + } + + // Default fallback + return Bucket.builder().addLimit(Bandwidth.simple(40, Duration.ofMinutes(1))).build(); + } + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/configuration/SecurityConfiguration.java b/src/main/java/com/gcc_it_cell_services/springboot/configuration/SecurityConfiguration.java new file mode 100644 index 0000000..aa0c19a --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/configuration/SecurityConfiguration.java @@ -0,0 +1,136 @@ +package com.gcc_it_cell_services.springboot.configuration; + +import java.util.List; + +import javax.servlet.http.HttpSessionEvent; +import javax.servlet.http.HttpSessionListener; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.dao.DaoAuthenticationProvider; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.security.web.access.AccessDeniedHandler; +import org.springframework.security.web.csrf.CookieCsrfTokenRepository; + +import com.gcc_it_cell_services.springboot.service.HomeService; + +@Configuration +@EnableWebSecurity +public class SecurityConfiguration extends WebSecurityConfigurerAdapter { + + /* + * @Value("${app.security.force-https}") private boolean isForceHttps; + */ + + @Autowired + private HomeService homeSer; + + // List of all admin-only endpoints + private final List adminEndpoints = List.of("/urls/add-url-data", "/urls/upd-url-data", "/api/urls/**"); + + @Bean + @Override + protected AuthenticationManager authenticationManager() throws Exception { + return super.authenticationManager(); + } + + // Return 404 for unauthenticated requests to admin endpoints + private final AuthenticationEntryPoint notFoundEntryPoint = (req, res, authException) -> { + if (adminEndpoints.contains(req.getRequestURI())) { + res.sendError(404); // hide existence + } else { + res.sendRedirect(req.getContextPath() + "/login"); // fallback for login for other endpoints + } + }; + + // Return 404 for access denied on admin endpoints + private final AccessDeniedHandler adminNotFoundAccessDeniedHandler = (req, res, accessDeniedException) -> { + if (adminEndpoints.contains(req.getRequestURI())) { + res.sendError(404); // hide existence + } else { + res.sendRedirect(req.getContextPath() + "/login"); // fallback for login for other endpoints + } + }; + + @Bean + PasswordEncoder passwordEncoder() { + return new BCryptPasswordEncoder(12); + } + + @Bean + public DaoAuthenticationProvider daoAuthProvider() { + DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); + provider.setUserDetailsService(homeSer); + provider.setPasswordEncoder(passwordEncoder()); + provider.setHideUserNotFoundExceptions(false); // THIS FIXES USER NOT FOUND EXCEPTION ISSUE + return provider; + } + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.authenticationProvider(daoAuthProvider()); // use custom provider + } + + // disable default login form + @Override + protected void configure(HttpSecurity http) throws Exception { + // CSRF with Cookie token repository + http.csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()); + + // Force HTTPS if enabled + // if (isForceHttps) { + /* http.redirectToHttps(withDefaults()); */ + // http.requiresChannel().anyRequest().requiresSecure(); + // } + + // Authorization rules + http.authorizeRequests().antMatchers("/urls/add-url-data", "/urls/upd-url-data", "/api/urls/**") + .hasRole("ADMIN") // Admin-only + .antMatchers("/api/val-app-usr-login", "/api/get-role", "/api/get-otp", "/api/verify-otp", + "/api/get-mob-num", "/clr-otp-ses", "/", "/redirect", "/login", "/view-login-det", + "/get-{urlCatName}-urls", "/usr-logout") + .permitAll() // Publicly accessible + .anyRequest().permitAll(); // Requires authentication for any other path + + // Session management + http.sessionManagement().sessionFixation().migrateSession() // Prevent session fixation attacks + .invalidSessionUrl("/") // Handle session expiration + .maximumSessions(2).maxSessionsPreventsLogin(true).and() + .sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED); // Limit concurrent logins + + // Exception handling + http.exceptionHandling().authenticationEntryPoint(notFoundEntryPoint) + .accessDeniedHandler(adminNotFoundAccessDeniedHandler); + + // Custom login/logout pages + http.formLogin().loginPage("/login").permitAll().failureUrl("/login"); // Redirect on failed login + http.logout().logoutUrl("/usr-logout").logoutSuccessUrl("/").invalidateHttpSession(true) + .clearAuthentication(true).permitAll(); + } + + // Set the session timeout duration programmatically + @Bean + public HttpSessionListener httpSessionListener() { + return new HttpSessionListener() { + @Override + public void sessionCreated(HttpSessionEvent event) { + // Set the timeout period (e.g., 30 minutes) + event.getSession().setMaxInactiveInterval(30 * 60); // 30 minutes + } + + @Override + public void sessionDestroyed(HttpSessionEvent event) { + // No specific action on session destruction + } + }; + } +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/configuration/WebConfiguration.java b/src/main/java/com/gcc_it_cell_services/springboot/configuration/WebConfiguration.java new file mode 100644 index 0000000..52d6fe3 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/configuration/WebConfiguration.java @@ -0,0 +1,37 @@ +package com.gcc_it_cell_services.springboot.configuration; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import com.gcc_it_cell_services.springboot.interceptor.RateLimitInterceptor; + +@Configuration +public class WebConfiguration implements WebMvcConfigurer { + + @Autowired + private RateLimitInterceptor rateLimitInterceptor; + + @Override + public void addInterceptors(InterceptorRegistry interceptorRegistry) { + // Fetch the application context path dynamically + String contextPath = System.getProperty("server.servlet.context-path", ""); + + // Define all paths for rate-limiting + String[] apiPaths = { "/api/**" }; + String[] publicPaths = { "/", "/login", "/view-login-det", "/redirect", "/urls/get-**" }; + + // Prepend context path dynamically + for (int i = 0; i < apiPaths.length; i++) { + apiPaths[i] = contextPath + apiPaths[i]; + } + for (int i = 0; i < publicPaths.length; i++) { + publicPaths[i] = contextPath + publicPaths[i]; + } + + // Register interceptor for API + public paths + interceptorRegistry.addInterceptor(rateLimitInterceptor).addPathPatterns(apiPaths).addPathPatterns(publicPaths); + } + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/controller/HomeController.java b/src/main/java/com/gcc_it_cell_services/springboot/controller/HomeController.java new file mode 100644 index 0000000..72e82a6 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/controller/HomeController.java @@ -0,0 +1,70 @@ +package com.gcc_it_cell_services.springboot.controller; + +import java.io.IOException; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.Authentication; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +import com.gcc_it_cell_services.springboot.response_dto.UrlDataResponseDTO; +import com.gcc_it_cell_services.springboot.service.UrlDataService; + +@Controller +@RequestMapping("/") +public class HomeController { + + @Autowired + private UrlDataService urlDataSer; + + @GetMapping({ "/", "" }) + public String home(Model model, Authentication auth) { + List urls = urlDataSer.getAllUrls(); + // Add role information to the model for conditional navbar rendering + boolean isAdmin = auth != null + && auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ROLE_ADMIN")); + model.addAttribute("isAdmin", isAdmin); + model.addAttribute("curPage", "home"); + model.addAttribute("urls", urls); + return "home/home"; + } + + @GetMapping("/login") + public String login() { + return "home/login"; + } + + @GetMapping("/view-login-det") + public String viewLoginDet(Model model, Authentication auth) { + // Add role information to the model for conditional navbar rendering + boolean isAdmin = auth != null + && auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ROLE_ADMIN")); + model.addAttribute("isAdmin", isAdmin); + List urls = urlDataSer.getAllUrlsWithUsrNameAndPass(); + model.addAttribute("urls", urls); + model.addAttribute("curPage", "view-login-det"); + return "home/view-login-details"; + } + + @GetMapping("/redirect") + public void usrRedirect(Authentication auth, HttpServletResponse res, HttpServletRequest req) throws IOException { + if (auth == null || !auth.isAuthenticated()) { + res.sendError(404); // hide endpoint if not logged in + return; + } + boolean isAdmin = auth != null + && auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ROLE_ADMIN")); + if (isAdmin) { + res.sendRedirect(req.getContextPath() + "/"); // admin goes to home + } else { + res.sendError(404); // non-admin users → hide endpoint + } + } + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/controller/UrlDataController.java b/src/main/java/com/gcc_it_cell_services/springboot/controller/UrlDataController.java new file mode 100644 index 0000000..fee7ef0 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/controller/UrlDataController.java @@ -0,0 +1,61 @@ +package com.gcc_it_cell_services.springboot.controller; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.Authentication; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; + +import com.gcc_it_cell_services.springboot.response_dto.StatusResponseDTO; +import com.gcc_it_cell_services.springboot.response_dto.UrlDataResponseDTO; +import com.gcc_it_cell_services.springboot.service.UrlDataService; + +@Controller +@RequestMapping({ "/urls", "/itcell/urls" }) +public class UrlDataController { + + @Autowired + private UrlDataService urlDataSer; + + @GetMapping("/add-url-data") + public String addUrl(Model model, Authentication auth) { + // Add role information to the model for conditional navbar rendering + boolean isAdmin = auth != null + && auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ROLE_ADMIN")); + model.addAttribute("isAdmin", isAdmin); + model.addAttribute("curPage", "add-url"); + return "urls/add-url-data"; + } + + @GetMapping("/get-{urlCatName}-urls") + public String getUrlsByCategory(@PathVariable("urlCatName") String urlCatName, Model model, Authentication auth) { + // Add role information to the model for conditional navbar rendering + urlCatName = urlCatName.replace("-", " "); + List urls = urlDataSer.getUrlsByUrlCatName(urlCatName); + urlCatName = urls.get(0).getUrlCatResDTO().getUrlCatName(); + boolean isAdmin = auth != null + && auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ROLE_ADMIN")); + model.addAttribute("isAdmin", isAdmin); + model.addAttribute("urlCatName", urlCatName); + model.addAttribute("urls", urls); + return "urls/get-urls-by-url-category"; // Thymeleaf view name + } + + @GetMapping("/upd-url-data") + public String updUrl(Model model, Authentication auth) { + // Add role information to the model for conditional navbar rendering + List urls = urlDataSer.getAllUrlsSortedByUrlName(); + List stats = urlDataSer.getAllStats(); + boolean isAdmin = auth != null + && auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ROLE_ADMIN")); + model.addAttribute("isAdmin", isAdmin); + model.addAttribute("curPage", "upd-url"); + model.addAttribute("stats", stats); + model.addAttribute("urls", urls); + return "urls/update-url-data"; + } +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/interceptor/RateLimitInterceptor.java b/src/main/java/com/gcc_it_cell_services/springboot/interceptor/RateLimitInterceptor.java new file mode 100644 index 0000000..55de5be --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/interceptor/RateLimitInterceptor.java @@ -0,0 +1,102 @@ +package com.gcc_it_cell_services.springboot.interceptor; + +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gcc_it_cell_services.springboot.configuration.RateLimitConfiguration; +import com.gcc_it_cell_services.springboot.util.MobileNumberTokenStore; + +import io.github.bucket4j.Bucket; + +@Component +public class RateLimitInterceptor implements HandlerInterceptor { + + private final RateLimitConfiguration rateLimitConfig; + private final MobileNumberTokenStore mobNumTokenStore; + + public RateLimitInterceptor(RateLimitConfiguration rateLimitConfig, MobileNumberTokenStore mobNumTokenStore) { + this.rateLimitConfig = rateLimitConfig; + this.mobNumTokenStore = mobNumTokenStore; + } + + @Override + public boolean preHandle(HttpServletRequest req, HttpServletResponse res, Object handler) throws Exception { + String key = extractKey(req); + Bucket bucket = rateLimitConfig.resolveBucket(key); + if (bucket.tryConsume(1)) { + // allow request + return true; + } + + res.setStatus(429); + res.setContentType("application/json"); // <--- important + Map resObj = new HashMap(); + resObj.put("result", false); + resObj.put("error", "Too many requests - Please try after some time"); + + // Write JSON + ObjectMapper mapper = new ObjectMapper(); + res.getWriter().write(mapper.writeValueAsString(resObj)); + return false; + } + + private String extractKey(HttpServletRequest req) { + String uri = req.getRequestURI(); + String contextPath = req.getContextPath(); + if (uri.startsWith(contextPath)) { + uri = uri.substring(contextPath.length()); + } + + // OTP endpoints → per mobile number + if (uri.matches("/api/(get|verify)-otp")) { + String mobNumId = req.getParameter("mobNumId"); + if (mobNumId != null && !mobNumId.trim().isBlank()) { + // Retrieve actual mobile number from MobileNumberTokenStore + String mobNum = mobNumTokenStore.getMobNum(mobNumId); + if (mobNum != null && !mobNum.trim().isBlank()) { + return "OTP_" + mobNum; + } + } + } + + // Login endpoint → per username + if (uri.contains("/api/val-app-usr-login")) { + String usrName = req.getParameter("usrName"); + if (usrName != null && !usrName.trim().isBlank()) { + return "LOGIN_" + usrName; + } + } + + // Admin endpoints → per authenticated username + if (uri.startsWith("/urls/") || uri.startsWith("/api/urls/") || uri.startsWith("/itcell/urls/")) { + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + if (auth != null && auth.isAuthenticated() && !"anonymousUser".equals(auth.getName())) { + return "USER_" + auth.getName(); + } + } + + // Authenticated endpoints → per username + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + if (auth != null && auth.isAuthenticated() && !"anonymousUser".equals(auth.getName())) { + return "USER_" + auth.getName(); + } + + // Dynamic public endpoints → fallback to IP + if (uri.matches("/urls/get-[a-zA-Z0-9\\-]+-urls")) { + return "IP_" + req.getRemoteAddr(); + } + + // Public endpoints → fallback to IP + return "IP_" + req.getRemoteAddr(); + } + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/mapper/OtpLogMapper.java b/src/main/java/com/gcc_it_cell_services/springboot/mapper/OtpLogMapper.java new file mode 100644 index 0000000..86774fd --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/mapper/OtpLogMapper.java @@ -0,0 +1,38 @@ +package com.gcc_it_cell_services.springboot.mapper; + +import org.springframework.stereotype.Component; + +import com.gcc_it_cell_services.springboot.model.OtpLog; +import com.gcc_it_cell_services.springboot.request_dto.OtpLogRequestDTO; +import com.gcc_it_cell_services.springboot.response_dto.OtpLogResponseDTO; + +@Component +public class OtpLogMapper { + + public OtpLog toOtpLogEnt(OtpLogRequestDTO otpLogReqDTO) { + OtpLog otpLog = new OtpLog(); + otpLog.setOtp(otpLogReqDTO.getOtp()); + otpLog.setOtpStat(otpLogReqDTO.getOtpStat()); + otpLog.setOtpReqMobNum(otpLogReqDTO.getOtpReqMobNum()); + otpLog.setOtpResMobNum(otpLogReqDTO.getOtpResMobNum()); + otpLog.setOtpLogMsg(otpLogReqDTO.getOtpLogMsg()); + return otpLog; + } + + public OtpLog toOtpLogEnt(OtpLogResponseDTO otpLogResDTO) { + OtpLog otpLog = new OtpLog(); + otpLog.setLogId(otpLogResDTO.getLogId()); + otpLog.setOtp(otpLogResDTO.getOtp()); + otpLog.setOtpLogMsg(otpLogResDTO.getOtpLogMsg()); + otpLog.setOtpReqMobNum(otpLogResDTO.getOtpReqMobNum()); + otpLog.setOtpResMobNum(otpLogResDTO.getOtpResMobNum()); + otpLog.setOtpStat(otpLogResDTO.getOtpStat()); + return otpLog; + } + + public OtpLogResponseDTO toOtpLogResDTO(OtpLog otpLog) { + return new OtpLogResponseDTO(otpLog.getLogId(), otpLog.getOtp(), otpLog.getOtpStat(), otpLog.getOtpReqMobNum(), + otpLog.getOtpResMobNum(), otpLog.getOtpLogMsg()); + } + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/mapper/StatusMapper.java b/src/main/java/com/gcc_it_cell_services/springboot/mapper/StatusMapper.java new file mode 100644 index 0000000..15888bb --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/mapper/StatusMapper.java @@ -0,0 +1,19 @@ +package com.gcc_it_cell_services.springboot.mapper; + +import org.springframework.stereotype.Component; + +import com.gcc_it_cell_services.springboot.model.Status; +import com.gcc_it_cell_services.springboot.response_dto.StatusResponseDTO; + +@Component +public class StatusMapper { + + public StatusResponseDTO toStatResDTO(Status stat) { + return new StatusResponseDTO(stat.getStatId(), stat.getStatName()); + } + + public Status toStatEnt(StatusResponseDTO statResDTO) { + return new Status(statResDTO.getStatId(), statResDTO.getStatName()); + } + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/mapper/UrlCategoryMapper.java b/src/main/java/com/gcc_it_cell_services/springboot/mapper/UrlCategoryMapper.java new file mode 100644 index 0000000..3bc070f --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/mapper/UrlCategoryMapper.java @@ -0,0 +1,29 @@ +package com.gcc_it_cell_services.springboot.mapper; + +import org.springframework.stereotype.Component; + +import com.gcc_it_cell_services.springboot.model.UrlCategory; +import com.gcc_it_cell_services.springboot.request_dto.UrlCategoryRequestDTO; +import com.gcc_it_cell_services.springboot.response_dto.UrlCategoryResponseDTO; + +@Component +public class UrlCategoryMapper { + + public UrlCategoryResponseDTO toUrlCatResDTO(UrlCategory urlCat) { + return new UrlCategoryResponseDTO(urlCat.getUrlCatId(), urlCat.getUrlCatName()); + } + + public UrlCategory toUrlCatEnt(UrlCategoryRequestDTO urlCatReqDTO) { + UrlCategory urlCat = new UrlCategory(); + urlCat.setUrlCatName(urlCatReqDTO.getUrlCatName()); + return urlCat; + } + + public UrlCategory toUrlCatEnt(UrlCategoryResponseDTO urlCatResDTO) { + UrlCategory urlCat = new UrlCategory(); + urlCat.setUrlCatId(urlCatResDTO.getUrlCatId()); + urlCat.setUrlCatName(urlCatResDTO.getUrlCatName()); + return urlCat; + } + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/mapper/UrlDataMapper.java b/src/main/java/com/gcc_it_cell_services/springboot/mapper/UrlDataMapper.java new file mode 100644 index 0000000..a7df1c8 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/mapper/UrlDataMapper.java @@ -0,0 +1,48 @@ +package com.gcc_it_cell_services.springboot.mapper; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.gcc_it_cell_services.springboot.model.UrlData; +import com.gcc_it_cell_services.springboot.request_dto.UrlDataRequestDTO; +import com.gcc_it_cell_services.springboot.response_dto.UrlDataResponseDTO; + +@Component +public class UrlDataMapper { + + @Autowired + private UrlCategoryMapper urlCatMap; + + @Autowired + private StatusMapper statMap; + + public UrlData toUrlDatEnt(UrlDataRequestDTO urlDataReqDTO) { + UrlData urlData = new UrlData(); + urlData.setUrlDataLink(urlDataReqDTO.getUrlDataLink()); + urlData.setUrlDataName(urlDataReqDTO.getUrlDataName()); + urlData.setUrlDataUsrName(urlDataReqDTO.getUrlDataUsrName()); + urlData.setUrlDataUsrPass(urlDataReqDTO.getUrlDataUsrPass()); + urlData.setUrlCat(urlCatMap.toUrlCatEnt(urlDataReqDTO.getUrlCatResDTO())); + urlData.setStatId(statMap.toStatEnt(urlDataReqDTO.getStatResDTO())); + return urlData; + } + + public UrlDataResponseDTO toUrlDataResDTO(UrlData urlData) { + return new UrlDataResponseDTO(urlData.getUrlDataId(), urlData.getUrlDataName(), urlData.getUrlDataLink(), + urlData.getUrlDataUsrPass(), urlData.getUrlDataUsrName(), urlCatMap.toUrlCatResDTO(urlData.getUrlCat()), + statMap.toStatResDTO(urlData.getStatId())); + } + + public UrlData toUrlDatEnt(UrlDataResponseDTO urlDataResDTO) { + // TODO Auto-generated method stub + UrlData urlData = new UrlData(); + urlData.setUrlDataId(urlDataResDTO.getUrlDataId()); + urlData.setUrlDataLink(urlDataResDTO.getUrlDataLink()); + urlData.setUrlDataName(urlDataResDTO.getUrlDataName()); + urlData.setUrlDataUsrName(urlDataResDTO.getUrlDataUsrName()); + urlData.setUrlDataUsrPass(urlDataResDTO.getUrlDataUsrPass()); + urlData.setUrlCat(urlCatMap.toUrlCatEnt(urlDataResDTO.getUrlCatResDTO())); + urlData.setStatId(statMap.toStatEnt(urlDataResDTO.getStatResDTO())); + return urlData; + } +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/model/AppUser.java b/src/main/java/com/gcc_it_cell_services/springboot/model/AppUser.java new file mode 100644 index 0000000..8bcac43 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/model/AppUser.java @@ -0,0 +1,70 @@ +package com.gcc_it_cell_services.springboot.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.validation.constraints.NotBlank; + +import com.fasterxml.jackson.annotation.JsonBackReference; + +// import jakarta.validation.constraints.NotBlank; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Entity +// @Table(name = "tbl_app_usr_det_2", schema = "fileadjust") +@Table(name = "tbl_app_usr_det") +/* @Table(name = "tbl_app_usr_det", schema = "gcc") */ +@Getter +@Setter +@ToString(doNotUseGetters = true, includeFieldNames = true, exclude = { "usrRole", "usrPass", "mobStatId", + "usrStatId" }) +@NoArgsConstructor +@AllArgsConstructor +public class AppUser { + @Id + @Column(name = "usr_id", nullable = false, updatable = false) + @GeneratedValue(strategy = GenerationType.IDENTITY) + /* + * @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = + * "app_usr_seq_2") + * + * @SequenceGenerator(name = "app_usr_seq_2", sequenceName = "app_usr_id_seq_2", + * allocationSize = 1) + */ + private Integer usrId; + + @Column(name = "usr_name", nullable = false) + @NotBlank + private String usrName; + + @Column(name = "usr_pass", nullable = false) + @NotBlank + private String usrPass; + + @Column(name = "usr_mob_num", nullable = false) + @NotBlank + private String usrMobNum; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "mob_stat_id", referencedColumnName = "stat_id", nullable = false) + private Status mobStatId; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "usr_stat_id", referencedColumnName = "stat_id", nullable = false) + private Status usrStatId; + + @ManyToOne + @JoinColumn(name = "usr_role_id", nullable = false, referencedColumnName = "usr_role_id") + @JsonBackReference + private UserRole usrRole; +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/model/OtpLog.java b/src/main/java/com/gcc_it_cell_services/springboot/model/OtpLog.java new file mode 100644 index 0000000..0577c46 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/model/OtpLog.java @@ -0,0 +1,102 @@ +package com.gcc_it_cell_services.springboot.model; + +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EntityListeners; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Entity +@EntityListeners(AuditingEntityListener.class) +@Table(name = "tbl_otp_log_det") +@Getter +@Setter +@ToString(doNotUseGetters = true, includeFieldNames = true) +@AllArgsConstructor +@NoArgsConstructor +public class OtpLog { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "log_id", nullable = false, updatable = false) + private Integer logId; + + @Column(name = "otp", nullable = false, updatable = false) + @NotNull + private Integer otp; + + @Column(name = "otp_stat", nullable = false) + @NotBlank + private String otpStat; + + @Column(name = "otp_req_mob_num", nullable = false, updatable = false) + @NotBlank + private String otpReqMobNum; + + @Column(name = "otp_res_mob_num", nullable = false) + @NotBlank + private String otpResMobNum; + + @Column(name = "otp_log_msg", nullable = false) + @NotBlank + private String otpLogMsg; + + // User timestamp + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "usr_req_timestamp", nullable = false, updatable = false, columnDefinition = "TIMESTAMP(0)") + private Date usrReqTimestamp; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "usr_res_timestamp", nullable = false, columnDefinition = "TIMESTAMP(0)") + private Date usrResTimestamp; + + // DB-managed timestamps + @CreatedDate + @Temporal(TemporalType.TIMESTAMP) + @Column(updatable = false, nullable = false, name = "db_req_timestamp", columnDefinition = "TIMESTAMP(0)") + private Date dbReqTimestamp; + + @LastModifiedDate + @Temporal(TemporalType.TIMESTAMP) + @Column(nullable = false, name = "db_res_timestamp", columnDefinition = "TIMESTAMP(0)") + private Date dbResTimestamp; + + @PrePersist + public void onCreate() { + Date now = Date.from(Instant.now().truncatedTo(ChronoUnit.SECONDS)); + this.usrReqTimestamp = now; + this.usrResTimestamp = now; + this.dbReqTimestamp = now; + this.dbResTimestamp = now; + } + + @PreUpdate + public void onUpdate() { + Date now = Date.from(Instant.now().truncatedTo(ChronoUnit.SECONDS)); + this.usrResTimestamp = now; + this.dbResTimestamp = now; + } + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/model/Status.java b/src/main/java/com/gcc_it_cell_services/springboot/model/Status.java new file mode 100644 index 0000000..fe48ea5 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/model/Status.java @@ -0,0 +1,35 @@ +package com.gcc_it_cell_services.springboot.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.validation.constraints.NotBlank; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Entity +@ToString(includeFieldNames = true, doNotUseGetters = true) +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Table(name = "tbl_stat_det") +public class Status { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "stat_id", nullable = false, updatable = false) + private Long statId; + + @Column(name = "stat_name", nullable = false) + @NotBlank + private String statName; + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/model/UrlCategory.java b/src/main/java/com/gcc_it_cell_services/springboot/model/UrlCategory.java new file mode 100644 index 0000000..7fc4fbc --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/model/UrlCategory.java @@ -0,0 +1,106 @@ +package com.gcc_it_cell_services.springboot.model; + +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.Date; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EntityListeners; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.validation.constraints.NotBlank; + +import org.springframework.data.annotation.CreatedBy; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedBy; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import com.fasterxml.jackson.annotation.JsonManagedReference; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Entity +@Table(name = "tbl_url_cat_det") +@Getter +@Setter +@ToString(includeFieldNames = true, doNotUseGetters = true, exclude = { "urlDatas", "createdBy", "updatedBy" }) +@AllArgsConstructor +@NoArgsConstructor +@EntityListeners(AuditingEntityListener.class) +public class UrlCategory { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "url_cat_id", nullable = false, updatable = false) + private Long urlCatId; + + @Column(name = "url_cat_name", nullable = false) + @NotBlank + private String urlCatName; + + @OneToMany(mappedBy = "urlCat", orphanRemoval = true, cascade = CascadeType.ALL) + @JsonManagedReference + private List urlDatas; + + @CreatedBy + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "created_by_usr_id", referencedColumnName = "usr_id", updatable = false, nullable = false) + private AppUser createdBy; + + @LastModifiedBy + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "updated_by_usr_id", referencedColumnName = "usr_id", nullable = false) + private AppUser updatedBy; + + // User timestamp + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "usr_created_timestamp", nullable = false, updatable = false, columnDefinition = "TIMESTAMP(0)") + private Date usrCreatedTimestamp; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "usr_updated_timestamp", nullable = false, columnDefinition = "TIMESTAMP(0)") + private Date usrUpdatedTimestamp; + + // DB-managed timestamps + @CreatedDate + @Temporal(TemporalType.TIMESTAMP) + @Column(updatable = false, nullable = false, name = "db_created_timestamp", columnDefinition = "TIMESTAMP(0)") + private Date dbCreatedTimestamp; + + @LastModifiedDate + @Temporal(TemporalType.TIMESTAMP) + @Column(nullable = false, name = "db_updated_timestamp", columnDefinition = "TIMESTAMP(0)") + private Date dbUpdatedTimestamp; + + @PrePersist + public void onCreate() { + Date now = Date.from(Instant.now().truncatedTo(ChronoUnit.SECONDS)); + this.usrCreatedTimestamp = now; + this.usrUpdatedTimestamp = now; + } + + @PreUpdate + public void onUpdate() { + Date now = Date.from(Instant.now().truncatedTo(ChronoUnit.SECONDS)); + this.usrUpdatedTimestamp = now; + } + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/model/UrlData.java b/src/main/java/com/gcc_it_cell_services/springboot/model/UrlData.java new file mode 100644 index 0000000..29e115d --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/model/UrlData.java @@ -0,0 +1,136 @@ +package com.gcc_it_cell_services.springboot.model; + +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EntityListeners; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.validation.constraints.NotBlank; + +import org.springframework.data.annotation.CreatedBy; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedBy; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import com.fasterxml.jackson.annotation.JsonBackReference; + +// import jakarta.persistence.Column; +// import jakarta.persistence.Entity; +// import jakarta.persistence.GeneratedValue; +// import jakarta.persistence.GenerationType; +// import jakarta.persistence.Id; +// import jakarta.persistence.SequenceGenerator; +// import jakarta.persistence.Table; +// import jakarta.validation.constraints.NotBlank; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Entity +@AllArgsConstructor +@NoArgsConstructor +@EntityListeners(AuditingEntityListener.class) +@Getter +@Setter +@ToString(doNotUseGetters = true, includeFieldNames = true, exclude = { "urlCat", "createdBy", "updatedBy", "statId" }) +// @Table(name = "tbl_url_data_det", schema = "fileadjust") +@Table(name = "tbl_url_data_det") +public class UrlData { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + /* + * @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = + * "url_data_seq") + * + * @SequenceGenerator(name = "url_data_seq", sequenceName = "url_data_id_seq", + * allocationSize = 1) + */ + @Column(name = "url_data_id", nullable = false, updatable = false) + private Long urlDataId; + + @Column(name = "url_data_link", nullable = false) + @NotBlank + private String urlDataLink; + + @Column(name = "url_data_name", nullable = false) + @NotBlank + private String urlDataName; + + @Column(name = "url_data_usr_pass", nullable = false) + @NotBlank + private String urlDataUsrPass; + + @Column(name = "url_data_usr_name", nullable = false) + @NotBlank + private String urlDataUsrName; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "url_cat_id", referencedColumnName = "url_cat_id", nullable = false) + @JsonBackReference + private UrlCategory urlCat; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "stat_id", referencedColumnName = "stat_id", nullable = false) + private Status statId; + + @CreatedBy + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "created_by_usr_id", referencedColumnName = "usr_id", updatable = false, nullable = false) + private AppUser createdBy; + + @LastModifiedBy + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "updated_by_usr_id", referencedColumnName = "usr_id", nullable = false) + private AppUser updatedBy; + + // User timestamp + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "usr_created_timestamp", nullable = false, updatable = false, columnDefinition = "TIMESTAMP(0)") + private Date usrCreatedTimestamp; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "usr_updated_timestamp", nullable = false, columnDefinition = "TIMESTAMP(0)") + private Date usrUpdatedTimestamp; + + // DB-managed timestamps + @CreatedDate + @Temporal(TemporalType.TIMESTAMP) + @Column(updatable = false, nullable = false, name = "db_created_timestamp", columnDefinition = "TIMESTAMP(0)") + private Date dbCreatedTimestamp; + + @LastModifiedDate + @Temporal(TemporalType.TIMESTAMP) + @Column(nullable = false, name = "db_updated_timestamp", columnDefinition = "TIMESTAMP(0)") + private Date dbUpdatedTimestamp; + + @PrePersist + public void onCreate() { + Date now = Date.from(Instant.now().truncatedTo(ChronoUnit.SECONDS)); + this.usrCreatedTimestamp = now; + this.usrUpdatedTimestamp = now; + } + + @PreUpdate + public void onUpdate() { + Date now = Date.from(Instant.now().truncatedTo(ChronoUnit.SECONDS)); + this.usrUpdatedTimestamp = now; + } + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/model/UserRole.java b/src/main/java/com/gcc_it_cell_services/springboot/model/UserRole.java new file mode 100644 index 0000000..ad644c8 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/model/UserRole.java @@ -0,0 +1,66 @@ +package com.gcc_it_cell_services.springboot.model; + +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.validation.constraints.NotBlank; + +import com.fasterxml.jackson.annotation.JsonManagedReference; + +// import jakarta.persistence.CascadeType; +// import jakarta.persistence.Column; +// import jakarta.persistence.Entity; +// import jakarta.persistence.FetchType; +// import jakarta.persistence.GeneratedValue; +// import jakarta.persistence.GenerationType; +// import jakarta.persistence.Id; +// import jakarta.persistence.OneToMany; +// import jakarta.persistence.SequenceGenerator; +// import jakarta.persistence.Table; +// import jakarta.validation.constraints.NotBlank; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Entity +@ToString(includeFieldNames = true, doNotUseGetters = true, exclude = { "appUsrs" }) +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +/* @Table(name = "tbl_usr_role_det", schema = "gcc") */ +// @Table(name = "tbl_usr_role_det_2", schema = "fileadjust") +@Table(name = "tbl_usr_role_det") +public class UserRole { + + @Id + @Column(name = "usr_role_id", nullable = false, updatable = false) + @GeneratedValue(strategy = GenerationType.IDENTITY) + /* + * @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = + * "usr_role_seq_2") + * + * @SequenceGenerator(name = "usr_role_seq_2", sequenceName = + * "usr_role_id_seq_2", allocationSize = 1) + */ + private Integer usrRoleId; + + @Column(name = "usr_role_name", nullable = false) + @NotBlank + private String usrRoleName; + + @OneToMany(mappedBy = "usrRole", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) + @JsonManagedReference + private List appUsrs; + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/repository/AppUserRepository.java b/src/main/java/com/gcc_it_cell_services/springboot/repository/AppUserRepository.java new file mode 100644 index 0000000..02cdeac --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/repository/AppUserRepository.java @@ -0,0 +1,25 @@ +package com.gcc_it_cell_services.springboot.repository; + +import java.util.List; +import java.util.Optional; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import com.gcc_it_cell_services.springboot.model.AppUser; + +@Repository +public interface AppUserRepository extends JpaRepository { + Optional findByUsrName(String usrName); + + @Query(value = """ + SELECT CASE WHEN COUNT(*) > 0 THEN TRUE ELSE FALSE END FROM tbl_app_usr_det + WHERE usr_mob_num = :mobNum """, nativeQuery = true) + Integer existsByUsrMobNum(@Param("mobNum") String mobNum); + + @Query("SELECT a.usrMobNum FROM AppUser a WHERE a.mobStatId.statId = 1") + List findAllMobNums(); + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/repository/OtpLogRepository.java b/src/main/java/com/gcc_it_cell_services/springboot/repository/OtpLogRepository.java new file mode 100644 index 0000000..7f48337 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/repository/OtpLogRepository.java @@ -0,0 +1,15 @@ +package com.gcc_it_cell_services.springboot.repository; + +import java.util.Optional; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import com.gcc_it_cell_services.springboot.model.OtpLog; + +@Repository +public interface OtpLogRepository extends JpaRepository { + + Optional findTopByOtpReqMobNumOrderByDbReqTimestampDesc(String otpReqMobNum); + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/repository/StatusRepository.java b/src/main/java/com/gcc_it_cell_services/springboot/repository/StatusRepository.java new file mode 100644 index 0000000..2630fe9 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/repository/StatusRepository.java @@ -0,0 +1,11 @@ +package com.gcc_it_cell_services.springboot.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import com.gcc_it_cell_services.springboot.model.Status; + +@Repository +public interface StatusRepository extends JpaRepository { + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/repository/UrlCategoryRepository.java b/src/main/java/com/gcc_it_cell_services/springboot/repository/UrlCategoryRepository.java new file mode 100644 index 0000000..f8cffc0 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/repository/UrlCategoryRepository.java @@ -0,0 +1,18 @@ +package com.gcc_it_cell_services.springboot.repository; + +import java.util.Optional; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import com.gcc_it_cell_services.springboot.model.UrlCategory; + +@Repository +public interface UrlCategoryRepository extends JpaRepository { + + @Query(nativeQuery = true, value = "SELECT * FROM tbl_url_cat_det WHERE url_cat_name = ?1") + Optional findUrlCatByUrlCatName(@Param("urlCatName") String urlCatName); + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/repository/UrlDataRepository.java b/src/main/java/com/gcc_it_cell_services/springboot/repository/UrlDataRepository.java new file mode 100644 index 0000000..bcae735 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/repository/UrlDataRepository.java @@ -0,0 +1,28 @@ +package com.gcc_it_cell_services.springboot.repository; + +import java.util.List; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import com.gcc_it_cell_services.springboot.model.UrlData; + +@Repository +public interface UrlDataRepository extends JpaRepository { + + @Query(value = "SELECT u FROM UrlData u ORDER BY LOWER(u.urlDataName)") + List findAllUrlsSortedByUrlName(); + + @Query(nativeQuery = true, value = """ + SELECT * FROM tbl_url_data_det WHERE url_data_usr_name != '-' AND url_data_usr_pass != '-' ORDER BY LOWER(url_data_name) """) + List findAllUrlsWithUsrNameAndPass(); + + @Query("SELECT u FROM UrlData u WHERE u.urlCat.urlCatId = ?1 ORDER BY LOWER(u.urlDataName)") + List findAllUrlsByUrlCatId(@Param("urlCatId") Long urlCatId); + + @Query("SELECT COUNT(u) FROM UrlData u WHERE u.urlCat.urlCatId = :urlCatId ORDER BY LOWER(u.urlDataName)") + Integer findUrlCountByUrlCatId(@Param("urlCatId") Long urlCatId); + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/request_dto/AddUrlDataRequestDTO.java b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/AddUrlDataRequestDTO.java new file mode 100644 index 0000000..4678a47 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/AddUrlDataRequestDTO.java @@ -0,0 +1,22 @@ +package com.gcc_it_cell_services.springboot.request_dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@ToString(doNotUseGetters = true, includeFieldNames = true) +public class AddUrlDataRequestDTO { + + private String urlDataLink; + private String urlDataName; + private String urlDataUsrName; + private String urlDataUsrPass; + private String urlCatName; + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/request_dto/AppUserRequestDTO.java b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/AppUserRequestDTO.java new file mode 100644 index 0000000..ebe8fc0 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/AppUserRequestDTO.java @@ -0,0 +1,17 @@ +package com.gcc_it_cell_services.springboot.request_dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(doNotUseGetters = true, includeFieldNames = true) +@NoArgsConstructor +@AllArgsConstructor +public class AppUserRequestDTO { + private String usrName; + private String usrPass; +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/request_dto/GetOtpRequestDTO.java b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/GetOtpRequestDTO.java new file mode 100644 index 0000000..727c353 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/GetOtpRequestDTO.java @@ -0,0 +1,18 @@ +package com.gcc_it_cell_services.springboot.request_dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(doNotUseGetters = true, includeFieldNames = true) +@NoArgsConstructor +@AllArgsConstructor +public class GetOtpRequestDTO { + + private String mobNumId; // changed from mobNum to mobNumId (UUID) + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/request_dto/OtpLogRequestDTO.java b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/OtpLogRequestDTO.java new file mode 100644 index 0000000..40aa36d --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/OtpLogRequestDTO.java @@ -0,0 +1,22 @@ +package com.gcc_it_cell_services.springboot.request_dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(includeFieldNames = true, doNotUseGetters = true) +@NoArgsConstructor +@AllArgsConstructor +public class OtpLogRequestDTO { + + private Integer otp; + private String otpStat; + private String otpReqMobNum; + private String otpResMobNum; + private String otpLogMsg; + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/request_dto/UpdateUrlDataRequestDTO.java b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/UpdateUrlDataRequestDTO.java new file mode 100644 index 0000000..4fc423f --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/UpdateUrlDataRequestDTO.java @@ -0,0 +1,22 @@ +package com.gcc_it_cell_services.springboot.request_dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(doNotUseGetters = true, includeFieldNames = true) +@AllArgsConstructor +@NoArgsConstructor +public class UpdateUrlDataRequestDTO { + private Long urlDataId; + private String urlDataName; + private String urlDataLink; + private String urlDataUsrPass; + private String urlDataUsrName; + private String urlCatName; + private Long statId; +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/request_dto/UrlCategoryRequestDTO.java b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/UrlCategoryRequestDTO.java new file mode 100644 index 0000000..ec6465e --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/UrlCategoryRequestDTO.java @@ -0,0 +1,18 @@ +package com.gcc_it_cell_services.springboot.request_dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(doNotUseGetters = true, includeFieldNames = true) +@NoArgsConstructor +@AllArgsConstructor +public class UrlCategoryRequestDTO { + + private String urlCatName; + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/request_dto/UrlDataRequestDTO.java b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/UrlDataRequestDTO.java new file mode 100644 index 0000000..220a7da --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/UrlDataRequestDTO.java @@ -0,0 +1,26 @@ +package com.gcc_it_cell_services.springboot.request_dto; + +import com.gcc_it_cell_services.springboot.response_dto.StatusResponseDTO; +import com.gcc_it_cell_services.springboot.response_dto.UrlCategoryResponseDTO; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@ToString(doNotUseGetters = true, includeFieldNames = true) +public class UrlDataRequestDTO { + + private String urlDataLink; + private String urlDataName; + private String urlDataUsrPass; + private String urlDataUsrName; + private UrlCategoryResponseDTO urlCatResDTO; + private StatusResponseDTO statResDTO; + +} diff --git a/src/main/java/com/gcc_it_cell_services/springboot/request_dto/VerifyOtpRequestDTO.java b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/VerifyOtpRequestDTO.java new file mode 100644 index 0000000..68d96a1 --- /dev/null +++ b/src/main/java/com/gcc_it_cell_services/springboot/request_dto/VerifyOtpRequestDTO.java @@ -0,0 +1,19 @@ +package com.gcc_it_cell_services.springboot.request_dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(doNotUseGetters = true, includeFieldNames = true) +@AllArgsConstructor +@NoArgsConstructor +public class VerifyOtpRequestDTO { + + private Integer otp; + private String mobNumId; // send the mobNumId from + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/home/home.html b/src/main/resources/templates/home/home.html new file mode 100644 index 0000000..15e3b09 --- /dev/null +++ b/src/main/resources/templates/home/home.html @@ -0,0 +1,81 @@ + + + + + + + GCC IT Cell Services + + + + + + + + + + + + + + + + + + +
+
+ + +
+
+

GCC IT Cell Services

+
+
+ + + + +
+
+ + +
+ +
+ + + +
+
+
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/home/login.html b/src/main/resources/templates/home/login.html new file mode 100644 index 0000000..0ea6312 --- /dev/null +++ b/src/main/resources/templates/home/login.html @@ -0,0 +1,88 @@ + + + + + + + GCC IT Cell Services + + + + + + + + + + + + + + +
+ +

GREATER CHENNAI CORPORATION

+

பெருநகர சென்னை மாநகராட்சி

+
+

GCC IT CELL SERVICES

+
+

Login

+ +
+
+ +
+
+
+ +
+
+ +
+
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/home/view-login-details.html b/src/main/resources/templates/home/view-login-details.html new file mode 100644 index 0000000..b0f09f6 --- /dev/null +++ b/src/main/resources/templates/home/view-login-details.html @@ -0,0 +1,71 @@ + + + + + + + GCC IT Cell Services + + + + + + + + + + + + + + + +
+
+

Login Details

+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + +
S.NoURL NumberURL NameUsernamePassword
+ + +
+
+
+
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modals/login-modal.html b/src/main/resources/templates/modals/login-modal.html new file mode 100644 index 0000000..737fcbb --- /dev/null +++ b/src/main/resources/templates/modals/login-modal.html @@ -0,0 +1,30 @@ +
+ + +
\ No newline at end of file diff --git a/src/main/resources/templates/urls/add-url-data.html b/src/main/resources/templates/urls/add-url-data.html new file mode 100644 index 0000000..3735e0e --- /dev/null +++ b/src/main/resources/templates/urls/add-url-data.html @@ -0,0 +1,86 @@ + + + + + + + GCC IT Cell Services + + + + + + + + + + + + + + + + + + +
+
+
+ +
+

Add URL

+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + + + +
+
+
+
+ + +
+
+
+ +
+
+
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/urls/get-urls-by-url-category.html b/src/main/resources/templates/urls/get-urls-by-url-category.html new file mode 100644 index 0000000..1703c55 --- /dev/null +++ b/src/main/resources/templates/urls/get-urls-by-url-category.html @@ -0,0 +1,80 @@ + + + + + + + GCC IT Cell Services + + + + + + + + + + + + + + + + + +
+
+ + +
+
+

+
+
+ + + + +
+
+ + +
+ +
+ + + +
+
+
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/urls/update-url-data.html b/src/main/resources/templates/urls/update-url-data.html new file mode 100644 index 0000000..7549aec --- /dev/null +++ b/src/main/resources/templates/urls/update-url-data.html @@ -0,0 +1,110 @@ + + + + + + + GCC IT Cell Services + + + + + + + + + + + + + + + + + + +
+
+
+ +
+

Update URL

+
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + + + +
+
+
+
+ + +
+
+ + +
+
+
+ +
+
+
+
+ + + + + + + + + + + \ No newline at end of file