Compare commits
1 Commits
feature_de
...
feature_de
Author | SHA1 | Date |
---|---|---|
Akash Maurya | 151fab1aff |
|
@ -0,0 +1,2 @@
|
|||
/mvnw text eol=lf
|
||||
*.cmd text eol=crlf
|
|
@ -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/
|
|
@ -0,0 +1,4 @@
|
|||
#Thu Jan 23 15:22:40 IST 2025
|
||||
host=DESKTOP-28FDSKV
|
||||
process-id=24364
|
||||
user=Admin
|
|
@ -0,0 +1,33 @@
|
|||
!SESSION 2025-01-23 15:22:04.521 -----------------------------------------------
|
||||
eclipse.buildId=4.34.0.202411281622
|
||||
java.version=21.0.5
|
||||
java.vendor=Eclipse Adoptium
|
||||
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
|
||||
Framework arguments: -product org.springframework.boot.ide.branding.sts4
|
||||
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.springframework.boot.ide.branding.sts4
|
||||
|
||||
!ENTRY ch.qos.logback.classic 1 0 2025-01-23 15:22:09.229
|
||||
!MESSAGE Activated before the state location was initialized. Retry after the state location is initialized.
|
||||
|
||||
!ENTRY ch.qos.logback.classic 1 0 2025-01-23 15:22:41.314
|
||||
!MESSAGE Logback config file: C:\Users\Admin\Desktop\inbound-user-service\.metadata\.plugins\org.eclipse.m2e.logback\logback.2.7.0.20241001-1350.xml
|
||||
|
||||
!ENTRY org.eclipse.ui 2 0 2025-01-23 15:22:42.359
|
||||
!MESSAGE Warnings while parsing the commands from the 'org.eclipse.ui.commands' and 'org.eclipse.ui.actionDefinitions' extension points.
|
||||
!SUBENTRY 1 org.eclipse.ui 2 0 2025-01-23 15:22:42.359
|
||||
!MESSAGE Commands should really have a category: plug-in='org.springframework.tooling.boot.ls', id='spring.initializr.addStarters', categoryId='org.eclipse.lsp4e.commandCategory'
|
||||
|
||||
!ENTRY org.eclipse.ui 2 0 2025-01-23 15:22:43.054
|
||||
!MESSAGE Warnings while parsing the commands from the 'org.eclipse.ui.commands' and 'org.eclipse.ui.actionDefinitions' extension points.
|
||||
!SUBENTRY 1 org.eclipse.ui 2 0 2025-01-23 15:22:43.054
|
||||
!MESSAGE Commands should really have a category: plug-in='org.springframework.tooling.boot.ls', id='spring.initializr.addStarters', categoryId='org.eclipse.lsp4e.commandCategory'
|
||||
|
||||
!ENTRY org.eclipse.mylyn.tasks.ui 2 0 2025-01-23 15:22:49.112
|
||||
!MESSAGE No search provider was registered. Tasks search is not available.
|
||||
|
||||
!ENTRY org.eclipse.egit.ui 2 0 2025-01-23 15:22:51.519
|
||||
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
|
||||
user global configuration and to define the default location to store repositories: 'C:\Users\Admin'. If this is
|
||||
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
|
||||
EGit might behave differently since they see different configuration options.
|
||||
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
java
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<typeInfoHistroy/>
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<qualifiedTypeNameHistroy/>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<section name="Workbench">
|
||||
<section name="org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart">
|
||||
<item key="group_libraries" value="true"/>
|
||||
<item key="layout" value="2"/>
|
||||
<item key="rootMode" value="1"/>
|
||||
<item key="linkWithEditor" value="false"/>
|
||||
<item key="memento" value="<?xml version="1.0" encoding="UTF-8"?>
<packageExplorer group_libraries="1" layout="2" linkWithEditor="0" rootMode="1" workingSetName="">
<customFilters userDefinedPatternsEnabled="false">
<xmlDefinedFilters>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.StaticsFilter" isEnabled="false"/>
<child filterId="org.eclipse.buildship.ui.packageexplorer.filter.gradle.buildfolder" isEnabled="true"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.NonSharedProjectsFilter" isEnabled="false"/>
<child filterId="bndtools.jareditor.tempfiles.packageexplorer.filter" isEnabled="true"/>
<child filterId="org.eclipse.jdt.internal.ui.PackageExplorer.EmptyInnerPackageFilter" isEnabled="true"/>
<child filterId="org.eclipse.m2e.MavenModuleFilter" isEnabled="false"/>
<child filterId="org.eclipse.buildship.ui.packageexplorer.filter.gradle.subProject" isEnabled="true"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.ClosedProjectsFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.EmptyLibraryContainerFilter" isEnabled="true"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.PackageDeclarationFilter" isEnabled="true"/>
<child filterId="org.eclipse.pde.ui.BinaryProjectFilter1" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.LocalTypesFilter" isEnabled="false"/>
<child filterId="org.eclipse.pde.ui.ExternalPluginLibrariesFilter1" isEnabled="true"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.FieldsFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.NonJavaProjectsFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer_patternFilterId_.*" isEnabled="true"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.SyntheticMembersFilter" isEnabled="true"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.ContainedLibraryFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.internal.ui.PackageExplorer.HideInnerClassFilesFilter" isEnabled="true"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.DeprecatedMembersFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.ImportDeclarationFilter" isEnabled="true"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.NonJavaElementFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.LibraryFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.CuAndClassFileFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.internal.ui.PackageExplorer.EmptyPackageFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.NonPublicFilter" isEnabled="false"/>
</xmlDefinedFilters>
</customFilters>
</packageExplorer>"/>
|
||||
</section>
|
||||
</section>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<section name="Workbench">
|
||||
<section name="MavenProjectImportWizardPage">
|
||||
<list key="rootDirectory">
|
||||
</list>
|
||||
<list key="projectNameTemplate">
|
||||
<item value="[artifactId]"/>
|
||||
<item value="[artifactId]-TRUNK"/>
|
||||
<item value="[artifactId]-[version]"/>
|
||||
<item value="[groupId].[artifactId]"/>
|
||||
<item value="[groupId].[artifactId]-[version]"/>
|
||||
<item value="[name]"/>
|
||||
</list>
|
||||
</section>
|
||||
</section>
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
2025-01-23 15:22:51,288 [Worker-2: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is not available. Remote download required.
|
|
@ -0,0 +1,41 @@
|
|||
<configuration scan="true">
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>%date [%thread] %-5level %logger{35} - %msg%n</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>${org.eclipse.m2e.log.console.threshold:-OFF}</level> <!-- change to DEBUG to mimic '-consolelog' behaviour -->
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${org.eclipse.m2e.log.dir}/0.log</File>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
||||
<FileNamePattern>${org.eclipse.m2e.log.dir}/%i.log</FileNamePattern>
|
||||
<MinIndex>1</MinIndex>
|
||||
<MaxIndex>10</MaxIndex>
|
||||
</rollingPolicy>
|
||||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||
<MaxFileSize>10MB</MaxFileSize>
|
||||
</triggeringPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>%date [%thread] %-5level %logger{35} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="EclipseLog" class="org.eclipse.m2e.logback.appender.EclipseLogAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>WARN</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="MavenConsoleLog" class="org.eclipse.m2e.logback.appender.MavenConsoleAppender">
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="FILE" />
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="EclipseLog" />
|
||||
<appender-ref ref="MavenConsoleLog" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,2 @@
|
|||
#Cached timestamps
|
||||
#Thu Jan 23 15:23:11 IST 2025
|
|
@ -0,0 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<section name="Workbench">
|
||||
</section>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<section name="Workbench">
|
||||
<section name="ImportExportAction">
|
||||
<section name="ImportExportWizard.dialogBounds">
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<workingSetManager>
|
||||
<workingSet editPageId="org.eclipse.jdt.internal.ui.DynamicSourcesWorkingSet" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1737625966732_0" label="Java Main Sources" name="Java Main Sources"/>
|
||||
<workingSet editPageId="org.eclipse.jdt.internal.ui.DynamicSourcesWorkingSet" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1737625966755_1" label="Java Test Sources" name="Java Test Sources"/>
|
||||
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1737625969384_2" label="Window Working Set" name="Aggregate for window 1737625969383"/>
|
||||
</workingSetManager>
|
|
@ -0,0 +1,3 @@
|
|||
#Thu Jan 23 15:22:40 IST 2025
|
||||
org.eclipse.core.runtime=2
|
||||
org.eclipse.platform=4.34.0.v20241120-1800
|
|
@ -0,0 +1,19 @@
|
|||
# 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.
|
||||
wrapperVersion=3.3.2
|
||||
distributionType=only-script
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
|
|
@ -0,0 +1,259 @@
|
|||
#!/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.2
|
||||
#
|
||||
# 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:]'
|
||||
}
|
||||
|
||||
# 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 <"${0%/*}/.mvn/wrapper/maven-wrapper.properties"
|
||||
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.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${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
|
||||
esac
|
||||
|
||||
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||
[ -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
|
||||
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url"
|
||||
mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
|
||||
|
||||
clean || :
|
||||
exec_maven "$@"
|
|
@ -0,0 +1,149 @@
|
|||
<# : 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.2
|
||||
@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-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||
if ($env:MVNW_REPOURL) {
|
||||
$MVNW_REPO_PATTERN = if ($USE_MVND) { "/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_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain"
|
||||
if ($env:MAVEN_USER_HOME) {
|
||||
$MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain"
|
||||
}
|
||||
$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::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
|
||||
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -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"
|
|
@ -0,0 +1,135 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.4.1</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.sahyog.app.inbound</groupId>
|
||||
<artifactId>inbound-user-service</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>inbound-user-service</name>
|
||||
<description>project user management services in Spring Boot</description>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<spring-cloud.version>2021.0.3</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- START - Local dependency added 2021.0.3 -->
|
||||
<!-- <dependency>
|
||||
<groupId>com.sahyog.app.inbound</groupId>
|
||||
<artifactId>inbound-common-lib</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency> -->
|
||||
<!-- END - Local dependency -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- dependency added -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>2.0.1.Final</version> <!-- Latest version for javax.validation -->
|
||||
</dependency>
|
||||
|
||||
<!-- dependency added -->
|
||||
<!-- swagger -->
|
||||
<!--<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-ui</artifactId>
|
||||
<version>1.6.12</version>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- getter / setter -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jettison</groupId>
|
||||
<artifactId>jettison</artifactId>
|
||||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.dozer</groupId>
|
||||
<artifactId>dozer</artifactId>
|
||||
<version>5.5.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<image>
|
||||
<builder>paketobuildpacks/builder-jammy-base:latest</builder>
|
||||
</image>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
package com.sahyog.app.inbound.user;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class InboundUserServiceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(InboundUserServiceApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.sahyog.app.inbound.user.config;
|
||||
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class CorsConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**") // Allow CORS for all paths
|
||||
.allowedOrigins("*") // Allow requests from all origins
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH") // Allow specific HTTP methods
|
||||
.allowedHeaders("*") // Allow all headers
|
||||
.allowCredentials(false); // Disable credentials for wildcard origins
|
||||
}
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
package com.sahyog.app.inbound.user.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.sahyog.app.inbound.user.dto.MaterialMasterDTO;
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
import com.sahyog.app.inbound.user.model.Response;
|
||||
import com.sahyog.app.inbound.user.model.User;
|
||||
import com.sahyog.app.inbound.user.service.MaterialMasterService;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/materials")
|
||||
public class MaterialMasterController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MaterialMasterController.class);
|
||||
|
||||
@Autowired
|
||||
private MaterialMasterService materialMasterService;
|
||||
|
||||
// Process Material endpoint
|
||||
@PostMapping("/process")
|
||||
public Response<List<Map<String, Object>>> processMaterial(
|
||||
@RequestBody @Valid List<MaterialMasterDTO> dtos) {
|
||||
log.info("Received request to process materials with {} DTOs", dtos.size());
|
||||
|
||||
try {
|
||||
User currentUser = getCurrentUser(); // Fetch the current logged-in user
|
||||
log.debug("Current user: {}", currentUser);
|
||||
|
||||
// Call the service method and get the response
|
||||
Response<List<Map<String, Object>>> response = materialMasterService.processMaterial(dtos, currentUser);
|
||||
|
||||
log.info("Processed materials successfully");
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred while processing materials: {}", e.getMessage(), e);
|
||||
return Response.error("Failed to process materials");
|
||||
}
|
||||
}
|
||||
|
||||
private User getCurrentUser() {
|
||||
// Replace this with actual logic to fetch the current user
|
||||
User user = new User();
|
||||
user.setUserId(1); // Example user ID
|
||||
log.debug("Fetched current user: {}", user);
|
||||
return user;
|
||||
}
|
||||
|
||||
@GetMapping("/getAll")
|
||||
public Response<List<MaterialMasterDTO>> getAllMaterials() {
|
||||
log.info("Fetching all materials");
|
||||
|
||||
try {
|
||||
List<MaterialMasterDTO> materials = materialMasterService.getAllMaterials();
|
||||
log.info("Fetched {} materials successfully", materials.size());
|
||||
return Response.success(materials).withMessage("Fetched all materials successfully.");
|
||||
} catch (Exception e) {
|
||||
log.error("Error fetching all materials: {}", e.getMessage(), e);
|
||||
return Response.error("Failed to fetch all materials");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getByPlantIdAndMaterialId")
|
||||
public Response<MaterialMasterDTO> getMaterialByPlantIdAndMaterialId(
|
||||
@RequestParam("plantId") Short plantId,
|
||||
@RequestParam("materialId") Short materialId) {
|
||||
log.info("Fetching material with plantId: {} and materialId: {}", plantId, materialId);
|
||||
|
||||
try {
|
||||
MaterialMasterDTO material = materialMasterService.getMaterialByPlantIdAndMaterialId(plantId, materialId);
|
||||
log.info("Fetched material successfully for plantId: {} and materialId: {}", plantId, materialId);
|
||||
return Response.success(material).withMessage("Fetched material successfully.");
|
||||
} catch (Exception e) {
|
||||
log.error("Error fetching material for plantId: {} and materialId: {}", plantId, materialId, e);
|
||||
return Response.error("Failed to fetch material");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getAllWithFilter")
|
||||
public Response<Page<MaterialMasterDTO>> getMaterialsWithFilters(
|
||||
@RequestParam(required = false) String materialCode,
|
||||
@RequestParam(required = false) String materialGroup,
|
||||
@RequestParam(required = false) String materialGroupDesc,
|
||||
@RequestParam(required = false) Status status,
|
||||
@RequestParam(defaultValue = "0") int page,
|
||||
@RequestParam(defaultValue = "5") int size) {
|
||||
log.info("Fetching materials with filters: materialCode={}, materialGroup={}, materialGroupDesc={}, status={}",
|
||||
materialCode, materialGroup, materialGroupDesc, status);
|
||||
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(page, size);
|
||||
Page<MaterialMasterDTO> materials = materialMasterService.getMaterialsWithFilters(
|
||||
materialCode, materialGroup, materialGroupDesc, status, pageable);
|
||||
|
||||
log.info("Fetched {} materials successfully with filters", materials.getTotalElements());
|
||||
return Response.success(materials).withMessage("Fetched materials successfully.");
|
||||
} catch (Exception e) {
|
||||
log.error("Error fetching materials with filters", e);
|
||||
return Response.error("Failed to fetch materials with filters");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/materialdetails")
|
||||
public ResponseEntity<Response<Page<Map<String, Object>>>> getMaterialDetails(
|
||||
@RequestBody Map<String, Object> req, Pageable pageable) {
|
||||
log.info("Fetching material details with request: {}", req);
|
||||
|
||||
try {
|
||||
// Call the service to fetch material details
|
||||
Page<Map<String, Object>> materialDetails = materialMasterService.getMaterialDetails(req, pageable);
|
||||
|
||||
// Check if the result is empty and respond accordingly
|
||||
if (materialDetails.isEmpty()) {
|
||||
log.warn("No material details found for the provided filters: {}", req);
|
||||
return ResponseEntity.ok(new Response<>(204, "No material details found for the provided filters.", materialDetails));
|
||||
}
|
||||
|
||||
log.info("Fetched material details successfully");
|
||||
return ResponseEntity.ok(new Response<>(200, "Material details fetched successfully.", materialDetails));
|
||||
} catch (Exception e) {
|
||||
log.error("Error fetching material details", e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(
|
||||
new Response<>(500, "An error occurred while fetching material details. Please try again later.", null)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
package com.sahyog.app.inbound.user.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.sahyog.app.inbound.user.dto.PlantDTO;
|
||||
import com.sahyog.app.inbound.user.dto.PlantMasterDTO;
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
import com.sahyog.app.inbound.user.model.Response;
|
||||
import com.sahyog.app.inbound.user.model.User;
|
||||
import com.sahyog.app.inbound.user.service.PlantMasterService;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
@RestController
|
||||
@RequestMapping("/api/plant")
|
||||
public class PlantMasterController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PlantMasterController.class);
|
||||
|
||||
@Autowired
|
||||
private PlantMasterService plantMasterService;
|
||||
|
||||
@PostMapping("/create")
|
||||
public Response<List<Map<String, Object>>> processPlant(@RequestBody List<PlantDTO> dtos) {
|
||||
log.info("Received request to process Plant DTOs: {}", dtos);
|
||||
|
||||
try {
|
||||
User currentUser = getCurrentUser();
|
||||
log.debug("Current user: {}", currentUser);
|
||||
|
||||
// Call the service method and log the response
|
||||
Response<List<Map<String, Object>>> response = plantMasterService.processPlant(dtos, currentUser);
|
||||
log.info("Successfully processed Plant DTOs. Response: {}", response);
|
||||
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred while processing Plant DTOs: {}", e.getMessage(), e);
|
||||
return Response.error(500, "Failed to process Plant DTOs");
|
||||
}
|
||||
}
|
||||
|
||||
private User getCurrentUser() {
|
||||
log.debug("Fetching current user...");
|
||||
User user = new User();
|
||||
user.setUserId(1); // Example user ID
|
||||
log.debug("Fetched current user: {}", user);
|
||||
return user;
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
public Response<List<PlantDTO>> getPlantsByStatus(@RequestParam(value = "status", required = false) String status) {
|
||||
log.info("Received request to fetch plants by status: {}", status);
|
||||
|
||||
try {
|
||||
List<PlantDTO> plants;
|
||||
|
||||
if (status == null || status.equalsIgnoreCase("B")) {
|
||||
log.info("Fetching all plants as no specific status is provided");
|
||||
plants = plantMasterService.getAllPlants();
|
||||
} else {
|
||||
log.info("Fetching plants with status: {}", status);
|
||||
plants = plantMasterService.getPlantsByStatus(Status.valueOf(status.toUpperCase()));
|
||||
}
|
||||
|
||||
log.info("Successfully fetched plants. Count: {}", plants.size());
|
||||
return Response.success(plants).withMessage("Fetched plants successfully.");
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred while fetching plants: {}", e.getMessage(), e);
|
||||
return Response.error(500, "Failed to fetch plants");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getAllAndPlantWithStatusPagination")
|
||||
public Response<Page<PlantDTO>> getPlantsWithPagination(
|
||||
@RequestParam(defaultValue = "0") int pageNumber,
|
||||
@RequestParam(defaultValue = "10") int pageSize,
|
||||
@RequestParam(value = "status", required = false) List<String> statusFilters) {
|
||||
|
||||
log.info("Received request for paginated plants. Page: {}, Size: {}, Status Filters: {}", pageNumber, pageSize, statusFilters);
|
||||
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "lastUpdatedOn"));
|
||||
|
||||
Page<PlantDTO> plants;
|
||||
if (statusFilters == null || statusFilters.isEmpty()) {
|
||||
log.info("Fetching all plants with pagination");
|
||||
plants = plantMasterService.getAllPlantsWithPagination(pageable);
|
||||
} else {
|
||||
log.info("Fetching plants with filters: {} and pagination", statusFilters);
|
||||
plants = plantMasterService.getPlantsByStatusWithPagination(statusFilters, pageable);
|
||||
}
|
||||
|
||||
log.info("Successfully fetched {} plants with pagination", plants.getTotalElements());
|
||||
return Response.success(plants).withMessage("Fetched plants successfully.");
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred while fetching plants with pagination: {}", e.getMessage(), e);
|
||||
return Response.error(500, "Failed to fetch paginated plants");
|
||||
}
|
||||
}
|
||||
|
||||
@PatchMapping("/updateStatus")
|
||||
public Response<PlantDTO> updatePlantStatus(
|
||||
@RequestParam(value = "plantId", required = false) Short plantId,
|
||||
@RequestParam(value = "plantCode", required = false) String plantCode,
|
||||
@RequestParam("status") String status) {
|
||||
|
||||
log.info("Received request to update plant status. PlantId: {}, PlantCode: {}, Status: {}", plantId, plantCode, status);
|
||||
|
||||
try {
|
||||
// Validate input
|
||||
if (!status.equalsIgnoreCase("A") && !status.equalsIgnoreCase("I")) {
|
||||
log.warn("Invalid status provided: {}", status);
|
||||
throw new IllegalArgumentException("Invalid status. Only 'A' (ACTIVE) or 'I' (INACTIVE) are allowed.");
|
||||
}
|
||||
|
||||
if (plantId == null && plantCode == null) {
|
||||
log.warn("Neither 'plantId' nor 'plantCode' was provided.");
|
||||
throw new IllegalArgumentException("Either 'plantId' or 'plantCode' must be provided.");
|
||||
}
|
||||
|
||||
User currentUser = getCurrentUser();
|
||||
log.debug("Current user for status update: {}", currentUser);
|
||||
|
||||
// Call the service method
|
||||
PlantDTO updatedPlant = plantMasterService.updatePlantStatus(plantId, plantCode, Status.valueOf(status.toUpperCase()), currentUser);
|
||||
log.info("Successfully updated plant status. Updated Plant: {}", updatedPlant);
|
||||
|
||||
return Response.success(updatedPlant).withMessage("Plant status updated successfully.");
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.error("Validation error while updating plant status: {}", e.getMessage());
|
||||
return Response.error(400, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred while updating plant status: {}", e.getMessage(), e);
|
||||
return Response.error(500, "Failed to update plant status");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package com.sahyog.app.inbound.user.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.sahyog.app.inbound.user.dto.RoleDTO;
|
||||
import com.sahyog.app.inbound.user.exception.RoleAlreadyExistsException;
|
||||
import com.sahyog.app.inbound.user.model.Role;
|
||||
import com.sahyog.app.inbound.user.service.RoleService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/roles")
|
||||
public class RoleController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RoleController.class);
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
// @GetMapping("/user-type/{userTypeId}")
|
||||
// public ResponseEntity<List<RoleDTO>> getRolesByUserTypeId(@PathVariable short userTypeId) {
|
||||
// log.info("Fetching roles for userTypeId: {}", userTypeId);
|
||||
// List<RoleDTO> roles = roleService.getRolesByUserTypeId(userTypeId);
|
||||
// return ResponseEntity.ok(roles);
|
||||
// }
|
||||
|
||||
// Create Role
|
||||
// @PostMapping
|
||||
// public ResponseEntity<Role> createRole(@RequestBody RoleDTO roleDTO) {
|
||||
// Role createdRole = roleService.createRole(roleDTO);
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(createdRole);
|
||||
// }
|
||||
//
|
||||
// // Get Roles by UserTypeId
|
||||
// @GetMapping("/userType/{userTypeId}")
|
||||
// public ResponseEntity<List<Role>> getRolesByUserTypeId(@PathVariable int userTypeId) {
|
||||
// List<Role> roles = roleService.getRolesByUserTypeId(userTypeId);
|
||||
// return ResponseEntity.ok(roles);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// // Get All Roles
|
||||
// @GetMapping
|
||||
// public ResponseEntity<List<Role>> getAllRoles() {
|
||||
// List<Role> roles = roleService.getAllRoles();
|
||||
// return ResponseEntity.ok(roles);
|
||||
// }
|
||||
//
|
||||
// // Get Role by ID
|
||||
// @GetMapping("/{roleId}")
|
||||
// public ResponseEntity<Role> getRoleById(@PathVariable int roleId) {
|
||||
// Role role = roleService.getRoleById(roleId);
|
||||
// return ResponseEntity.ok(role);
|
||||
// }
|
||||
//
|
||||
// // Update Role
|
||||
// @PutMapping("/{roleId}")
|
||||
// public ResponseEntity<Role> updateRole(@PathVariable int roleId, @RequestBody RoleDTO roleDTO) {
|
||||
// Role updatedRole = roleService.updateRole(roleId, roleDTO);
|
||||
// return ResponseEntity.ok(updatedRole);
|
||||
// }
|
||||
//
|
||||
// // Delete Role
|
||||
// @DeleteMapping("/{roleId}")
|
||||
// public ResponseEntity<Void> deleteRole(@PathVariable int roleId) {
|
||||
// roleService.deleteRole(roleId);
|
||||
// return ResponseEntity.noContent().build();
|
||||
// }
|
||||
//
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
package com.sahyog.app.inbound.user.controller;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.sahyog.app.inbound.user.dto.TransporterMasterDto;
|
||||
import com.sahyog.app.inbound.user.dto.TransporterResponse;
|
||||
import com.sahyog.app.inbound.user.service.TransporterService;
|
||||
import jakarta.validation.Valid;
|
||||
import com.sahyog.app.inbound.user.model.Response;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/transporter")
|
||||
public class TransporterController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(TransporterController.class);
|
||||
|
||||
@Autowired
|
||||
private TransporterService transporterService;
|
||||
|
||||
|
||||
@PostMapping(value = "/addUpdateTransporters", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Response<?>> createOrUpdateTransporters(@Valid @RequestBody List<TransporterMasterDto> transporterRequestDtos) {
|
||||
log.info("Received request to process {} transporters.", transporterRequestDtos.size());
|
||||
|
||||
try {
|
||||
Response<List<Map<String, Object>>> response = transporterService.processTransporters(transporterRequestDtos);
|
||||
|
||||
if (response.getStatus() == 200 || response.getStatus() == 201) {
|
||||
log.info("Transporters processed successfully. Status: {}", response.getStatus());
|
||||
} else if (response.getStatus() == 207) {
|
||||
log.warn("Partial success in processing transporters: {}", response.getMessage());
|
||||
} else {
|
||||
log.error("Failed to process transporters. Status: {}, Message: {}", response.getStatus(), response.getMessage());
|
||||
}
|
||||
|
||||
return ResponseEntity.status(response.getStatus()).body(response);
|
||||
} catch (Exception e) {
|
||||
log.error("Unexpected error occurred while processing transporters.", e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(
|
||||
new Response<>(500, "Failed to process transporters due to an internal error.", null)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getAllTransporters")
|
||||
public Response<Page<TransporterResponse>> getAllTransporters(
|
||||
@RequestParam(value = "pageNumber", defaultValue = "0") int pageNumber,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") int pageSize,
|
||||
@RequestParam(value = "sortDirection", defaultValue = "DESC") String sortDirection,
|
||||
@RequestParam(value = "supplier_code", required = false) String supplierCode,
|
||||
@RequestParam(value = "transporter_name", required = false) String transporterName,
|
||||
@RequestParam(value = "supplier_account_group", required = false) String supplierAccountGroup,
|
||||
@RequestParam(value = "state", required = false) String state,
|
||||
@RequestParam(value = "bp_grouping", required = false) String bpGrouping) {
|
||||
|
||||
log.info("Fetching all transporters with filters: supplierCode={}, transporterName={}, supplierAccountGroup={}, state={}, bpGrouping={}",
|
||||
supplierCode, transporterName, supplierAccountGroup, state, bpGrouping);
|
||||
|
||||
Sort.Direction direction = Sort.Direction.fromString(sortDirection);
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, Sort.by(direction, "lastUpdatedOn"));
|
||||
|
||||
try {
|
||||
Page<TransporterResponse> transporters = transporterService.getTransportersWithFilters(
|
||||
supplierCode, transporterName, supplierAccountGroup, state, bpGrouping, pageable);
|
||||
|
||||
log.info("Successfully fetched {} transporters with pagination.", transporters.getTotalElements());
|
||||
return Response.success(transporters).withMessage("Transporters fetched successfully.");
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred while fetching transporters with filters.", e);
|
||||
return Response.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Failed to fetch transporters. Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/transporterdetails")
|
||||
public ResponseEntity<Response<Page<Map<String, Object>>>> getTransporterDetails(
|
||||
@RequestBody Map<String, Object> req, Pageable pageable) {
|
||||
log.info("Received request to fetch transporter details with filters: {} and pagination: {}", req, pageable);
|
||||
|
||||
try {
|
||||
Page<Map<String, Object>> transporterDetails = transporterService.getTransporterDetails(req, pageable);
|
||||
|
||||
if (transporterDetails.isEmpty()) {
|
||||
log.info("No transporter details found for the provided filters.");
|
||||
return ResponseEntity.ok(new Response<>(204, "No transporter details found for the provided filters.", transporterDetails));
|
||||
}
|
||||
|
||||
log.info("Successfully fetched {} transporter details.", transporterDetails.getTotalElements());
|
||||
return ResponseEntity.ok(new Response<>(200, "Transporter details fetched successfully.", transporterDetails));
|
||||
} catch (Exception e) {
|
||||
log.error("Error fetching transporter details.", e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(
|
||||
new Response<>(500, "An error occurred while fetching transporter details. Please try again later.", null)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/dropdown")
|
||||
public ResponseEntity<Response<Map<String, Object>>> getDropDownValues() {
|
||||
try {
|
||||
// Fetch dropdown values from the service
|
||||
Map<String, Object> dropDownValues = transporterService.getDropDownValues();
|
||||
|
||||
// Check if an error occurred in the service layer
|
||||
if (dropDownValues.containsKey("error")) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(new Response<>(500, "Failed to fetch dropdown values.", null));
|
||||
}
|
||||
|
||||
// Return successful response
|
||||
return ResponseEntity.ok(new Response<>(200, "Dropdown values fetched successfully.", dropDownValues));
|
||||
|
||||
} catch (Exception e) {
|
||||
// Log the exception and return a generic error response
|
||||
log.error("Error while fetching dropdown values: {}", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(new Response<>(500, "An error occurred while fetching dropdown values.", null));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,225 @@
|
|||
package com.sahyog.app.inbound.user.controller;
|
||||
|
||||
import com.sahyog.app.inbound.user.dto.UserDTO;
|
||||
import com.sahyog.app.inbound.user.dto.UserUpdateDTO;
|
||||
import com.sahyog.app.inbound.user.exception.UserAlreadyExistsException;
|
||||
import com.sahyog.app.inbound.user.exception.UserNotFoundException;
|
||||
import com.sahyog.app.inbound.user.model.Response;
|
||||
import com.sahyog.app.inbound.user.model.User;
|
||||
import com.sahyog.app.inbound.user.service.UserService;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@RestController
|
||||
@RequestMapping("/api/users")
|
||||
public class UserController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UserController.class);
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@PostMapping("/createUser")
|
||||
public ResponseEntity<Response<List<Map<String, Object>>>> createInternalUsers(@RequestBody List<UserDTO> userDTOs) {
|
||||
log.info("Received request to create/update users: {}", userDTOs);
|
||||
try {
|
||||
Response<List<Map<String, Object>>> response = userService.createInternalUsers(userDTOs);
|
||||
log.info("Users created/updated successfully. Response: {}", response);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(response);
|
||||
} catch (UserAlreadyExistsException e) {
|
||||
log.warn("UserAlreadyExistsException occurred: {}", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.CONFLICT)
|
||||
.body(Response.error(409, "Error: " + e.getMessage()).withData(Collections.emptyList()));
|
||||
} catch (RuntimeException e) {
|
||||
log.error("RuntimeException occurred: {}", e.getMessage(), e);
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
.body(Response.error(400, "Error: " + e.getMessage()).withData(Collections.emptyList()));
|
||||
} catch (Exception e) {
|
||||
log.error("Unexpected error occurred: {}", e.getMessage(), e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(Response.error(500, "An unexpected error occurred").withData(Collections.emptyList()));
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
public ResponseEntity<Response<Map<String, Object>>> updateUser(
|
||||
@RequestParam(required = false) String userEmpTransCode,
|
||||
@RequestBody UserUpdateDTO userUpdateDTO) {
|
||||
log.info("Received request to update user with employeeTransCode: {} or email: {}", userEmpTransCode, userUpdateDTO.getEmailId());
|
||||
|
||||
// Validate input
|
||||
if ((userEmpTransCode == null || userEmpTransCode.isEmpty()) &&
|
||||
(userUpdateDTO.getEmailId() == null || userUpdateDTO.getEmailId().isEmpty())) {
|
||||
log.warn("Invalid request: Either employeeTransCode or email must be provided.");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
.body(Response.error(400, "Either employeeTransCode or email must be provided."));
|
||||
}
|
||||
|
||||
try {
|
||||
// Call the service to handle the update
|
||||
Response<Map<String, Object>> response = userService.updateUser(userEmpTransCode, userUpdateDTO);
|
||||
log.info("User updated successfully. Response: {}", response);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(response);
|
||||
|
||||
} catch (UserNotFoundException e) {
|
||||
log.warn("User not found: {}", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||
.body(Response.error(404, e.getMessage()));
|
||||
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.warn("Invalid input: {}", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
.body(Response.error(400, e.getMessage()));
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("Unexpected error occurred while updating user: {}", e.getMessage(), e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(Response.error(500, "An unexpected error occurred: " + e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// @PutMapping("/update")
|
||||
// public ResponseEntity<String> updateUser(@RequestParam String userEmpTransCode,
|
||||
// @RequestBody UserUpdateDTO userUpdateDTO) {
|
||||
// log.info("Received request to update user with userEmpTransCode: {}", userEmpTransCode);
|
||||
// if (userEmpTransCode == null || userEmpTransCode.isEmpty()) {
|
||||
// log.warn("Invalid request: userEmpTransCode is null or empty");
|
||||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
// .body("userEmpTransCode must be provided.");
|
||||
// }
|
||||
// ResponseEntity<String> response = userService.updateUser(userEmpTransCode, userUpdateDTO);
|
||||
// log.info("User updated successfully with userEmpTransCode: {}", userEmpTransCode);
|
||||
// return response;
|
||||
// }
|
||||
|
||||
@GetMapping("/getallUserWithPagination")
|
||||
public ResponseEntity<Page<User>> getAllUsers(
|
||||
@RequestParam(defaultValue = "0") int pageNumber,
|
||||
@RequestParam(defaultValue = "10") int pageSize) {
|
||||
log.info("Fetching all users with page: {} and size: {}", pageNumber, pageSize);
|
||||
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "lastUpdatedOn"));
|
||||
|
||||
Page<User> users = userService.getAllUsers(pageable);
|
||||
|
||||
log.info("Fetched {} users", users.getTotalElements());
|
||||
return ResponseEntity.ok(users);
|
||||
}
|
||||
|
||||
@GetMapping("/ActiveOrInactive")
|
||||
public ResponseEntity<List<User>> getUsersByActive_Inactive(@RequestParam List<String> status) {
|
||||
log.info("Fetching users by status: {}", status);
|
||||
List<User> users = userService.getUsersByActive_Inactive(status);
|
||||
log.info("Fetched {} users for statuses: {}", users.size(), status);
|
||||
return ResponseEntity.ok(users);
|
||||
}
|
||||
|
||||
@GetMapping("/getAllAndUserWithStatus")
|
||||
public Response<List<UserDTO>> getUsersByStatus(
|
||||
@RequestParam(value = "status", required = false) List<String> status) {
|
||||
|
||||
log.info("Fetching users with status filters: {}", status);
|
||||
|
||||
List<UserDTO> users;
|
||||
|
||||
if (status == null || status.isEmpty()) {
|
||||
log.info("Fetching all users as no status filter was provided");
|
||||
users = userService.getAllUsers(); // Fetch all users
|
||||
} else {
|
||||
log.info("Fetching users filtered by status: {}", status);
|
||||
users = userService.getUsersByStatus(status); // Fetch users by status
|
||||
}
|
||||
|
||||
log.info("Successfully fetched {} users", users.size());
|
||||
return Response.success(users).withMessage("Fetched users successfully.");
|
||||
}
|
||||
|
||||
@GetMapping("/getAllAndUserWithStatusPagination")
|
||||
public Response<Page<UserDTO>> getUsersWithPagination(
|
||||
@RequestParam(defaultValue = "0") int pageNumber,
|
||||
@RequestParam(defaultValue = "10") int pageSize,
|
||||
@RequestParam(value = "status", required = false) String status) {
|
||||
|
||||
log.info("Fetching users with pagination. Page: {}, Size: {}, Status filter: {}", pageNumber, pageSize, status);
|
||||
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "lastUpdatedOn"));
|
||||
|
||||
Page<UserDTO> users;
|
||||
if (status == null || status.isEmpty()) {
|
||||
log.info("Fetching all users with pagination");
|
||||
users = userService.getAllUsersWithPagination(pageable);
|
||||
} else {
|
||||
log.info("Fetching users with status filter and pagination");
|
||||
users = userService.getUsersByStatusWithPagination(status, pageable);
|
||||
}
|
||||
|
||||
log.info("Successfully fetched {} users with pagination", users.getTotalElements());
|
||||
return Response.success(users).withMessage("Fetched users successfully.");
|
||||
}
|
||||
|
||||
@PostMapping("/userdetails")
|
||||
public ResponseEntity<Response<Page<Map<String, Object>>>> getUserDetails(
|
||||
@RequestBody Map<String, Object> req, Pageable pageable) {
|
||||
log.info("Received request to fetch user details with filters: {}", req);
|
||||
try {
|
||||
// Call the service to fetch user details
|
||||
Page<Map<String, Object>> userDetails = userService.getUserDetails(req, pageable);
|
||||
|
||||
// Check if the result is empty and respond accordingly
|
||||
if (userDetails.isEmpty()) {
|
||||
log.info("No user details found for the provided filters.");
|
||||
return ResponseEntity.ok(new Response<>(204,"No User details found for the provided filters.", userDetails));
|
||||
}
|
||||
|
||||
// Return success response with transporter details
|
||||
log.info("Successfully fetched user details.");
|
||||
return ResponseEntity.ok(new Response<>(200,"User details fetched successfully.",userDetails));
|
||||
} catch (Exception e) {
|
||||
// Log the exception
|
||||
log.error("Error fetching user details.", e);
|
||||
|
||||
// Return error response
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(
|
||||
new Response<>(500, "An error occurred while fetching user details. Please try again later.", null)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/userdropdown")
|
||||
public ResponseEntity<Response<Map<String, Object>>> getDropDownValues() {
|
||||
try {
|
||||
// Fetch dropdown values from the service
|
||||
Map<String, Object> dropDownValues = userService.getDropDownValues();
|
||||
|
||||
// Check if an error occurred in the service layer
|
||||
if (dropDownValues.containsKey("error")) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(new Response<>(500, "Failed to fetch dropdown values.", null));
|
||||
}
|
||||
|
||||
// Return successful response
|
||||
return ResponseEntity.ok(new Response<>(200, "Dropdown values fetched successfully.", dropDownValues));
|
||||
|
||||
} catch (Exception e) {
|
||||
// Log the exception and return a generic error response
|
||||
log.error("Error while fetching dropdown values: {}", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(new Response<>(500, "An error occurred while fetching dropdown values.", null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
package com.sahyog.app.inbound.user.controller;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.sahyog.app.inbound.user.dto.AssignPlantsRequestDTO;
|
||||
import com.sahyog.app.inbound.user.dto.AssignRolesRequestDTO;
|
||||
import com.sahyog.app.inbound.user.dto.PlantMasterDTO;
|
||||
import com.sahyog.app.inbound.user.dto.RoleDTO;
|
||||
import com.sahyog.app.inbound.user.dto.UserRequestDTO;
|
||||
import com.sahyog.app.inbound.user.model.Response;
|
||||
import com.sahyog.app.inbound.user.service.UserPlantService;
|
||||
import com.sahyog.app.inbound.user.service.UserRoleService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/userplant")
|
||||
public class UserPlantController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UserPlantController.class);
|
||||
|
||||
@Autowired
|
||||
private UserPlantService userPlantService;
|
||||
|
||||
@PostMapping("/fetchPlants")
|
||||
public ResponseEntity<Response<List<PlantMasterDTO>>> getAllPlantsAndAssignedPlants(@RequestBody UserRequestDTO userRequestDTO) {
|
||||
String email = userRequestDTO.getEmail();
|
||||
String employeeTransCode = userRequestDTO.getEmployeeTransCode();
|
||||
|
||||
try {
|
||||
// Fetch all plants and assigned plants
|
||||
List<PlantMasterDTO> plantsWithAssignmentInfo = userPlantService.getAllPlantsWithAssignmentInfo(email, employeeTransCode);
|
||||
|
||||
if (plantsWithAssignmentInfo.isEmpty()) {
|
||||
log.debug("No plants available or assigned for email: {} and employeeTransCode: {}", email, employeeTransCode);
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||
.body(new Response<>(404, "No plants found for the given user.", Collections.emptyList()));
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(new Response<>(200, "Plants fetched successfully.", plantsWithAssignmentInfo));
|
||||
} catch (Exception e) {
|
||||
log.error("Error while fetching plants: {}", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(new Response<>(500, "An error occurred while fetching plants.", null));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/assignPlants")
|
||||
public ResponseEntity<Response<String>> assignPlantsToUser(@RequestBody AssignPlantsRequestDTO requestDTO) {
|
||||
String email = requestDTO.getEmail();
|
||||
String employeeTransCode = requestDTO.getEmployeeTransCode();
|
||||
List<Integer> selectedPlantIds = requestDTO.getSelectedPlantIds();
|
||||
int createdBy = requestDTO.getCreatedBy();
|
||||
int lastUpdatedBy = requestDTO.getLastUpdatedBy();
|
||||
|
||||
try {
|
||||
// Call the service to assign selected plants
|
||||
boolean isAssigned = userPlantService.assignSelectedPlantsToUser(
|
||||
email,
|
||||
employeeTransCode,
|
||||
selectedPlantIds,
|
||||
createdBy,
|
||||
lastUpdatedBy
|
||||
);
|
||||
|
||||
if (!isAssigned) {
|
||||
log.debug("Failed to assign plants to user with email: {} and employeeTransCode: {}", email, employeeTransCode);
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
.body(new Response<>(400, "Failed to assign plants.", "No changes were made."));
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(new Response<>(200, "Plants assigned successfully.", "Operation successful."));
|
||||
} catch (Exception e) {
|
||||
log.error("Error while assigning plants: {}", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(new Response<>(500, "An error occurred while assigning plants.", null));
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/userplant_dropdown")
|
||||
public ResponseEntity<Response<Map<String, Object>>> getDropDownValues() {
|
||||
try {
|
||||
// Fetch dropdown values from the service
|
||||
Map<String, Object> dropDownValues = userPlantService.getDropDownValues();
|
||||
|
||||
if (dropDownValues.containsKey("error")) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(new Response<>(500, "Failed to fetch dropdown values.", null));
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(new Response<>(200, "Dropdown values fetched successfully.", dropDownValues));
|
||||
} catch (Exception e) {
|
||||
log.error("Error while fetching dropdown values: {}", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(new Response<>(500, "An error occurred while fetching dropdown values.", null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//@RestController
|
||||
//@RequestMapping("/userplant")
|
||||
//public class UserPlantController {
|
||||
//
|
||||
//
|
||||
// private static final Logger log = LoggerFactory.getLogger(UserPlantController.class);
|
||||
//
|
||||
// @Autowired
|
||||
// private UserPlantService userPlantService;
|
||||
//
|
||||
// @PostMapping("/fetchPlants")
|
||||
// public ResponseEntity<List<PlantMasterDTO>> getAllPlantsAndAssignedPlants(@RequestBody UserRequestDTO userRequestDTO) {
|
||||
// String email = userRequestDTO.getEmail();
|
||||
// String employeeTransCode = userRequestDTO.getEmployeeTransCode();
|
||||
//
|
||||
// // Fetch all plants and assigned plants
|
||||
// List<PlantMasterDTO> plantsWithAssignmentInfo = userPlantService.getAllPlantsWithAssignmentInfo(email, employeeTransCode);
|
||||
//
|
||||
// if (plantsWithAssignmentInfo.isEmpty()) {
|
||||
// log.debug("No plants available or assigned for email: {} and employeeTransCode: {}", email, employeeTransCode);
|
||||
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(Collections.emptyList());
|
||||
// }
|
||||
//
|
||||
// return ResponseEntity.ok(plantsWithAssignmentInfo);
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/assignPlants")
|
||||
// public ResponseEntity<String> assignPlantsToUser(@RequestBody AssignPlantsRequestDTO requestDTO) {
|
||||
// String email = requestDTO.getEmail();
|
||||
// String employeeTransCode = requestDTO.getEmployeeTransCode();
|
||||
// List<Integer> selectedPlantIds = requestDTO.getSelectedPlantIds();
|
||||
// int createdBy = requestDTO.getCreatedBy();
|
||||
// int lastUpdatedBy = requestDTO.getLastUpdatedBy();
|
||||
// // Call the service to assign selected plants
|
||||
// boolean isAssigned = userPlantService.assignSelectedPlantsToUser(
|
||||
// email,
|
||||
// employeeTransCode,
|
||||
// selectedPlantIds,
|
||||
// createdBy,
|
||||
// lastUpdatedBy
|
||||
// );
|
||||
//
|
||||
// if (!isAssigned) {
|
||||
// log.debug("Failed to assign plants to user with email: {} and employeeTransCode: {}", email, employeeTransCode);
|
||||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Failed to assign plants.");
|
||||
// }
|
||||
//
|
||||
// return ResponseEntity.ok("Plants assigned successfully.");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @GetMapping("userplant_dropdown")
|
||||
// public ResponseEntity<Response<Map<String, Object>>> getDropDownValues() {
|
||||
// try {
|
||||
// // Fetch dropdown values from the service
|
||||
// Map<String, Object> dropDownValues = userPlantService.getDropDownValues();
|
||||
//
|
||||
// // Check if an error occurred in the service layer
|
||||
// if (dropDownValues.containsKey("error")) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
// .body(new Response<>(500, "Failed to fetch dropdown values.", null));
|
||||
// }
|
||||
//
|
||||
// // Return successful response
|
||||
// return ResponseEntity.ok(new Response<>(200, "Dropdown values fetched successfully.", dropDownValues));
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// // Log the exception and return a generic error response
|
||||
// log.error("Error while fetching dropdown values: {}", e.getMessage());
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
// .body(new Response<>(500, "An error occurred while fetching dropdown values.", null));
|
||||
// }
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,165 @@
|
|||
package com.sahyog.app.inbound.user.controller;
|
||||
|
||||
import com.sahyog.app.inbound.user.dto.AssignRolesRequestDTO;
|
||||
import com.sahyog.app.inbound.user.dto.RoleDTO;
|
||||
import com.sahyog.app.inbound.user.dto.UserRequestDTO;
|
||||
import com.sahyog.app.inbound.user.model.Response;
|
||||
import com.sahyog.app.inbound.user.service.UserRoleService;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/user-roles")
|
||||
public class UserRoleController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UserRoleController.class);
|
||||
|
||||
@Autowired
|
||||
private UserRoleService userRoleService;
|
||||
|
||||
@PostMapping("/fetchRoles")
|
||||
public ResponseEntity<Response<List<RoleDTO>>> getAllRolesAndAssignedRoles(@RequestBody UserRequestDTO userRequestDTO) {
|
||||
try {
|
||||
String email = userRequestDTO.getEmail();
|
||||
String employeeTransCode = userRequestDTO.getEmployeeTransCode();
|
||||
|
||||
List<RoleDTO> rolesWithAssignmentInfo = userRoleService.getAllRolesWithAssignmentInfo(email, employeeTransCode);
|
||||
|
||||
if (rolesWithAssignmentInfo.isEmpty()) {
|
||||
log.debug("No roles available or assigned for email: {} and employeeTransCode: {}", email, employeeTransCode);
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||
.body(new Response<>(404, "No roles found for the given user.", Collections.emptyList()));
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(new Response<>(200, "Roles fetched successfully.", rolesWithAssignmentInfo));
|
||||
} catch (Exception e) {
|
||||
log.error("Error while fetching roles: {}", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(new Response<>(500, "An error occurred while fetching roles.", null));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/assignRoles")
|
||||
public ResponseEntity<Response<String>> assignRolesToUser(@RequestBody AssignRolesRequestDTO requestDTO) {
|
||||
try {
|
||||
String email = requestDTO.getEmail();
|
||||
String employeeTransCode = requestDTO.getEmployeeTransCode();
|
||||
List<Integer> selectedRoleIds = requestDTO.getSelectedRoleIds();
|
||||
int createdBy = requestDTO.getCreatedBy();
|
||||
int lastUpdatedBy = requestDTO.getLastUpdatedBy();
|
||||
|
||||
boolean success = userRoleService.assignSelectedRolesToUser(email, employeeTransCode, selectedRoleIds, createdBy, lastUpdatedBy);
|
||||
|
||||
if (success) {
|
||||
return ResponseEntity.ok(new Response<>(200, "Roles assigned successfully.", "Success"));
|
||||
} else {
|
||||
log.debug("Roles assignment failed for email: {} and employeeTransCode: {}", email, employeeTransCode);
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||
.body(new Response<>(404, "User not found or no changes were made to roles.", "Failure"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error while assigning roles: {}", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(new Response<>(500, "An error occurred while assigning roles.", null));
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/userrole_dropdown")
|
||||
public ResponseEntity<Response<Map<String, Object>>> getDropDownValues() {
|
||||
try {
|
||||
// Fetch dropdown values from the service
|
||||
Map<String, Object> dropDownValues = userRoleService.getDropDownValues();
|
||||
|
||||
// Check if an error occurred in the service layer
|
||||
if (dropDownValues.containsKey("error")) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(new Response<>(500, "Failed to fetch dropdown values.", null));
|
||||
}
|
||||
|
||||
// Return successful response
|
||||
return ResponseEntity.ok(new Response<>(200, "Dropdown values fetched successfully.", dropDownValues));
|
||||
} catch (Exception e) {
|
||||
log.error("Error while fetching dropdown values: {}", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(new Response<>(500, "An error occurred while fetching dropdown values.", null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//@RestController
|
||||
//@RequestMapping("/api/user-roles")
|
||||
//public class UserRoleController {
|
||||
//
|
||||
// private static final Logger log = LoggerFactory.getLogger(UserRoleController.class);
|
||||
//
|
||||
// @Autowired
|
||||
// private UserRoleService userRoleService;
|
||||
//
|
||||
// @PostMapping("/fetchRoles")
|
||||
// public ResponseEntity<List<RoleDTO>> getAllRolesAndAssignedRoles(@RequestBody UserRequestDTO userRequestDTO) {
|
||||
// String email = userRequestDTO.getEmail();
|
||||
// String employeeTransCode = userRequestDTO.getEmployeeTransCode();
|
||||
//
|
||||
// List<RoleDTO> rolesWithAssignmentInfo = userRoleService.getAllRolesWithAssignmentInfo(email, employeeTransCode);
|
||||
//
|
||||
// if (rolesWithAssignmentInfo.isEmpty()) {
|
||||
// log.debug("No roles available or assigned for email: {} and employeeTransCode: {}", email, employeeTransCode);
|
||||
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(Collections.emptyList());
|
||||
// }
|
||||
//
|
||||
// return ResponseEntity.ok(rolesWithAssignmentInfo);
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/assignRoles")
|
||||
// public ResponseEntity<String> assignRolesToUser(@RequestBody AssignRolesRequestDTO requestDTO) {
|
||||
// String email = requestDTO.getEmail();
|
||||
// String employeeTransCode = requestDTO.getEmployeeTransCode();
|
||||
// List<Integer> selectedRoleIds = requestDTO.getSelectedRoleIds();
|
||||
// int createdBy = requestDTO.getCreatedBy();
|
||||
// int lastUpdatedBy = requestDTO.getLastUpdatedBy();
|
||||
//
|
||||
// boolean success = userRoleService.assignSelectedRolesToUser(email, employeeTransCode, selectedRoleIds, createdBy, lastUpdatedBy);
|
||||
//
|
||||
// if (success) {
|
||||
// return ResponseEntity.ok("Roles assigned successfully.");
|
||||
// } else {
|
||||
// log.debug("Roles assignment failed for email: {} and employeeTransCode: {}", email, employeeTransCode);
|
||||
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("User not found or roles could not be assigned.");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @GetMapping("userrole_dropdown")
|
||||
// public ResponseEntity<Response<Map<String, Object>>> getDropDownValues() {
|
||||
// try {
|
||||
// // Fetch dropdown values from the service
|
||||
// Map<String, Object> dropDownValues = userRoleService.getDropDownValues();
|
||||
//
|
||||
// // Check if an error occurred in the service layer
|
||||
// if (dropDownValues.containsKey("error")) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
// .body(new Response<>(500, "Failed to fetch dropdown values.", null));
|
||||
// }
|
||||
//
|
||||
// // Return successful response
|
||||
// return ResponseEntity.ok(new Response<>(200, "Dropdown values fetched successfully.", dropDownValues));
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// // Log the exception and return a generic error response
|
||||
// log.error("Error while fetching dropdown values: {}", e.getMessage());
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
// .body(new Response<>(500, "An error occurred while fetching dropdown values.", null));
|
||||
// }
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,147 @@
|
|||
package com.sahyog.app.inbound.user.controller;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.sahyog.app.inbound.user.dto.UserTypeDTO;
|
||||
import com.sahyog.app.inbound.user.model.Response;
|
||||
import com.sahyog.app.inbound.user.model.UserType;
|
||||
import com.sahyog.app.inbound.user.model.UserType1;
|
||||
import com.sahyog.app.inbound.user.service.UserTypeService;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/user-types")
|
||||
public class UserTypeController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UserTypeController.class);
|
||||
|
||||
@Autowired
|
||||
private UserTypeService userTypeService;
|
||||
|
||||
|
||||
@PostMapping("/createUserType")
|
||||
public ResponseEntity<Response<List<Map<String, Object>>>> createUserType(@RequestBody UserTypeDTO userTypeDTO) {
|
||||
log.info("Received request to create/update user type: {}", userTypeDTO);
|
||||
|
||||
try {
|
||||
Response<List<Map<String, Object>>> response = userTypeService.createUserType(userTypeDTO);
|
||||
log.info("User Type created/updated successfully. Response: {}", response);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(response);
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred while processing user type creation: {}", e.getMessage(), e);
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
.body(Response.error(400, "Error: " + e.getMessage()).withData(Collections.emptyList()));
|
||||
}
|
||||
}
|
||||
|
||||
// public ResponseEntity<UserType> createUserType(@RequestBody @Valid UserTypeDTO userTypeDTO)
|
||||
// @PostMapping("/create")
|
||||
// public ResponseEntity<UserType> createUserType(@RequestBody UserType1 userTypeDTO) {
|
||||
// log.info("123Received payload: {}", userTypeDTO);
|
||||
// log.info("line 40");
|
||||
// UserType createdUserType = userTypeService.createUserType(userTypeDTO);
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(createdUserType);
|
||||
// }
|
||||
|
||||
// @PostMapping("/create")
|
||||
// public String createUserType(@RequestBody Map<String, Object> req) {
|
||||
// System.out.println("line 46");
|
||||
// log.info("Received payload: {}", req);
|
||||
// return "data found";
|
||||
//// UserType createdUserType = userTypeService.createUserType(userTypeDTO);
|
||||
//// return ResponseEntity.status(HttpStatus.CREATED).body(createdUserType);
|
||||
// }
|
||||
|
||||
@PostMapping("/usertypedetails")
|
||||
public ResponseEntity<Response<Page<Map<String, Object>>>> getUsertypeDetails(
|
||||
@RequestBody Map<String, Object> req, Pageable pageable) {
|
||||
log.info("Received request to fetch usertype details with filters: {} and pagination: {}", req, pageable);
|
||||
|
||||
// Handle the service call to fetch usertype details
|
||||
try {
|
||||
Page<Map<String, Object>> usertypeDetails = userTypeService.getUsertypeDetails(req, pageable);
|
||||
|
||||
if (usertypeDetails.isEmpty()) {
|
||||
return ResponseEntity.ok(new Response<>(204, "No usertype details found", usertypeDetails));
|
||||
}
|
||||
return ResponseEntity.ok(new Response<>(200, "Usertype details fetched successfully", usertypeDetails));
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("Error fetching usertype details.", e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(
|
||||
new Response<>(500, "An error occurred while fetching usertype details.", null)
|
||||
);
|
||||
}
|
||||
}
|
||||
@GetMapping("/{userTypeId}")
|
||||
public ResponseEntity<Response<UserType>> getUserTypeById(@PathVariable short userTypeId) {
|
||||
log.info("Fetching user type with ID: {}", userTypeId);
|
||||
|
||||
try {
|
||||
UserType userType = userTypeService.getUserTypeById(userTypeId);
|
||||
return ResponseEntity.ok(Response.success(userType));
|
||||
} catch (RuntimeException e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||
.body(Response.error(404, "Error: " + e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@PatchMapping("/update-status/{userTypeId}")
|
||||
public ResponseEntity<Response<String>> updateUserTypeStatus(@PathVariable short userTypeId) {
|
||||
try {
|
||||
userTypeService.updateUserTypeStatus(userTypeId);
|
||||
return ResponseEntity.ok(Response.success("UserType status updated successfully."));
|
||||
} catch (RuntimeException e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||
.body(Response.error(404, "Error: " + e.getMessage()));
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(Response.error(500, "An unexpected error occurred: " + e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("usertype_dropdown")
|
||||
public ResponseEntity<Response<Map<String, Object>>> getDropDownValues() {
|
||||
try {
|
||||
// Fetch dropdown values from the service
|
||||
Map<String, Object> dropDownValues = userTypeService.getDropDownValues();
|
||||
|
||||
// Check if an error occurred in the service layer
|
||||
if (dropDownValues.containsKey("error")) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(new Response<>(500, "Failed to fetch dropdown values.", null));
|
||||
}
|
||||
|
||||
// Return successful response
|
||||
return ResponseEntity.ok(new Response<>(200, "Dropdown values fetched successfully.", dropDownValues));
|
||||
|
||||
} catch (Exception e) {
|
||||
// Log the exception and return a generic error response
|
||||
log.error("Error while fetching dropdown values: {}", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(new Response<>(500, "An error occurred while fetching dropdown values.", null));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class AssignPlantsRequestDTO {
|
||||
|
||||
private String email;
|
||||
private String employeeTransCode;
|
||||
private List<Integer> selectedPlantIds; // List of role IDs selected by the user
|
||||
private int createdBy;
|
||||
private int lastUpdatedBy;
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class AssignRolesRequestDTO {
|
||||
|
||||
private String email;
|
||||
private String employeeTransCode;
|
||||
private List<Integer> selectedRoleIds;
|
||||
private int createdBy;
|
||||
private int lastUpdatedBy; // List of role IDs selected by the user
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class MaterialMasterDTO {
|
||||
|
||||
private Integer materialId;
|
||||
private String materialCode;
|
||||
private String materialDescription;
|
||||
private String materialGroup;
|
||||
private String materialGroupDesc;
|
||||
private int plantId;
|
||||
private Status status;
|
||||
private int createdBy;
|
||||
private int lastUpdatedBy;
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class PlantDTO {
|
||||
|
||||
private Short plantId;
|
||||
private String plantCode;
|
||||
private String plantDesc;
|
||||
private String plantPan;
|
||||
private String plantGst;
|
||||
private BigDecimal plantGstRate;
|
||||
private String addedChannel;
|
||||
private Status status;
|
||||
private int createdBy;
|
||||
private int lastUpdatedBy;
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class PlantMasterDTO {
|
||||
private Short plantId;
|
||||
private String plantCode;
|
||||
private String plantDesc;
|
||||
private String plantPan;
|
||||
private String plantGst;
|
||||
private BigDecimal plantGstRate;
|
||||
private String addedChannel;
|
||||
private Status status;
|
||||
private Integer createdBy;
|
||||
private Integer lastUpdatedBy;
|
||||
|
||||
// Field to indicate if the plant is assigned to the user
|
||||
private boolean assigned;
|
||||
|
||||
// Getters and Setters
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
|
||||
import com.sahyog.app.inbound.user.model.User;
|
||||
import com.sahyog.app.inbound.user.model.UserType;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
@Data
|
||||
public class RoleDTO {
|
||||
private int roleId;
|
||||
private String roleName;
|
||||
private String roleDescription;
|
||||
private short userTypeId;
|
||||
private String status;
|
||||
private int createdBy;
|
||||
private int lastUpdatedBy;
|
||||
private boolean assigned;
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class TransporterMasterDto {
|
||||
private int transporterId;
|
||||
private short plantId;
|
||||
private String plantCode;
|
||||
private int userId;
|
||||
private String supplierCode;
|
||||
private String bpGrouping;
|
||||
private String transporterCode;
|
||||
private String supplierAccountGroup;
|
||||
private String transporterName;
|
||||
private String transporterFirstName;
|
||||
private String transporterMiddleName;
|
||||
private String transporterLastName;
|
||||
private String legalEntity;
|
||||
private String permanentAccountNumber;
|
||||
private String street;
|
||||
private String houseNumber;
|
||||
private String district;
|
||||
private String differentCity;
|
||||
private String postalCode;
|
||||
private String city;
|
||||
private String country;
|
||||
private String state;
|
||||
private String mobileNumber;
|
||||
private String emailId;
|
||||
private String gstn;
|
||||
private String taxRegime;
|
||||
private String shortCode;
|
||||
private LocalDate createdDate;
|
||||
private LocalDate updationDate;
|
||||
private String taxCodeDesc;
|
||||
private int taxRate;
|
||||
private String status;
|
||||
private int createdBy;
|
||||
private int lastUpdatedBy;
|
||||
private LocalDateTime lastUpdatedOn;
|
||||
|
||||
public TransporterMasterDto() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class TransporterResponse {
|
||||
private String supplierCode;
|
||||
private String transporterName;
|
||||
private String supplierAccountGroup;
|
||||
private String state;
|
||||
private String bpGrouping;
|
||||
private String legalEntity;
|
||||
private String permanentAccountNumber;
|
||||
private String street;
|
||||
private String houseNumber;
|
||||
private String district;
|
||||
private String differentCity;
|
||||
private String postalCode;
|
||||
private String city;
|
||||
private String country;
|
||||
private String mobileNumber;
|
||||
private String emailId;
|
||||
private String gstn;
|
||||
private String taxRegime;
|
||||
private String shortCode;
|
||||
private String status;
|
||||
private String taxCodeDesc;
|
||||
private int taxRate;
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.sahyog.app.inbound.user.model.User;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class TransporterUpdateDTO {
|
||||
private int transporterId;
|
||||
private short plantId;
|
||||
private String plantCode;
|
||||
private int userId;
|
||||
private String supplierCode;
|
||||
private String bpGrouping;
|
||||
private String transporterCode;
|
||||
private String supplierAccountGroup;
|
||||
private String transporterName;
|
||||
private String transporterFirstName;
|
||||
private String transporterMiddleName;
|
||||
private String transporterLastName;
|
||||
private String legalEntity;
|
||||
private String permanentAccountNumber;
|
||||
private String street;
|
||||
private String houseNumber;
|
||||
private String district;
|
||||
private String differentCity;
|
||||
private String postalCode;
|
||||
private String city;
|
||||
private String country;
|
||||
private String state;
|
||||
private String mobileNumber;
|
||||
private String emailId;
|
||||
private String gstn;
|
||||
private String taxRegime;
|
||||
private String shortCode;
|
||||
private LocalDate createdDate;
|
||||
private LocalDate updationDate;
|
||||
private String taxCodeDesc;
|
||||
private int taxRate;
|
||||
private String status;
|
||||
private int createdBy;
|
||||
private int lastUpdatedBy;
|
||||
private LocalDateTime lastUpdatedOn;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
import com.sahyog.app.inbound.user.model.User;
|
||||
import com.sahyog.app.inbound.user.model.UserType;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class UserDTO {
|
||||
private int userId; //
|
||||
private short userTypeId;
|
||||
private String userName;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String email;
|
||||
private String mobile;
|
||||
private String employeeTransCode;
|
||||
private String addedChannel;
|
||||
private Status status; // Typically a char field like 'A' or 'I'
|
||||
private int createdBy; // Self-reference for the creator
|
||||
private int lastUpdatedBy; // Self-reference for the last updater
|
||||
// private LocalDateTime lastUpdatedOn;
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class UserPlantDTO {
|
||||
|
||||
|
||||
private int userPlantId;
|
||||
|
||||
private int userId;
|
||||
|
||||
private int plantId;
|
||||
|
||||
private Status status;
|
||||
|
||||
private boolean assigned;
|
||||
|
||||
private int createdBy;
|
||||
|
||||
private int lastUpdatedBy;
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class UserRequestDTO {
|
||||
|
||||
private String email;
|
||||
private String employeeTransCode;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
import com.sahyog.app.inbound.user.model.Role;
|
||||
import com.sahyog.app.inbound.user.model.User;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class UserRoleDTO {
|
||||
|
||||
private int userRoleId;
|
||||
private int userId;
|
||||
private int roleId;
|
||||
private Status status;
|
||||
private int createdBy;
|
||||
private int lastUpdatedBy;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class UserTypeCreateDTO {
|
||||
private String usertypeName;
|
||||
private Status status;
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class UserTypeDTO {
|
||||
|
||||
private String userTypeName;
|
||||
private String status; // A or I
|
||||
private int createdBy;
|
||||
private int lastUpdatedBy;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.sahyog.app.inbound.user.dto;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class UserUpdateDTO {
|
||||
private int userId;
|
||||
private short userTypeId;
|
||||
private String userName;
|
||||
private String firstName;
|
||||
private String middleName;
|
||||
private String lastName;
|
||||
private String emailId;
|
||||
private String phoneNumber;
|
||||
private String userEmpTransCode;
|
||||
private String addedChannel;
|
||||
private Status status;
|
||||
private int createdBy;
|
||||
private int lastUpdatedBy;
|
||||
private LocalDateTime lastUpdatedOn;
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.sahyog.app.inbound.user.enums;
|
||||
|
||||
|
||||
public enum RoleType {
|
||||
ADMIN("Admin"),
|
||||
GUEST("Guest"),
|
||||
USER("User"),
|
||||
MANAGER("Manager");
|
||||
|
||||
private final String name;
|
||||
|
||||
RoleType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.sahyog.app.inbound.user.enums;
|
||||
|
||||
public enum Status {
|
||||
|
||||
A,
|
||||
I
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.sahyog.app.inbound.user.enums;
|
||||
|
||||
public enum UserType {
|
||||
INTERNAL,
|
||||
TRANSPORTER
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.sahyog.app.inbound.user.enums;
|
||||
|
||||
public enum UserTypeEnum {
|
||||
TRANSPORTER("Transporter"),
|
||||
MIS("MIS");
|
||||
|
||||
private final String userTypeName;
|
||||
|
||||
UserTypeEnum(String userTypeName) {
|
||||
this.userTypeName = userTypeName;
|
||||
}
|
||||
|
||||
public String getUserTypeName() {
|
||||
return userTypeName;
|
||||
}
|
||||
|
||||
// Method to get UserTypeEnum by userTypeName
|
||||
public static UserTypeEnum fromString(String userTypeName) {
|
||||
for (UserTypeEnum userType : values()) {
|
||||
if (userType.getUserTypeName().equalsIgnoreCase(userTypeName)) {
|
||||
return userType;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No enum constant with name " + userTypeName);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.sahyog.app.inbound.user.exception;
|
||||
|
||||
public class CustomException extends RuntimeException {
|
||||
|
||||
public CustomException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CustomException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
package com.sahyog.app.inbound.user.exception;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
|
||||
import com.sahyog.app.inbound.user.model.Response;
|
||||
|
||||
import jakarta.validation.ConstraintViolation;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
@ControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
||||
|
||||
@ExceptionHandler(RoleAlreadyExistsException.class)
|
||||
public ResponseEntity<String> handleRoleAlreadyExistsException(RoleAlreadyExistsException ex) {
|
||||
log.error("RoleAlreadyExistsException occurred: {}", ex.getMessage(), ex);
|
||||
return new ResponseEntity<>(ex.getMessage(), HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserAlreadyExistsException.class)
|
||||
public ResponseEntity<String> handleUserAlreadyExistsException(UserAlreadyExistsException ex) {
|
||||
log.error("UserAlreadyExistsException occurred: {}", ex.getMessage(), ex);
|
||||
return ResponseEntity.status(HttpStatus.CONFLICT).body(ex.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(IllegalArgumentException.class)
|
||||
public ResponseEntity<String> handleIllegalArgumentException(IllegalArgumentException ex) {
|
||||
log.warn("IllegalArgumentException occurred: {}", ex.getMessage(), ex);
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(ex.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(TransporterCreationException.class)
|
||||
public ResponseEntity<Response<?>> handleTransporterCreationException(TransporterCreationException ex) {
|
||||
log.error("Transporter creation error: {}", ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(Response.error(500, ex.getMessage()));
|
||||
}
|
||||
|
||||
@ExceptionHandler(TransporterUpdateException.class)
|
||||
public ResponseEntity<Response<?>> handleTransporterUpdateException(TransporterUpdateException ex) {
|
||||
log.error("Transporter update error: {}", ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(Response.error(500, ex.getMessage()));
|
||||
}
|
||||
|
||||
@ExceptionHandler(TransporterProcessingException.class)
|
||||
public ResponseEntity<Response<?>> handleTransporterProcessingException(TransporterProcessingException ex) {
|
||||
log.error("Transporter processing error: {}", ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.PARTIAL_CONTENT)
|
||||
.body(Response.error(207, ex.getMessage()));
|
||||
}
|
||||
|
||||
@ExceptionHandler(TransporterValidationException.class)
|
||||
public ResponseEntity<Response<?>> handleTransporterValidationException(TransporterValidationException e) {
|
||||
// Log the error and return a response
|
||||
String errorMessage = e.getErrorMessage();
|
||||
log.error("Transporter validation error occurred for supplier code: {}", e.getSupplierCode(), e);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
.body(Response.error(HttpStatus.BAD_REQUEST.value(), "Validation error")
|
||||
.withMessage(errorMessage)
|
||||
.withDetails("Please check the provided data."));
|
||||
}
|
||||
|
||||
|
||||
@ExceptionHandler(ConstraintViolationException.class)
|
||||
public ResponseEntity<Response<?>> handleConstraintViolationException(ConstraintViolationException e) {
|
||||
// Extracting only the violation message (e.g., "Invalid PAN format")
|
||||
String violations = e.getConstraintViolations().stream()
|
||||
.map(violation -> violation.getMessage()) // Getting the violation message
|
||||
.collect(Collectors.joining("; ")); // Joining multiple violations with a semicolon
|
||||
|
||||
// Creating user-friendly error message and details
|
||||
String errorMessage = "Validation failed: " + violations;
|
||||
String errorDetails = "Please check the provided data. Violations: " + violations;
|
||||
|
||||
// Return the response with status 400 (Bad Request)
|
||||
Response<String> response = Response.<String>error(HttpStatus.BAD_REQUEST.value(), errorMessage)
|
||||
.withMessage(errorMessage)
|
||||
.withDetails(errorDetails);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
.body(response);
|
||||
}
|
||||
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity<Response<?>> handleGeneralException(Exception e) {
|
||||
// Log the full exception
|
||||
log.error("An unexpected error occurred: {}", e.getMessage(), e);
|
||||
|
||||
// Get the root cause of the exception
|
||||
Throwable rootCause = getRootCause(e);
|
||||
|
||||
// Simplified error message based on the root cause
|
||||
String errorMessage = "An unexpected error occurred: " + rootCause.getMessage();
|
||||
|
||||
// Simplified details (including root cause)
|
||||
String errorDetails = "Please check the provided data or system configuration. Root cause: " + rootCause.getClass().getSimpleName() + ": " + rootCause.getMessage();
|
||||
|
||||
// Construct response with status 500
|
||||
Response<String> response = Response.<String>error(HttpStatus.INTERNAL_SERVER_ERROR.value(), errorMessage)
|
||||
.withMessage(errorMessage)
|
||||
.withDetails(errorDetails);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(response);
|
||||
}
|
||||
|
||||
|
||||
private Throwable getRootCause(Throwable throwable) {
|
||||
Throwable rootCause = throwable;
|
||||
while (rootCause.getCause() != null && rootCause != rootCause.getCause()) {
|
||||
rootCause = rootCause.getCause();
|
||||
}
|
||||
return rootCause;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.sahyog.app.inbound.user.exception;
|
||||
|
||||
public class RoleAlreadyExistsException extends RuntimeException {
|
||||
public RoleAlreadyExistsException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.sahyog.app.inbound.user.exception;
|
||||
|
||||
public class RoleNotFoundException extends RuntimeException {
|
||||
public RoleNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.sahyog.app.inbound.user.exception;
|
||||
|
||||
public class TransporterCreationException extends TransporterProcessingException{
|
||||
|
||||
public TransporterCreationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.sahyog.app.inbound.user.exception;
|
||||
|
||||
|
||||
public class TransporterProcessingException extends RuntimeException {
|
||||
public TransporterProcessingException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public TransporterProcessingException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.sahyog.app.inbound.user.exception;
|
||||
|
||||
public class TransporterUpdateException extends TransporterProcessingException {
|
||||
public TransporterUpdateException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.sahyog.app.inbound.user.exception;
|
||||
|
||||
public class TransporterValidationException extends RuntimeException {
|
||||
private String supplierCode;
|
||||
private String errorMessage;
|
||||
|
||||
public TransporterValidationException(String supplierCode, String errorMessage) {
|
||||
super(errorMessage);
|
||||
this.supplierCode = supplierCode;
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public String getSupplierCode() {
|
||||
return supplierCode;
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.sahyog.app.inbound.user.exception;
|
||||
|
||||
public class UserAlreadyExistsException extends RuntimeException{
|
||||
public UserAlreadyExistsException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.sahyog.app.inbound.user.exception;
|
||||
|
||||
|
||||
public class UserNotFoundException extends RuntimeException {
|
||||
public UserNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.sahyog.app.inbound.user.filter;
|
||||
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
||||
import com.sahyog.app.inbound.user.model.Transporter;
|
||||
|
||||
|
||||
public class TransporterFilters {
|
||||
|
||||
public static Specification<Transporter> filterBySupplierCode(String supplierCode) {
|
||||
return (root, query, criteriaBuilder) ->
|
||||
criteriaBuilder.equal(root.get("supplierCode"), supplierCode);
|
||||
}
|
||||
|
||||
public static Specification<Transporter> filterByTransporterName(String transporterName) {
|
||||
return (root, query, criteriaBuilder) ->
|
||||
criteriaBuilder.like(root.get("transporterName"), "%" + transporterName + "%");
|
||||
}
|
||||
|
||||
public static Specification<Transporter> filterBySupplierAccountGroup(String supplierAccountGroup) {
|
||||
return (root, query, criteriaBuilder) ->
|
||||
criteriaBuilder.equal(root.get("supplierAccountGroup"), supplierAccountGroup);
|
||||
}
|
||||
|
||||
public static Specification<Transporter> filterByState(String state) {
|
||||
return (root, query, criteriaBuilder) ->
|
||||
criteriaBuilder.equal(root.get("state"), state);
|
||||
}
|
||||
|
||||
public static Specification<Transporter> filterByBpGrouping(String bpGrouping) {
|
||||
return (root, query, criteriaBuilder) ->
|
||||
criteriaBuilder.equal(root.get("bpGrouping"), bpGrouping);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.sahyog.app.inbound.user.mapper;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.sahyog.app.inbound.user.dto.MaterialMasterDTO;
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
import com.sahyog.app.inbound.user.model.MaterialMaster;
|
||||
import com.sahyog.app.inbound.user.model.User;
|
||||
|
||||
@Component
|
||||
public class MaterialMapper {
|
||||
|
||||
public MaterialMaster toEntity(MaterialMasterDTO dto, User user) {
|
||||
MaterialMaster material = new MaterialMaster();
|
||||
// material.setMaterialId(dto.getMaterialId());
|
||||
material.setMaterialCode(dto.getMaterialCode());
|
||||
material.setMaterialDescription(dto.getMaterialDescription());
|
||||
material.setMaterialGroup(dto.getMaterialGroup());
|
||||
material.setMaterialGroupDesc(dto.getMaterialGroupDesc());
|
||||
material.setPlantId(dto.getPlantId());
|
||||
material.setStatus(Status.A);
|
||||
material.setCreatedBy(user.getUserId());
|
||||
material.setLastUpdatedBy(user.getUserId());
|
||||
return material;
|
||||
}
|
||||
|
||||
public void updateEntityFromDTO(MaterialMaster entity, MaterialMasterDTO dto, User user) {
|
||||
entity.setMaterialCode(dto.getMaterialCode());
|
||||
entity.setMaterialDescription(dto.getMaterialDescription());
|
||||
entity.setMaterialGroup(dto.getMaterialGroup());
|
||||
entity.setMaterialGroupDesc(dto.getMaterialGroupDesc());
|
||||
entity.setPlantId(dto.getPlantId());
|
||||
entity.setStatus(Status.A);
|
||||
entity.setLastUpdatedBy(user.getUserId());
|
||||
}
|
||||
|
||||
public MaterialMasterDTO toDTO(MaterialMaster entity) {
|
||||
MaterialMasterDTO dto = new MaterialMasterDTO();
|
||||
dto.setMaterialId(entity.getMaterialId());
|
||||
dto.setMaterialCode(entity.getMaterialCode());
|
||||
dto.setMaterialDescription(entity.getMaterialDescription());
|
||||
dto.setMaterialGroup(entity.getMaterialGroup());
|
||||
dto.setMaterialGroupDesc(entity.getMaterialGroupDesc());
|
||||
dto.setPlantId(entity.getPlantId());
|
||||
dto.setStatus(Status.A);
|
||||
return dto;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.sahyog.app.inbound.user.mapper;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.sahyog.app.inbound.user.dto.PlantDTO;
|
||||
import com.sahyog.app.inbound.user.dto.PlantMasterDTO;
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
import com.sahyog.app.inbound.user.model.PlantMaster;
|
||||
import com.sahyog.app.inbound.user.model.User;
|
||||
|
||||
@Component
|
||||
public class PlantMapper {
|
||||
|
||||
public PlantMaster toEntity(PlantDTO dto, User user) {
|
||||
PlantMaster plant = new PlantMaster();
|
||||
plant.setPlantCode(dto.getPlantCode());
|
||||
plant.setPlantDesc(dto.getPlantDesc());
|
||||
plant.setPlantPan(dto.getPlantPan());
|
||||
plant.setPlantGst(dto.getPlantGst());
|
||||
plant.setPlantGstRate(dto.getPlantGstRate());
|
||||
plant.setAddedChannel(dto.getAddedChannel());
|
||||
plant.setStatus(Status.A);
|
||||
plant.setCreatedBy(user.getUserId());
|
||||
plant.setLastUpdatedBy(user.getUserId());
|
||||
return plant;
|
||||
}
|
||||
|
||||
public void updateEntityFromDTO(PlantMaster entity, PlantDTO dto, User user) {
|
||||
entity.setPlantCode(dto.getPlantCode());
|
||||
entity.setPlantDesc(dto.getPlantDesc());
|
||||
entity.setPlantPan(dto.getPlantPan());
|
||||
entity.setPlantGst(dto.getPlantGst());
|
||||
entity.setPlantGstRate(dto.getPlantGstRate());
|
||||
entity.setAddedChannel(dto.getAddedChannel());
|
||||
entity.setStatus(Status.A);
|
||||
entity.setLastUpdatedBy(user.getUserId());
|
||||
}
|
||||
|
||||
public PlantDTO toDTO(PlantMaster plant) {
|
||||
PlantDTO dto = new PlantDTO();
|
||||
dto.setPlantId(plant.getPlantId());
|
||||
dto.setPlantCode(plant.getPlantCode());
|
||||
dto.setPlantDesc(plant.getPlantDesc());
|
||||
dto.setPlantPan(plant.getPlantPan());
|
||||
dto.setPlantGst(plant.getPlantGst());
|
||||
dto.setPlantGstRate(plant.getPlantGstRate());
|
||||
dto.setAddedChannel(plant.getAddedChannel());
|
||||
dto.setStatus(plant.getStatus());
|
||||
dto.setCreatedBy(plant.getCreatedBy());
|
||||
dto.setLastUpdatedBy(plant.getLastUpdatedBy());
|
||||
return dto;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.sahyog.app.inbound.user.mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.sahyog.app.inbound.user.dto.RoleDTO;
|
||||
import com.sahyog.app.inbound.user.model.Role;
|
||||
import com.sahyog.app.inbound.user.model.User;
|
||||
import com.sahyog.app.inbound.user.model.UserType;
|
||||
|
||||
@Component
|
||||
public class RoleMapper {
|
||||
|
||||
// public Role toEntity(RoleDTO roleDTO, short userTypeId, int createdBy, int lastUpdatedBy) {
|
||||
// Role role = new Role();
|
||||
// role.setRoleName(roleDTO.getRoleName());
|
||||
// role.setRoleDescription(roleDTO.getRoleDescription());
|
||||
// role.setUserTypeId(roleDTO.getUserType());
|
||||
// role.setStatus(roleDTO.getStatus());
|
||||
// role.setCreatedBy(createdBy);
|
||||
//// role.setLastUpdatedBy(lastUpdatedBy);
|
||||
//// role.setCreatedOn(LocalDateTime.now());
|
||||
//// role.setLastUpdatedOn(LocalDateTime.now());
|
||||
// return role;
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package com.sahyog.app.inbound.user.mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.sahyog.app.inbound.user.dto.TransporterMasterDto;
|
||||
import com.sahyog.app.inbound.user.dto.TransporterResponse;
|
||||
import com.sahyog.app.inbound.user.dto.TransporterUpdateDTO;
|
||||
import com.sahyog.app.inbound.user.model.Transporter;
|
||||
import com.sahyog.app.inbound.user.model.User;
|
||||
|
||||
@Component
|
||||
public class TransporterMapper {
|
||||
|
||||
|
||||
public Transporter toEntity(TransporterMasterDto dto, User user) {
|
||||
Transporter transporter = new Transporter();
|
||||
transporter.setPlantId((short) 2); // Cast the integer to short
|
||||
transporter.setSupplierCode(dto.getSupplierCode());
|
||||
transporter.setPlantCode(dto.getPlantCode());
|
||||
transporter.setTransporterCode(dto.getTransporterCode());
|
||||
transporter.setBpGrouping(dto.getBpGrouping());
|
||||
transporter.setSupplierAccountGroup(dto.getSupplierAccountGroup());
|
||||
transporter.setTransporterName(dto.getTransporterName());
|
||||
transporter.setTransporterFirstName(dto.getTransporterFirstName());
|
||||
transporter.setTransporterMiddleName(dto.getTransporterMiddleName());
|
||||
transporter.setTransporterLastName(dto.getTransporterLastName());
|
||||
transporter.setLegalEntity(dto.getLegalEntity());
|
||||
transporter.setPermanentAccountNumber(dto.getPermanentAccountNumber());
|
||||
transporter.setStreet(dto.getStreet());
|
||||
transporter.setHouseNumber(dto.getHouseNumber());
|
||||
transporter.setDistrict(dto.getDistrict());
|
||||
transporter.setDifferentCity(dto.getDifferentCity());
|
||||
transporter.setPostalCode(dto.getPostalCode());
|
||||
transporter.setCity(dto.getCity());
|
||||
transporter.setState(dto.getState());
|
||||
transporter.setCountry(dto.getCountry());
|
||||
transporter.setMobileNumber(dto.getMobileNumber());
|
||||
transporter.setEmailId(dto.getEmailId());
|
||||
transporter.setGstn(dto.getGstn());
|
||||
transporter.setTaxRegime(dto.getTaxRegime());
|
||||
transporter.setStatus(dto.getStatus());
|
||||
transporter.setShortCode(dto.getShortCode());
|
||||
transporter.setCreatedDate(dto.getCreatedDate());
|
||||
transporter.setUpdationDate(dto.getUpdationDate());
|
||||
transporter.setTaxCodeDesc(dto.getTaxCodeDesc());
|
||||
transporter.setTaxRate(dto.getTaxRate());
|
||||
transporter.setCreatedBy(user.getUserId());
|
||||
transporter.setLastUpdatedBy(user.getUserId());
|
||||
return transporter;
|
||||
}
|
||||
|
||||
public TransporterUpdateDTO toUpdateDTO(TransporterMasterDto dto, User user) {
|
||||
TransporterUpdateDTO updateDTO = new TransporterUpdateDTO();
|
||||
updateDTO.setSupplierCode(dto.getSupplierCode());
|
||||
updateDTO.setPlantId((short) 2); // Cast the integer to short
|
||||
updateDTO.setTransporterCode(dto.getTransporterCode());
|
||||
updateDTO.setPlantCode(dto.getPlantCode());
|
||||
updateDTO.setBpGrouping(dto.getBpGrouping());
|
||||
updateDTO.setSupplierAccountGroup(dto.getSupplierAccountGroup());
|
||||
updateDTO.setTransporterName(dto.getTransporterName());
|
||||
updateDTO.setTransporterFirstName(dto.getTransporterFirstName());
|
||||
updateDTO.setTransporterMiddleName(dto.getTransporterMiddleName());
|
||||
updateDTO.setTransporterLastName(dto.getTransporterLastName());
|
||||
updateDTO.setLegalEntity(dto.getLegalEntity());
|
||||
updateDTO.setPermanentAccountNumber(dto.getPermanentAccountNumber());
|
||||
updateDTO.setStreet(dto.getStreet());
|
||||
updateDTO.setHouseNumber(dto.getHouseNumber());
|
||||
updateDTO.setDistrict(dto.getDistrict());
|
||||
updateDTO.setDifferentCity(dto.getDifferentCity());
|
||||
updateDTO.setPostalCode(dto.getPostalCode());
|
||||
updateDTO.setCity(dto.getCity());
|
||||
updateDTO.setState(dto.getState());
|
||||
updateDTO.setCountry(dto.getCountry());
|
||||
updateDTO.setMobileNumber(dto.getMobileNumber());
|
||||
updateDTO.setEmailId(dto.getEmailId());
|
||||
updateDTO.setGstn(dto.getGstn());
|
||||
updateDTO.setTaxRegime(dto.getTaxRegime());
|
||||
updateDTO.setStatus(dto.getStatus());
|
||||
updateDTO.setShortCode(dto.getShortCode());
|
||||
updateDTO.setTaxCodeDesc(dto.getTaxCodeDesc());
|
||||
updateDTO.setTaxRate(dto.getTaxRate());
|
||||
updateDTO.setCreatedBy(user.getUserId());
|
||||
updateDTO.setLastUpdatedBy(user.getUserId());
|
||||
return updateDTO;
|
||||
}
|
||||
|
||||
public void updateEntityFromDTO(Transporter transporter, TransporterUpdateDTO dto) {
|
||||
transporter.setPlantCode(dto.getPlantCode());
|
||||
transporter.setBpGrouping(dto.getBpGrouping());
|
||||
transporter.setTransporterCode(dto.getTransporterCode());
|
||||
transporter.setSupplierAccountGroup(dto.getSupplierAccountGroup());
|
||||
transporter.setTransporterName(dto.getTransporterName());
|
||||
transporter.setTransporterFirstName(dto.getTransporterFirstName());
|
||||
transporter.setTransporterMiddleName(dto.getTransporterMiddleName());
|
||||
transporter.setTransporterLastName(dto.getTransporterLastName());
|
||||
transporter.setLegalEntity(dto.getLegalEntity());
|
||||
transporter.setPermanentAccountNumber(dto.getPermanentAccountNumber());
|
||||
transporter.setStreet(dto.getStreet());
|
||||
transporter.setHouseNumber(dto.getHouseNumber());
|
||||
transporter.setDistrict(dto.getDistrict());
|
||||
transporter.setDifferentCity(dto.getDifferentCity());
|
||||
transporter.setPostalCode(dto.getPostalCode());
|
||||
transporter.setCity(dto.getCity());
|
||||
transporter.setState(dto.getState());
|
||||
transporter.setCountry(dto.getCountry());
|
||||
transporter.setMobileNumber(dto.getMobileNumber());
|
||||
transporter.setEmailId(dto.getEmailId());
|
||||
transporter.setGstn(dto.getGstn());
|
||||
transporter.setTaxRegime(dto.getTaxRegime());
|
||||
transporter.setStatus(dto.getStatus());
|
||||
transporter.setShortCode(dto.getShortCode());
|
||||
transporter.setTaxCodeDesc(dto.getTaxCodeDesc());
|
||||
transporter.setTaxRate(dto.getTaxRate());
|
||||
transporter.setLastUpdatedBy(dto.getLastUpdatedBy());
|
||||
transporter.setUpdationDate(dto.getUpdationDate());
|
||||
}
|
||||
|
||||
|
||||
public TransporterResponse toResponse(Transporter transporter) {
|
||||
TransporterResponse response = new TransporterResponse();
|
||||
response.setSupplierCode(transporter.getSupplierCode());
|
||||
response.setTransporterName(transporter.getTransporterName());
|
||||
response.setSupplierAccountGroup(transporter.getSupplierAccountGroup());
|
||||
response.setState(transporter.getState());
|
||||
response.setBpGrouping(transporter.getBpGrouping());
|
||||
response.setLegalEntity(transporter.getLegalEntity());
|
||||
response.setPermanentAccountNumber(transporter.getPermanentAccountNumber());
|
||||
response.setStreet(transporter.getStreet());
|
||||
response.setHouseNumber(transporter.getHouseNumber());
|
||||
response.setDistrict(transporter.getDistrict());
|
||||
response.setDifferentCity(transporter.getDifferentCity());
|
||||
response.setPostalCode(transporter.getPostalCode());
|
||||
response.setCity(transporter.getCity());
|
||||
response.setCountry(transporter.getCountry());
|
||||
response.setMobileNumber(transporter.getMobileNumber());
|
||||
response.setEmailId(transporter.getEmailId());
|
||||
response.setGstn(transporter.getGstn());
|
||||
response.setTaxRegime(transporter.getTaxRegime());
|
||||
response.setShortCode(transporter.getShortCode());
|
||||
response.setStatus(transporter.getStatus());
|
||||
response.setTaxCodeDesc(transporter.getTaxCodeDesc());
|
||||
response.setTaxRate(transporter.getTaxRate());
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
package com.sahyog.app.inbound.user.mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.sahyog.app.inbound.user.dto.TransporterMasterDto;
|
||||
import com.sahyog.app.inbound.user.dto.UserDTO;
|
||||
import com.sahyog.app.inbound.user.dto.UserUpdateDTO;
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
import com.sahyog.app.inbound.user.model.User;
|
||||
import com.sahyog.app.inbound.user.model.UserType;
|
||||
import com.sahyog.app.inbound.user.repository.UserTypeRepository;
|
||||
|
||||
@Component
|
||||
public class UserMapper {
|
||||
|
||||
@Autowired
|
||||
private UserTypeRepository userTypeRepository;
|
||||
|
||||
public UserDTO toUserDTO(TransporterMasterDto dto) {
|
||||
String usertypeName = "Transporter";
|
||||
UserType userType = userTypeRepository.findByUsertypeName(usertypeName);
|
||||
if (userType == null) {
|
||||
throw new IllegalStateException("UserType 'Transporter' not found");
|
||||
}
|
||||
|
||||
UserDTO userDTO = new UserDTO();
|
||||
userDTO.setUserTypeId(userType.getUserTypeId());
|
||||
userDTO.setUserName(dto.getTransporterName());
|
||||
userDTO.setFirstName(dto.getTransporterFirstName());
|
||||
userDTO.setLastName(dto.getTransporterLastName());
|
||||
userDTO.setEmail(dto.getEmailId());
|
||||
userDTO.setMobile(dto.getMobileNumber());
|
||||
userDTO.setEmployeeTransCode(dto.getSupplierCode());
|
||||
userDTO.setAddedChannel("B");
|
||||
userDTO.setStatus(Status.A);
|
||||
userDTO.setCreatedBy(dto.getCreatedBy());
|
||||
userDTO.setLastUpdatedBy(dto.getLastUpdatedBy());
|
||||
// userDTO.setLastUpdatedOn(LocalDateTime.now());
|
||||
|
||||
return userDTO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Helper method to concatenate first, middle, and last name to create the userName
|
||||
private String createUserName(String firstName, String lastName) {
|
||||
StringBuilder userNameBuilder = new StringBuilder();
|
||||
|
||||
if (firstName != null && !firstName.isEmpty()) {
|
||||
userNameBuilder.append(firstName);
|
||||
}
|
||||
// if (middleName != null && !middleName.isEmpty()) {
|
||||
// userNameBuilder.append(" ").append(middleName);
|
||||
// }
|
||||
if (lastName != null && !lastName.isEmpty()) {
|
||||
userNameBuilder.append(" ").append(lastName);
|
||||
}
|
||||
|
||||
return userNameBuilder.toString().trim();
|
||||
}
|
||||
|
||||
// NEW: Method to map User entity to UserDTO
|
||||
public UserDTO toDTO(User user) {
|
||||
UserDTO userDTO = new UserDTO();
|
||||
userDTO.setUserId(user.getUserId());
|
||||
userDTO.setUserTypeId(user.getUserTypeId());
|
||||
userDTO.setUserName(createUserName(user.getFirstName(), user.getLastName()));
|
||||
userDTO.setFirstName(user.getFirstName());
|
||||
// userDTO.setMiddleName(user.getMiddleName());
|
||||
userDTO.setLastName(user.getLastName());
|
||||
userDTO.setEmail(user.getEmail());
|
||||
userDTO.setMobile(user.getMobile());
|
||||
userDTO.setAddedChannel(user.getAddedChannel());
|
||||
userDTO.setStatus(user.getStatus());
|
||||
userDTO.setCreatedBy(user.getCreatedBy());
|
||||
userDTO.setLastUpdatedBy(user.getLastUpdatedBy());
|
||||
|
||||
return userDTO;
|
||||
}
|
||||
|
||||
// Method to update user details based on UserDTO
|
||||
public void updateUserFromDTO(User existingUser, UserDTO userDTO) {
|
||||
existingUser.setUserTypeId(userDTO.getUserTypeId());
|
||||
existingUser.setUserName(createUserName(userDTO.getFirstName(), userDTO.getLastName())); // Automatically create userName
|
||||
existingUser.setFirstName(userDTO.getFirstName());
|
||||
// existingUser.setMiddleName(userDTO.getMiddleName());
|
||||
existingUser.setLastName(userDTO.getLastName());
|
||||
existingUser.setEmail(userDTO.getEmail());
|
||||
existingUser.setMobile(userDTO.getMobile());
|
||||
existingUser.setAddedChannel(userDTO.getAddedChannel());
|
||||
existingUser.setStatus(userDTO.getStatus());
|
||||
}
|
||||
|
||||
// Method to update user details based on UserUpdateDTO
|
||||
public void updateUserFromUpdateDTO(User existingUser, UserUpdateDTO userUpdateDTO) {
|
||||
existingUser.setUserName(createUserName(userUpdateDTO.getFirstName(), userUpdateDTO.getLastName())); // Automatically create userName
|
||||
existingUser.setFirstName(userUpdateDTO.getFirstName());
|
||||
// existingUser.setMiddleName(userUpdateDTO.getMiddleName());
|
||||
existingUser.setLastName(userUpdateDTO.getLastName());
|
||||
existingUser.setEmail(userUpdateDTO.getEmailId());
|
||||
existingUser.setMobile(userUpdateDTO.getPhoneNumber());
|
||||
existingUser.setAddedChannel(userUpdateDTO.getAddedChannel());
|
||||
existingUser.setStatus(userUpdateDTO.getStatus());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// // NEW: Method to map User entity to UserDTO
|
||||
// public UserDTO toDTO(User user) {
|
||||
// UserDTO userDTO = new UserDTO();
|
||||
// userDTO.setUserId(user.getUserId());
|
||||
// userDTO.setUserTypeId(user.getUserTypeId());
|
||||
// userDTO.setUserName(user.getUserName());
|
||||
// userDTO.setFirstName(user.getFirstName());
|
||||
// userDTO.setLastName(user.getLastName());
|
||||
// userDTO.setEmail(user.getEmail());
|
||||
// userDTO.setMobile(user.getMobile());
|
||||
// userDTO.setAddedChannel(user.getAddedChannel());
|
||||
// userDTO.setStatus(user.getStatus());
|
||||
// userDTO.setCreatedBy(user.getCreatedBy());
|
||||
// userDTO.setLastUpdatedBy(user.getLastUpdatedBy());
|
||||
//// userDTO.setLastUpdatedOn(LocalDateTime.now());
|
||||
//
|
||||
// return userDTO;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public void updateUserFromDTO(User existingUser, UserDTO userDTO) {
|
||||
// existingUser.setUserTypeId(userDTO.getUserTypeId());
|
||||
// existingUser.setUserName(userDTO.getUserName());
|
||||
// existingUser.setFirstName(userDTO.getFirstName());
|
||||
// existingUser.setLastName(userDTO.getLastName());
|
||||
// existingUser.setEmail(userDTO.getEmail());
|
||||
// existingUser.setMobile(userDTO.getMobile());
|
||||
// existingUser.setAddedChannel(userDTO.getAddedChannel());
|
||||
// existingUser.setStatus(userDTO.getStatus());
|
||||
// }
|
||||
//
|
||||
// public void updateUserFromUpdateDTO(User existingUser, UserUpdateDTO userUpdateDTO) {
|
||||
// existingUser.setUserName(userUpdateDTO.getUserName());
|
||||
// existingUser.setFirstName(userUpdateDTO.getFirstName());
|
||||
// existingUser.setLastName(userUpdateDTO.getLastName());
|
||||
// existingUser.setEmail(userUpdateDTO.getEmailId());
|
||||
// existingUser.setMobile(userUpdateDTO.getPhoneNumber());
|
||||
// existingUser.setAddedChannel(userUpdateDTO.getAddedChannel());
|
||||
// existingUser.setStatus(userUpdateDTO.getStatus());
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.sahyog.app.inbound.user.mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.sahyog.app.inbound.user.dto.UserTypeCreateDTO;
|
||||
import com.sahyog.app.inbound.user.model.UserType;
|
||||
|
||||
@Component
|
||||
public class UserTypeMapper {
|
||||
|
||||
public UserType toEntity(UserTypeCreateDTO userTypeCreateDTO, int createdBy) {
|
||||
UserType userType = new UserType();
|
||||
userType.setUsertypeName(userTypeCreateDTO.getUsertypeName());
|
||||
userType.setStatus(userTypeCreateDTO.getStatus());
|
||||
userType.setDescription(userType.getDescription());
|
||||
// userType.setCreatedBy(createdBy);
|
||||
// userType.setLastUpdatedBy(createdBy);
|
||||
// userType.s(LocalDateTime.now());
|
||||
// userType.setLastUpdatedOn(LocalDateTime.now());
|
||||
return userType;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.sahyog.app.inbound.user.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
@Entity
|
||||
@Table(name = "materialmaster")
|
||||
public class MaterialMaster {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "material_id", nullable = false, updatable = false)
|
||||
private int materialId;
|
||||
|
||||
@Column(name = "material_code", length = 40, nullable = false)
|
||||
private String materialCode;
|
||||
|
||||
@Column(name = "material_description", length = 60, nullable = false)
|
||||
private String materialDescription;
|
||||
|
||||
@Column(name = "material_group", length = 30)
|
||||
private String materialGroup;
|
||||
|
||||
@Column(name = "material_group_desc", length = 40)
|
||||
private String materialGroupDesc;
|
||||
|
||||
@Column(name = "plant_id", nullable = false)
|
||||
private int plantId;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "status", length = 1, nullable = false)
|
||||
private Status status;
|
||||
|
||||
// @Column(name = "created_on", nullable = false, updatable = false)
|
||||
// private Timestamp createdOn;
|
||||
|
||||
@Column(name = "created_by", nullable = false)
|
||||
private int createdBy;
|
||||
|
||||
// @Column(name = "last_updated_on", nullable = false)
|
||||
// private Timestamp lastUpdatedOn;
|
||||
|
||||
@Column(name = "last_updated_by", nullable = false)
|
||||
private int lastUpdatedBy;
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.sahyog.app.inbound.user.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.DecimalMin;
|
||||
import jakarta.validation.constraints.Digits;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
@Entity
|
||||
@Table(name="plantmaster")
|
||||
public class PlantMaster {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "plant_id", nullable = false, updatable = false)
|
||||
private Short plantId;
|
||||
|
||||
@NotNull(message = "Plant code cannot be null")
|
||||
@Size(min = 4, max = 4, message = "Plant code must be exactly 4 characters")
|
||||
@Column(name = "plant_code", nullable = false, length = 4, unique = true)
|
||||
private String plantCode;
|
||||
|
||||
@Size(max = 30, message = "Plant description cannot exceed 30 characters")
|
||||
@Column(name = "plant_desc", length = 30)
|
||||
private String plantDesc;
|
||||
|
||||
@Size(max = 30, message = "Plant PAN cannot exceed 30 characters")
|
||||
@Column(name = "plant_pan", length = 30)
|
||||
private String plantPan;
|
||||
|
||||
@Size(max = 30, message = "Plant GST cannot exceed 30 characters")
|
||||
@Column(name = "plant_gst", length = 30)
|
||||
private String plantGst;
|
||||
|
||||
@NotNull(message = "Plant GST rate cannot be null")
|
||||
@DecimalMin(value = "0.00", inclusive = false, message = "Plant GST rate must be greater than 0")
|
||||
@Digits(integer = 9, fraction = 2, message = "Plant GST rate must be a valid decimal with 2 decimal places")
|
||||
@Column(name = "plant_gst_rate", nullable = false, precision = 11, scale = 2)
|
||||
private BigDecimal plantGstRate;
|
||||
|
||||
@NotNull(message = "Added channel cannot be null")
|
||||
@Pattern(regexp = "^[A-Za-z0-9]{1}$", message = "Added channel must be a single alphanumeric character")
|
||||
@Column(name = "added_channel", nullable = false, length = 1)
|
||||
private String addedChannel;
|
||||
|
||||
@NotNull(message = "Status cannot be null")
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "status", nullable = false, length = 1)
|
||||
private Status status;
|
||||
|
||||
@NotNull(message = "Created by cannot be null")
|
||||
@Column(name = "created_by", nullable = false)
|
||||
private int createdBy;
|
||||
|
||||
@NotNull(message = "Last updated by cannot be null")
|
||||
@Column(name = "last_updated_by", nullable = false)
|
||||
private int lastUpdatedBy;
|
||||
|
||||
@Column(name="last_updated_on")
|
||||
private LocalDateTime lastUpdatedOn = LocalDateTime.now();
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.sahyog.app.inbound.user.model;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import java.time.LocalDateTime;
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class Response<T> {
|
||||
private int status;
|
||||
private String message;
|
||||
// private String details; // Additional field for error details
|
||||
private T data;
|
||||
private String timestamp; // Use String for ISO 8601 format
|
||||
|
||||
// Custom constructor for success with data
|
||||
public Response(int statusCode, String message, T data) {
|
||||
this.status = statusCode;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
this.timestamp = LocalDateTime.now().toString(); // ISO format timestamp
|
||||
}
|
||||
|
||||
// Custom constructor for messages without data
|
||||
public Response(int statusCode, String message) {
|
||||
this(statusCode, message, null);
|
||||
}
|
||||
|
||||
// Generic method to create success responses with data
|
||||
public static <T> Response<T> success(T data) {
|
||||
return new Response<>(200, "Success", data);
|
||||
}
|
||||
|
||||
// Generic method to create error responses with details
|
||||
public static <T> Response<T> error(int statusCode, String message) {
|
||||
return new Response<>(statusCode, message, null);
|
||||
}
|
||||
|
||||
// Method to update the message dynamically
|
||||
public Response<T> withMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Method to update the details dynamically
|
||||
public Response<T> withDetails(String details) {
|
||||
// this.details = details;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Updated withData() method to accept List<Map<String, Object>> as data
|
||||
public Response<List<Map<String, Object>>> withData(List<Map<String, Object>> data) {
|
||||
this.data = (T) data; // Cast data to type T
|
||||
return (Response<List<Map<String, Object>>>) this; // Ensure the return type matches
|
||||
}
|
||||
|
||||
// Generic method to create error responses with default status code
|
||||
public static <T> Response<T> error(String message) {
|
||||
return new Response<>(500, message, null); // Default status code to 500
|
||||
}
|
||||
|
||||
public static Response<List<Map<String, Object>>> failure(String message, List<Map<String, Object>> userResponseData) {
|
||||
Response<List<Map<String, Object>>> response = new Response<>();
|
||||
// response.setStatus("failure");
|
||||
response.setMessage(message);
|
||||
response.setData(userResponseData);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.sahyog.app.inbound.user.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.RoleType;
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "rolemaster", indexes = {
|
||||
// @Index(name = "uk_role_name", columnList = "role_name", unique = true),
|
||||
// @Index(name = "idx_role_status", columnList = "status")
|
||||
})
|
||||
public class Role {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "role_id", nullable = false, updatable = false)
|
||||
private short roleId;
|
||||
|
||||
@NotNull(message = "Role name cannot be null")
|
||||
@Size(min = 1, max = 30, message = "Role name must be between 1 and 30 characters")
|
||||
@Column(name = "role_name", length = 30, nullable = false)
|
||||
private String roleName;
|
||||
|
||||
@NotNull(message = "Role description cannot be null")
|
||||
@Size(min = 1, max = 50, message = "Role description must be between 1 and 50 characters")
|
||||
@Column(name = "rode_description", length = 50, nullable = false)
|
||||
private String roleDescription;
|
||||
|
||||
@NotNull(message = "User type ID cannot be null")
|
||||
@Min(value = 1, message = "User type ID must be a positive integer")
|
||||
@Column(name = "usertype_id", nullable = false)
|
||||
private short userTypeId;
|
||||
|
||||
@NotNull(message = "Status cannot be null")
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "status", length = 1, nullable = false)
|
||||
private Status status;
|
||||
|
||||
@NotNull(message = "Created by cannot be null")
|
||||
@Min(value = 1, message = "Created by must be a positive integer")
|
||||
@Column(name = "created_by", nullable = false)
|
||||
private int createdBy;
|
||||
|
||||
@NotNull(message = "Last updated by cannot be null")
|
||||
@Min(value = 1, message = "Last updated by must be a positive integer")
|
||||
@Column(name = "last_updated_by", nullable = false)
|
||||
private int lastUpdatedBy;
|
||||
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
package com.sahyog.app.inbound.user.model;
|
||||
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
@Entity
|
||||
@Table(name = "transportermaster", indexes = {
|
||||
@Index(name = "idx_supplier_code", columnList = "supplier_code"),
|
||||
@Index(name = "idx_transporter_status", columnList = "status"),
|
||||
@Index(name = "idx_transporter_plant_code", columnList = "plant_code")
|
||||
})
|
||||
public class Transporter {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "transporter_id", nullable = false, updatable = false)
|
||||
private int transporterId;
|
||||
|
||||
@Column(name = "plant_id", nullable = false)
|
||||
@NotNull(message = "Plant ID cannot be null")
|
||||
private short plantId;
|
||||
|
||||
@Column(name = "plant_code", length = 4, nullable = false)
|
||||
@NotNull(message = "Plant code cannot be null")
|
||||
@Size(min = 4, max = 4, message = "Plant code must be exactly 4 characters")
|
||||
private String plantCode;
|
||||
|
||||
@Column(name="user_id")
|
||||
@Positive(message = "User ID must be a positive number")
|
||||
private int userId;
|
||||
|
||||
@Column(name = "BP_GROUPING")
|
||||
@Size(max = 255, message = "BP Grouping cannot exceed 255 characters")
|
||||
private String bpGrouping;
|
||||
|
||||
@Column(name = "transporter_code", length = 20)
|
||||
@Size(max = 20, message = "Transporter code cannot exceed 20 characters")
|
||||
private String transporterCode;
|
||||
|
||||
@Column(name = "supplier_code", length = 20)
|
||||
@Size(max = 20, message = "Supplier code cannot exceed 20 characters")
|
||||
private String supplierCode;
|
||||
|
||||
@Column(name = "supplier_account_group", length = 20)
|
||||
@Size(max = 20, message = "Supplier account group cannot exceed 20 characters")
|
||||
private String supplierAccountGroup;
|
||||
|
||||
@Column(name = "transporter_name", length = 100, nullable = false)
|
||||
@NotNull(message = "Transporter name cannot be null")
|
||||
@Size(max = 100, message = "Transporter name cannot exceed 100 characters")
|
||||
private String transporterName;
|
||||
|
||||
@Column(name = "transporter_fname", length = 40, nullable = false)
|
||||
@NotNull(message = "First name cannot be null")
|
||||
@Size(max = 40, message = "First name cannot exceed 40 characters")
|
||||
private String transporterFirstName;
|
||||
|
||||
@Column(name = "transporter_mname", length = 30, nullable = false)
|
||||
@NotNull(message = "Middle name cannot be null")
|
||||
@Size(max = 30, message = "Middle name cannot exceed 30 characters")
|
||||
private String transporterMiddleName;
|
||||
|
||||
@Column(name = "transporter_lname", length = 30, nullable = false)
|
||||
@NotNull(message = "Last name cannot be null")
|
||||
@Size(max = 30, message = "Last name cannot exceed 30 characters")
|
||||
private String transporterLastName;
|
||||
|
||||
|
||||
@Column(name = "legal_entity", length = 100)
|
||||
@Size(max = 100, message = "Legal entity cannot exceed 100 characters")
|
||||
private String legalEntity;
|
||||
|
||||
@Column(name = "permanent_account_number", length = 10)
|
||||
@Pattern(regexp = "[A-Z]{5}[0-9]{4}[A-Z]{1}", message = "Invalid PAN format")
|
||||
private String permanentAccountNumber;
|
||||
|
||||
|
||||
@Column(name = "street", length = 40)
|
||||
@Size(max = 40, message = "Street cannot exceed 40 characters")
|
||||
private String street;
|
||||
|
||||
@Column(name = "house_number", length = 10)
|
||||
@Size(max = 10, message = "House number cannot exceed 10 characters")
|
||||
private String houseNumber;
|
||||
|
||||
@Column(name = "district", length = 40)
|
||||
@Size(max = 40, message = "District cannot exceed 40 characters")
|
||||
private String district;
|
||||
|
||||
@Column(name = "different_city", length = 40)
|
||||
@Size(max = 40, message = "City cannot exceed 40 characters")
|
||||
private String differentCity;
|
||||
|
||||
@Column(name = "postal_code", length = 10)
|
||||
@Pattern(regexp = "\\d{5,10}", message = "Postal code must be between 5 to 10 digits")
|
||||
private String postalCode;
|
||||
|
||||
@Column(name = "city", length = 40)
|
||||
@Size(max = 40, message = "City cannot exceed 40 characters")
|
||||
private String city;
|
||||
|
||||
@Column(name = "country", length = 40)
|
||||
@Size(max = 40, message = "Country cannot exceed 40 characters")
|
||||
private String country;
|
||||
|
||||
@Column(name = "state", length = 40)
|
||||
@Size(max = 40, message = "State cannot exceed 40 characters")
|
||||
private String state;
|
||||
|
||||
@Column(name = "mobile_number", length = 10)
|
||||
@Pattern(regexp = "\\d{10}", message = "Mobile number must be exactly 10 digits")
|
||||
private String mobileNumber;
|
||||
|
||||
@Column(name = "email_id", length = 50)
|
||||
@Email(message = "Invalid email format")
|
||||
@Size(max = 50, message = "Email cannot exceed 50 characters")
|
||||
private String emailId;
|
||||
|
||||
@Column(name = "gstn", length = 40)
|
||||
@Size(max = 40, message = "GSTN cannot exceed 40 characters")
|
||||
private String gstn;
|
||||
|
||||
@Column(name = "tax_regime", length = 10)
|
||||
@Size(max = 10, message = "Tax regime cannot exceed 10 characters")
|
||||
private String taxRegime;
|
||||
|
||||
@Column(name = "short_code", length = 40)
|
||||
@Size(max = 40, message = "Short code cannot exceed 40 characters")
|
||||
private String shortCode;
|
||||
|
||||
|
||||
@Column(name = "created_date")
|
||||
private LocalDate createdDate;
|
||||
|
||||
@Column(name = "updation_date")
|
||||
private LocalDate updationDate;
|
||||
|
||||
@Column(name = "tax_code_desc")
|
||||
@Size(max = 255, message = "Tax code description cannot exceed 255 characters")
|
||||
private String taxCodeDesc;
|
||||
|
||||
@Column(name = "tax_rate")
|
||||
@Min(value = 0, message = "Tax rate cannot be negative")
|
||||
@Max(value = 100, message = "Tax rate cannot exceed 100")
|
||||
private int taxRate;
|
||||
|
||||
@Column(name = "status", length = 1, nullable = false)
|
||||
@NotNull(message = "Status cannot be null")
|
||||
@Pattern(regexp = "[AI]", message = "Status must be 'A' (Active) or 'I' (Inactive)")
|
||||
private String status;
|
||||
|
||||
@Column(name = "created_by", nullable = false)
|
||||
@NotNull(message = "Created by cannot be null")
|
||||
private int createdBy;
|
||||
|
||||
@Column(name = "last_updated_by", nullable = false)
|
||||
@NotNull(message = "Last updated by cannot be null")
|
||||
private int lastUpdatedBy;
|
||||
|
||||
@Column(name = "last_updated_on", nullable = false)
|
||||
private LocalDateTime lastUpdatedOn = LocalDateTime.now();
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
package com.sahyog.app.inbound.user.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
@Entity
|
||||
@Table(name = "usermaster")
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "user_id", nullable = false, updatable = false)
|
||||
private int userId;
|
||||
|
||||
@NotNull(message = "User type ID cannot be null")
|
||||
@Min(value = 1, message = "User type ID must be a positive integer")
|
||||
@Column(name = "usertype_id", nullable = false)
|
||||
private short userTypeId;
|
||||
|
||||
@NotNull(message = "Username cannot be null")
|
||||
@Size(min = 1, max = 80, message = "Username must be between 1 and 80 characters")
|
||||
@Column(name = "user_name", length = 80, nullable = false)
|
||||
private String userName;
|
||||
|
||||
@NotNull(message = "First name cannot be null")
|
||||
@Size(min = 1, max = 40, message = "First name must be between 1 and 40 characters")
|
||||
@Column(name = "user_fname", length = 40, nullable = false)
|
||||
private String firstName;
|
||||
|
||||
@Size(max = 40, message = "Last name must not exceed 40 characters")
|
||||
@Column(name = "user_lname", length = 40)
|
||||
private String lastName;
|
||||
|
||||
@NotNull(message = "Email cannot be null")
|
||||
@Email(message = "Email should be valid")
|
||||
@Size(max = 40, message = "Email must not exceed 40 characters")
|
||||
@Column(name = "user_email", length = 40, nullable = false, unique = true)
|
||||
private String email;
|
||||
|
||||
@Size(max = 10, message = "Mobile number must not exceed 10 characters")
|
||||
@Column(name = "user_mobile", length = 10)
|
||||
private String mobile;
|
||||
|
||||
@Size(max = 20, message = "Employee transaction code must not exceed 20 characters")
|
||||
@Column(name = "user_emp_trans_code", length = 20)
|
||||
private String employeeTransCode;
|
||||
|
||||
@NotNull(message = "Added channel cannot be null")
|
||||
@Size(min = 1, max = 1, message = "Added channel must be exactly 1 character")
|
||||
@Column(name = "user_added_channel", length = 1, nullable = false)
|
||||
private String addedChannel;
|
||||
|
||||
@NotNull(message = "Status cannot be null")
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "status", length = 1, nullable = false)
|
||||
private Status status;
|
||||
|
||||
@NotNull(message = "Created by cannot be null")
|
||||
@Min(value = 1, message = "Created by must be a positive integer")
|
||||
@Column(name = "created_by", nullable = false)
|
||||
private int createdBy;
|
||||
|
||||
// @Column(name="created_on")
|
||||
// private LocalDateTime createdOn;
|
||||
|
||||
@NotNull(message = "Last updated by cannot be null")
|
||||
@Min(value = 1, message = "Last updated by must be a positive integer")
|
||||
@Column(name = "last_updated_by", nullable = false)
|
||||
private int lastUpdatedBy;
|
||||
|
||||
@Column(name = "last_updated_on", nullable = false)
|
||||
private LocalDateTime lastUpdatedOn = LocalDateTime.now();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.sahyog.app.inbound.user.model;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name="userplant")
|
||||
public class UserPlant {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "userplant_id", nullable = false, updatable = false)
|
||||
private int userPlantId;
|
||||
|
||||
@NotNull(message = "User ID cannot be null")
|
||||
@Min(value = 1, message = "User ID must be a positive integer")
|
||||
@Column(name = "user_id", nullable = false)
|
||||
private int userId;
|
||||
|
||||
@NotNull(message = "Plant ID cannot be null")
|
||||
@Min(value = 1, message = "Plant ID must be a positive integer")
|
||||
@Column(name = "plant_id", nullable = false)
|
||||
private int plantId;
|
||||
|
||||
@NotNull(message = "Status cannot be null")
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "status", length = 1, nullable = false)
|
||||
private Status status;
|
||||
|
||||
@NotNull(message = "Created by cannot be null")
|
||||
@Min(value = 1, message = "Created by must be a positive integer")
|
||||
@Column(name = "created_by", nullable = false)
|
||||
private int createdBy;
|
||||
|
||||
@NotNull(message = "Last updated by cannot be null")
|
||||
@Min(value = 1, message = "Last updated by must be a positive integer")
|
||||
@Column(name = "last_updated_by", nullable = false)
|
||||
private int lastUpdatedBy;
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.sahyog.app.inbound.user.model;
|
||||
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "userrole")
|
||||
public class UserRole {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "userrole_id")
|
||||
private int userRoleId;
|
||||
|
||||
@Column(name = "user_id")
|
||||
private int userId;
|
||||
|
||||
@Column(name = "role_id")
|
||||
private int roleId;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "status", length = 1, nullable = false)
|
||||
private Status status;
|
||||
|
||||
@Column(name = "created_by", nullable = false)
|
||||
private int createdBy;
|
||||
|
||||
@Column(name = "last_updated_by", nullable = false)
|
||||
private int lastUpdatedBy;
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.sahyog.app.inbound.user.model;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.persistence.UniqueConstraint;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "usertypemaster")
|
||||
public class UserType {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "usertype_id", nullable = false, updatable = false)
|
||||
private short userTypeId;
|
||||
|
||||
@NotNull(message = "User type name cannot be null")
|
||||
@Size(max = 255, message = "User type name must be less than or equal to 255 characters")
|
||||
@Column(name = "usertype_name", length = 255, unique = true, nullable = false)
|
||||
private String usertypeName;
|
||||
|
||||
@Size(max = 255, message = "User type description must be less than or equal to 255 characters")
|
||||
@Column(name = "usertype_description", length = 255)
|
||||
private String description;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "status", length = 1, nullable = true)
|
||||
private Status status;
|
||||
|
||||
@NotNull(message = "Created by cannot be null")
|
||||
@Min(value = 1, message = "Created by must be a positive integer")
|
||||
@Column(name = "created_by", nullable = false)
|
||||
private int createdBy;
|
||||
|
||||
@NotNull(message = "Last updated by cannot be null")
|
||||
@Min(value = 1, message = "Last updated by must be a positive integer")
|
||||
@Column(name = "last_updated_by", nullable = false)
|
||||
private int lastUpdatedBy;
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.sahyog.app.inbound.user.model;
|
||||
|
||||
public class UserType1 {
|
||||
|
||||
private short userTypeId;
|
||||
private String usertypeName;
|
||||
private String description;
|
||||
private String status;
|
||||
private int createdBy;
|
||||
private int lastUpdatedBy;
|
||||
public short getUserTypeId() {
|
||||
return userTypeId;
|
||||
}
|
||||
public void setUserTypeId(short userTypeId) {
|
||||
this.userTypeId = userTypeId;
|
||||
}
|
||||
public String getUsertypeName() {
|
||||
return usertypeName;
|
||||
}
|
||||
public void setUsertypeName(String usertypeName) {
|
||||
this.usertypeName = usertypeName;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
public int getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
public void setCreatedBy(int createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
public int getLastUpdatedBy() {
|
||||
return lastUpdatedBy;
|
||||
}
|
||||
public void setLastUpdatedBy(int lastUpdatedBy) {
|
||||
this.lastUpdatedBy = lastUpdatedBy;
|
||||
}
|
||||
public UserType1(short userTypeId, String usertypeName, String description, String status, int createdBy,
|
||||
int lastUpdatedBy) {
|
||||
super();
|
||||
this.userTypeId = userTypeId;
|
||||
this.usertypeName = usertypeName;
|
||||
this.description = description;
|
||||
this.status = status;
|
||||
this.createdBy = createdBy;
|
||||
this.lastUpdatedBy = lastUpdatedBy;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserType1 [userTypeId=" + userTypeId + ", usertypeName=" + usertypeName + ", description=" + description
|
||||
+ ", status=" + status + ", createdBy=" + createdBy + ", lastUpdatedBy=" + lastUpdatedBy + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.sahyog.app.inbound.user.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.sahyog.app.inbound.user.model.MaterialMaster;
|
||||
|
||||
public interface MaterialMasterRepository extends JpaRepository<MaterialMaster, Integer> {
|
||||
|
||||
|
||||
Optional<MaterialMaster> findByPlantIdAndMaterialCode(int plantId, String materialCode);
|
||||
|
||||
Optional<MaterialMaster> findByPlantIdAndMaterialId(Short plantId, Short materialId);
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.sahyog.app.inbound.user.repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
import com.sahyog.app.inbound.user.model.PlantMaster;
|
||||
|
||||
public interface PlantRepository extends JpaRepository<PlantMaster, Short>{
|
||||
|
||||
List<PlantMaster> findAll();
|
||||
|
||||
Optional<PlantMaster> findByPlantCode(String plantCode);
|
||||
|
||||
// Non-paginated query to fetch plants by status
|
||||
List<PlantMaster> findByStatus(Status status);
|
||||
|
||||
// Paginated query to fetch plants by status
|
||||
Page<PlantMaster> findByStatus(Status status, Pageable pageable);
|
||||
|
||||
// Paginated query to fetch all plants
|
||||
Page<PlantMaster> findAll(Pageable pageable);
|
||||
|
||||
Page<PlantMaster> findByStatusIn(List<Status> statuses, Pageable pageable);
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.sahyog.app.inbound.user.repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.sahyog.app.inbound.user.model.Role;
|
||||
|
||||
public interface RoleRepository extends JpaRepository<Role, Short> {
|
||||
|
||||
List<Role> findByUserTypeId(short userTypeId);
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.sahyog.app.inbound.user.repository;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.sahyog.app.inbound.user.model.Transporter;
|
||||
|
||||
|
||||
@Repository
|
||||
public interface TransporterRepository extends JpaRepository<Transporter, Integer> {
|
||||
|
||||
Optional<Transporter> findBySupplierCode(String supplierCode);
|
||||
|
||||
Page<Transporter> findAll(Specification<Transporter> specification, Pageable pageable);
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.sahyog.app.inbound.user.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import com.sahyog.app.inbound.user.model.UserPlant;
|
||||
|
||||
import feign.Param;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
public interface UserPlantRepository extends JpaRepository<UserPlant, Integer>{
|
||||
|
||||
// Fetch UserPlants by userId
|
||||
List<UserPlant> findByUserId(int userId);
|
||||
|
||||
@Query("SELECT up.plantId FROM UserPlant up WHERE up.userId = :userId")
|
||||
List<Integer> findPlantIdsByUserId(@Param("userId") int userId);
|
||||
|
||||
// Delete UserPlants by userId and plantIds
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query("DELETE FROM UserPlant up WHERE up.userId = :userId AND up.plantId IN :plantIds")
|
||||
void deleteByUserIdAndPlantIds(@Param("userId") int userId, @Param("plantIds") List<Integer> plantIds);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.sahyog.app.inbound.user.repository;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.sahyog.app.inbound.user.dto.UserDTO;
|
||||
import com.sahyog.app.inbound.user.enums.Status;
|
||||
import com.sahyog.app.inbound.user.model.User;
|
||||
|
||||
import feign.Param;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<User, Integer> {
|
||||
|
||||
|
||||
|
||||
User findByUserTypeId(short userTypeId);
|
||||
|
||||
Page<User> findByStatus(Status status, Pageable pageable);
|
||||
|
||||
User findByEmployeeTransCode(String employeeTransCode);
|
||||
|
||||
Optional<User> findByEmailAndEmployeeTransCode(String email, String employeeTransCode);
|
||||
|
||||
Page<User> findByStatusIn(List<Status> statuses, Pageable pageable);
|
||||
|
||||
List<User> findByStatusIn(List<Status> statuses);
|
||||
|
||||
@Query(value = "SELECT * FROM users WHERE last_updated_on = :lastUpdatedOn", nativeQuery = true)
|
||||
List<User> findUsersByLastUpdatedOn(@Param("lastUpdatedOn") Timestamp lastUpdatedOn);
|
||||
|
||||
@Query(value = "SELECT * FROM users WHERE status = :status ORDER BY last_updated_on DESC", nativeQuery = true)
|
||||
Page<User> findUsersByStatusWithPagination(@Param("status") String status, Pageable pageable);
|
||||
|
||||
User findByEmail(String email);
|
||||
|
||||
User findByEmployeeTransCodeOrEmail(String employeeTransCode, String email);
|
||||
|
||||
// @Query("SELECT new com.example.dto.UserDTO(u.userId, u.userName, u.firstName, u.lastName, u.email, u.mobile, u.employeeTransCode, u.addedChannel, u.status, u.createdBy, u.lastUpdatedBy, ut.userTypeName) " +
|
||||
// "FROM User u JOIN u.userType ut " +
|
||||
// "WHERE (:userTypeName IS NULL OR ut.userTypeName = :userTypeName) " +
|
||||
// "AND (:email IS NULL OR u.email = :email) " +
|
||||
// "AND (:employeeTransCode IS NULL OR u.employeeTransCode = :employeeTransCode) " +
|
||||
// "AND (:status IS NULL OR u.status = :status)")
|
||||
// Page<UserDTO> findUsersWithFilters(@Param("userTypeName") String userTypeName,
|
||||
// @Param("email") String email,
|
||||
// @Param("employeeTransCode") String employeeTransCode,
|
||||
// @Param("status") Status status, Pageable pageable);
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.sahyog.app.inbound.user.repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.sahyog.app.inbound.user.model.UserRole;
|
||||
|
||||
import feign.Param;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
@Repository
|
||||
public interface UserRoleRepository extends JpaRepository<UserRole, Integer> {
|
||||
|
||||
// @Query(value = "SELECT ur.userrole_id, ur.status, ur.user_id FROM userrole ur WHERE ur.user_id = :userId AND ur.role_id = :roleId", nativeQuery = true)
|
||||
Optional<UserRole> findByUserIdAndRoleId(@Param("userId") int userId, @Param("roleId") int roleId);
|
||||
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query("DELETE FROM UserRole ur WHERE ur.userId = :userId AND ur.roleId IN :roleIds")
|
||||
void deleteByUserIdAndRoleIds(@Param("userId") int userId, @Param("roleIds") List<Integer> roleIds);
|
||||
|
||||
List<UserRole> findByUserId(int userId);
|
||||
|
||||
@Query("SELECT ur.roleId FROM UserRole ur WHERE ur.userId = :userId")
|
||||
List<Integer> findRoleIdsByUserId(@Param("userId") int userId);
|
||||
|
||||
// List<Integer> findRoleIdsByUserId(int userId);
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.sahyog.app.inbound.user.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.sahyog.app.inbound.user.model.UserType;
|
||||
|
||||
import feign.Param;
|
||||
|
||||
@Repository
|
||||
public interface UserTypeRepository extends JpaRepository<UserType, Short> {
|
||||
|
||||
// @Query("SELECT u FROM usertypemaster1 WHERE LOWER(usertype_name) = LOWER(:usertypeName)")
|
||||
UserType findByUsertypeName(@Param("usertypeName") String usertypeName);
|
||||
// UserType findByUsertypeName(String usertypeName); // Correct the method name
|
||||
|
||||
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue