From a79327712a2ee6ac305fdf7a1301c44d40984726 Mon Sep 17 00:00:00 2001 From: "Abdulwahab K. Al Senan" Date: Tue, 8 Apr 2025 14:33:28 +0300 Subject: [PATCH 1/7] s --- .../kotlin/com/coded/spring/ordering/ApplicationController.kt | 2 ++ src/main/kotlin/com/coded/spring/ordering/UsersRepository.kt | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 src/main/kotlin/com/coded/spring/ordering/ApplicationController.kt create mode 100644 src/main/kotlin/com/coded/spring/ordering/UsersRepository.kt diff --git a/src/main/kotlin/com/coded/spring/ordering/ApplicationController.kt b/src/main/kotlin/com/coded/spring/ordering/ApplicationController.kt new file mode 100644 index 0000000..d71d30c --- /dev/null +++ b/src/main/kotlin/com/coded/spring/ordering/ApplicationController.kt @@ -0,0 +1,2 @@ +package com.coded.spring.ordering + diff --git a/src/main/kotlin/com/coded/spring/ordering/UsersRepository.kt b/src/main/kotlin/com/coded/spring/ordering/UsersRepository.kt new file mode 100644 index 0000000..d71d30c --- /dev/null +++ b/src/main/kotlin/com/coded/spring/ordering/UsersRepository.kt @@ -0,0 +1,2 @@ +package com.coded.spring.ordering + From 9e5d2a306d99c785b1f8bf5539287d91342d979e Mon Sep 17 00:00:00 2001 From: bmx311 Date: Thu, 10 Apr 2025 11:29:11 +0300 Subject: [PATCH 2/7] started from scratch (Welcome to online ordering) --- .gitattributes | 2 - .gitignore | 33 --- .mvn/wrapper/maven-wrapper.properties | 19 -- mvnw | 259 ------------------ mvnw.cmd | 149 ---------- pom.xml | 93 ------- .../com/coded/spring/ordering/Application.kt | 11 - .../spring/ordering/ApplicationController.kt | 2 - .../coded/spring/ordering/UsersRepository.kt | 2 - src/main/resources/application.properties | 1 - .../coded/spring/ordering/ApplicationTests.kt | 13 - 11 files changed, 584 deletions(-) delete mode 100644 .gitattributes delete mode 100644 .gitignore delete mode 100644 .mvn/wrapper/maven-wrapper.properties delete mode 100755 mvnw delete mode 100644 mvnw.cmd delete mode 100644 pom.xml delete mode 100644 src/main/kotlin/com/coded/spring/ordering/Application.kt delete mode 100644 src/main/kotlin/com/coded/spring/ordering/ApplicationController.kt delete mode 100644 src/main/kotlin/com/coded/spring/ordering/UsersRepository.kt delete mode 100644 src/main/resources/application.properties delete mode 100644 src/test/kotlin/com/coded/spring/ordering/ApplicationTests.kt diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 3b41682..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/mvnw text eol=lf -*.cmd text eol=crlf diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 549e00a..0000000 --- a/.gitignore +++ /dev/null @@ -1,33 +0,0 @@ -HELP.md -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index d58dfb7..0000000 --- a/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,19 +0,0 @@ -# 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 diff --git a/mvnw b/mvnw deleted file mode 100755 index 19529dd..0000000 --- a/mvnw +++ /dev/null @@ -1,259 +0,0 @@ -#!/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-,maven-mvnd--}/ -[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" -distributionUrlName="${distributionUrl##*/}" -distributionUrlNameMain="${distributionUrlName%.*}" -distributionUrlNameMain="${distributionUrlNameMain%-bin}" -MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" -MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" - -exec_maven() { - unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : - exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" -} - -if [ -d "$MAVEN_HOME" ]; then - verbose "found existing MAVEN_HOME at $MAVEN_HOME" - exec_maven "$@" -fi - -case "${distributionUrl-}" in -*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; -*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; -esac - -# prepare tmp dir -if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then - clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } - trap clean HUP INT TERM EXIT -else - die "cannot create temp dir" -fi - -mkdir -p -- "${MAVEN_HOME%/*}" - -# Download and Install Apache Maven -verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." -verbose "Downloading from: $distributionUrl" -verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" - -# select .zip or .tar.gz -if ! command -v unzip >/dev/null; then - distributionUrl="${distributionUrl%.zip}.tar.gz" - distributionUrlName="${distributionUrl##*/}" -fi - -# verbose opt -__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' -[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v - -# normalize http auth -case "${MVNW_PASSWORD:+has-password}" in -'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; -has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; -esac - -if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then - verbose "Found wget ... using wget" - wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" -elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then - verbose "Found curl ... using curl" - curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" -elif set_java_home; then - verbose "Falling back to use Java to download" - javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" - targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" - cat >"$javaSource" <<-END - public class Downloader extends java.net.Authenticator - { - protected java.net.PasswordAuthentication getPasswordAuthentication() - { - return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); - } - public static void main( String[] args ) throws Exception - { - setDefault( new Downloader() ); - java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); - } - } - END - # For Cygwin/MinGW, switch paths to Windows format before running javac and java - verbose " - Compiling Downloader.java ..." - "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" - verbose " - Running Downloader.java ..." - "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" -fi - -# If specified, validate the SHA-256 sum of the Maven distribution zip file -if [ -n "${distributionSha256Sum-}" ]; then - distributionSha256Result=false - if [ "$MVN_CMD" = mvnd.sh ]; then - echo "Checksum validation is not supported for maven-mvnd." >&2 - echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 - exit 1 - elif command -v sha256sum >/dev/null; then - if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then - distributionSha256Result=true - fi - elif command -v shasum >/dev/null; then - if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then - distributionSha256Result=true - fi - else - echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 - echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 - exit 1 - fi - if [ $distributionSha256Result = false ]; then - echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 - echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 - exit 1 - fi -fi - -# unzip and move -if command -v unzip >/dev/null; then - unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" -else - tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" -fi -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 "$@" diff --git a/mvnw.cmd b/mvnw.cmd deleted file mode 100644 index 249bdf3..0000000 --- a/mvnw.cmd +++ /dev/null @@ -1,149 +0,0 @@ -<# : 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-,maven-mvnd--}/ -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" diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 163ad53..0000000 --- a/pom.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.4.4 - - - com.coded.spring - Ordering - 0.0.1-SNAPSHOT - Kotlin.SpringbootV2 - Kotlin.SpringbootV2 - - - - - - - - - - - - - - - 21 - 1.9.25 - - - - org.springframework.boot - spring-boot-starter-web - - - com.fasterxml.jackson.module - jackson-module-kotlin - - - org.jetbrains.kotlin - kotlin-reflect - - - org.jetbrains.kotlin - kotlin-stdlib - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.jetbrains.kotlin - kotlin-test-junit5 - test - - - - - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/test/kotlin - - - org.springframework.boot - spring-boot-maven-plugin - - - org.jetbrains.kotlin - kotlin-maven-plugin - - - -Xjsr305=strict - - - spring - - - - - org.jetbrains.kotlin - kotlin-maven-allopen - ${kotlin.version} - - - - - - - diff --git a/src/main/kotlin/com/coded/spring/ordering/Application.kt b/src/main/kotlin/com/coded/spring/ordering/Application.kt deleted file mode 100644 index 8554e49..0000000 --- a/src/main/kotlin/com/coded/spring/ordering/Application.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.coded.spring.ordering - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -class Application - -fun main(args: Array) { - runApplication(*args) -} diff --git a/src/main/kotlin/com/coded/spring/ordering/ApplicationController.kt b/src/main/kotlin/com/coded/spring/ordering/ApplicationController.kt deleted file mode 100644 index d71d30c..0000000 --- a/src/main/kotlin/com/coded/spring/ordering/ApplicationController.kt +++ /dev/null @@ -1,2 +0,0 @@ -package com.coded.spring.ordering - diff --git a/src/main/kotlin/com/coded/spring/ordering/UsersRepository.kt b/src/main/kotlin/com/coded/spring/ordering/UsersRepository.kt deleted file mode 100644 index d71d30c..0000000 --- a/src/main/kotlin/com/coded/spring/ordering/UsersRepository.kt +++ /dev/null @@ -1,2 +0,0 @@ -package com.coded.spring.ordering - diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 3704dc6..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -spring.application.name=Kotlin.SpringbootV2 diff --git a/src/test/kotlin/com/coded/spring/ordering/ApplicationTests.kt b/src/test/kotlin/com/coded/spring/ordering/ApplicationTests.kt deleted file mode 100644 index b2e2320..0000000 --- a/src/test/kotlin/com/coded/spring/ordering/ApplicationTests.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.coded.spring.ordering - -import org.junit.jupiter.api.Test -import org.springframework.boot.test.context.SpringBootTest - -@SpringBootTest -class ApplicationTests { - - @Test - fun contextLoads() { - } - -} From 8fb77b91464befcd35cf37bbdb01e77d5f0bb559 Mon Sep 17 00:00:00 2001 From: bmx311 Date: Thu, 10 Apr 2025 11:30:20 +0300 Subject: [PATCH 3/7] started from scratch (Welcome to online ordering) --- .idea/.gitignore | 3 + .idea/misc.xml | 12 + .idea/vcs.xml | 6 + thisgottawork/.gitattributes | 2 + thisgottawork/.gitignore | 33 +++ .../.mvn/wrapper/maven-wrapper.properties | 19 ++ thisgottawork/mvnw | 259 ++++++++++++++++++ thisgottawork/mvnw.cmd | 149 ++++++++++ thisgottawork/pom.xml | 94 +++++++ .../thisgottawork/HelloWorldController.kt | 11 + .../thisgottawork/ThisgottaworkApplication.kt | 11 + .../src/main/resources/application.properties | 1 + .../ThisgottaworkApplicationTests.kt | 13 + 13 files changed, 613 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/vcs.xml create mode 100644 thisgottawork/.gitattributes create mode 100644 thisgottawork/.gitignore create mode 100644 thisgottawork/.mvn/wrapper/maven-wrapper.properties create mode 100644 thisgottawork/mvnw create mode 100644 thisgottawork/mvnw.cmd create mode 100644 thisgottawork/pom.xml create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/ThisgottaworkApplication.kt create mode 100644 thisgottawork/src/main/resources/application.properties create mode 100644 thisgottawork/src/test/kotlin/com/hooba/thisgottawork/ThisgottaworkApplicationTests.kt diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f24c79d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/thisgottawork/.gitattributes b/thisgottawork/.gitattributes new file mode 100644 index 0000000..3b41682 --- /dev/null +++ b/thisgottawork/.gitattributes @@ -0,0 +1,2 @@ +/mvnw text eol=lf +*.cmd text eol=crlf diff --git a/thisgottawork/.gitignore b/thisgottawork/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/thisgottawork/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/thisgottawork/.mvn/wrapper/maven-wrapper.properties b/thisgottawork/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..d58dfb7 --- /dev/null +++ b/thisgottawork/.mvn/wrapper/maven-wrapper.properties @@ -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 diff --git a/thisgottawork/mvnw b/thisgottawork/mvnw new file mode 100644 index 0000000..19529dd --- /dev/null +++ b/thisgottawork/mvnw @@ -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-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} + +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" +fi + +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac + +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" +fi + +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" +fi + +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v + +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac + +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 + fi +fi + +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" +else + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi +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 "$@" diff --git a/thisgottawork/mvnw.cmd b/thisgottawork/mvnw.cmd new file mode 100644 index 0000000..249bdf3 --- /dev/null +++ b/thisgottawork/mvnw.cmd @@ -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-,maven-mvnd--}/ +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" diff --git a/thisgottawork/pom.xml b/thisgottawork/pom.xml new file mode 100644 index 0000000..1c78639 --- /dev/null +++ b/thisgottawork/pom.xml @@ -0,0 +1,94 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.4.4 + + + com.hooba + thisgottawork + 0.0.1-SNAPSHOT + thisgottawork + Demo project for Spring Boot + + + + + + + + + + + + + + + 21 + 1.9.25 + + + + org.springframework.boot + spring-boot-starter-web + + + org.jetbrains.kotlin + kotlin-reflect + + + org.jetbrains.kotlin + kotlin-stdlib + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.jetbrains.kotlin + kotlin-test-junit5 + test + + + org.springframework + spring-web + 6.2.5 + + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + org.springframework.boot + spring-boot-maven-plugin + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + -Xjsr305=strict + + + spring + + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + + + + + diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt new file mode 100644 index 0000000..aa055ed --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt @@ -0,0 +1,11 @@ +package com.hooba.thisgottawork + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +class HelloWorldController(){ + + @GetMapping("/home") + fun helloWorld() = "Welcome to online ordering!" +} \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/ThisgottaworkApplication.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/ThisgottaworkApplication.kt new file mode 100644 index 0000000..78055b9 --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/ThisgottaworkApplication.kt @@ -0,0 +1,11 @@ +package com.hooba.thisgottawork + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +class ThisgottaworkApplication + +fun main(args: Array) { + runApplication(*args) +} diff --git a/thisgottawork/src/main/resources/application.properties b/thisgottawork/src/main/resources/application.properties new file mode 100644 index 0000000..8635501 --- /dev/null +++ b/thisgottawork/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.application.name=thisgottawork diff --git a/thisgottawork/src/test/kotlin/com/hooba/thisgottawork/ThisgottaworkApplicationTests.kt b/thisgottawork/src/test/kotlin/com/hooba/thisgottawork/ThisgottaworkApplicationTests.kt new file mode 100644 index 0000000..274778b --- /dev/null +++ b/thisgottawork/src/test/kotlin/com/hooba/thisgottawork/ThisgottaworkApplicationTests.kt @@ -0,0 +1,13 @@ +package com.hooba.thisgottawork + +import org.junit.jupiter.api.Test +import org.springframework.boot.test.context.SpringBootTest + +@SpringBootTest +class ThisgottaworkApplicationTests { + + @Test + fun contextLoads() { + } + +} From 83fb2ff849b48f2bc2af3ab852adad21121c2eeb Mon Sep 17 00:00:00 2001 From: abdulwahab alsenan Date: Thu, 10 Apr 2025 17:30:32 +0300 Subject: [PATCH 4/7] part 2 --- thisgottawork/.gitattributes | 2 + thisgottawork/.gitignore | 33 +++ .../.mvn/wrapper/maven-wrapper.properties | 19 ++ thisgottawork/mvnw | 259 ++++++++++++++++++ thisgottawork/mvnw.cmd | 149 ++++++++++ thisgottawork/pom.xml | 117 ++++++++ .../thisgottawork/HelloWorldController.kt | 28 ++ .../thisgottawork/ThisgottaworkApplication.kt | 11 + .../hooba/thisgottawork/UsersRepository.kt | 21 ++ .../src/main/resources/application.properties | 1 + .../ThisgottaworkApplicationTests.kt | 13 + 11 files changed, 653 insertions(+) create mode 100644 thisgottawork/.gitattributes create mode 100644 thisgottawork/.gitignore create mode 100644 thisgottawork/.mvn/wrapper/maven-wrapper.properties create mode 100644 thisgottawork/mvnw create mode 100644 thisgottawork/mvnw.cmd create mode 100644 thisgottawork/pom.xml create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/ThisgottaworkApplication.kt create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/UsersRepository.kt create mode 100644 thisgottawork/src/main/resources/application.properties create mode 100644 thisgottawork/src/test/kotlin/com/hooba/thisgottawork/ThisgottaworkApplicationTests.kt diff --git a/thisgottawork/.gitattributes b/thisgottawork/.gitattributes new file mode 100644 index 0000000..3b41682 --- /dev/null +++ b/thisgottawork/.gitattributes @@ -0,0 +1,2 @@ +/mvnw text eol=lf +*.cmd text eol=crlf diff --git a/thisgottawork/.gitignore b/thisgottawork/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/thisgottawork/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/thisgottawork/.mvn/wrapper/maven-wrapper.properties b/thisgottawork/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..d58dfb7 --- /dev/null +++ b/thisgottawork/.mvn/wrapper/maven-wrapper.properties @@ -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 diff --git a/thisgottawork/mvnw b/thisgottawork/mvnw new file mode 100644 index 0000000..19529dd --- /dev/null +++ b/thisgottawork/mvnw @@ -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-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} + +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" +fi + +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac + +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" +fi + +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" +fi + +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v + +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac + +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 + fi +fi + +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" +else + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi +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 "$@" diff --git a/thisgottawork/mvnw.cmd b/thisgottawork/mvnw.cmd new file mode 100644 index 0000000..249bdf3 --- /dev/null +++ b/thisgottawork/mvnw.cmd @@ -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-,maven-mvnd--}/ +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" diff --git a/thisgottawork/pom.xml b/thisgottawork/pom.xml new file mode 100644 index 0000000..1e5cfc0 --- /dev/null +++ b/thisgottawork/pom.xml @@ -0,0 +1,117 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.4.4 + + + com.hooba + thisgottawork + 0.0.1-SNAPSHOT + thisgottawork + Demo project for Spring Boot + + + + + + + + + + + + + + + 21 + 1.9.25 + + + + org.springframework.boot + spring-boot-starter-web + + + org.jetbrains.kotlin + kotlin-reflect + + + org.jetbrains.kotlin + kotlin-stdlib + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.jetbrains.kotlin + kotlin-test-junit5 + test + + + org.springframework + spring-web + 6.2.5 + + + jakarta.inject + jakarta.inject-api + 2.0.1 + + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + + + jakarta.persistence + jakarta.persistence-api + 3.2.0-M1 + + + org.springframework.data + spring-data-jpa + 3.4.4 + + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + org.springframework.boot + spring-boot-maven-plugin + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + -Xjsr305=strict + + + spring + + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + + + + + diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt new file mode 100644 index 0000000..7fdac79 --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt @@ -0,0 +1,28 @@ +package com.hooba.thisgottawork + +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.RestController + +@RestController +class HelloWorldController( + val usersRepository: UsersRepository +){ + + @GetMapping("/home") + fun helloWorld() = "Welcome to online ordering!" + + + @PostMapping("/order") + fun saveMyOrder( @RequestBody request: MyOrderRequest) = + usersRepository.save(Order(name = request.name, restaurant = request.restaurant, items = request.items)) + +} + +data class MyOrderRequest( + val id: Long?, + val name: String, + val restaurant: String, + val items: MutableList +) \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/ThisgottaworkApplication.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/ThisgottaworkApplication.kt new file mode 100644 index 0000000..78055b9 --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/ThisgottaworkApplication.kt @@ -0,0 +1,11 @@ +package com.hooba.thisgottawork + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +class ThisgottaworkApplication + +fun main(args: Array) { + runApplication(*args) +} diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/UsersRepository.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/UsersRepository.kt new file mode 100644 index 0000000..cbd3607 --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/UsersRepository.kt @@ -0,0 +1,21 @@ +package com.hooba.thisgottawork + +import jakarta.inject.Named +import jakarta.persistence.* +import org.springframework.data.jpa.repository.JpaRepository + +@Named +interface UsersRepository : JpaRepository + +@Entity +@Table(name = "orders") +data class Order( + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + val id: Long? = null, + val name: String, + val restaurant: String, + val items: MutableList +){ + constructor() : this(null, "","", mutableListOf()) +} \ No newline at end of file diff --git a/thisgottawork/src/main/resources/application.properties b/thisgottawork/src/main/resources/application.properties new file mode 100644 index 0000000..8635501 --- /dev/null +++ b/thisgottawork/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.application.name=thisgottawork diff --git a/thisgottawork/src/test/kotlin/com/hooba/thisgottawork/ThisgottaworkApplicationTests.kt b/thisgottawork/src/test/kotlin/com/hooba/thisgottawork/ThisgottaworkApplicationTests.kt new file mode 100644 index 0000000..274778b --- /dev/null +++ b/thisgottawork/src/test/kotlin/com/hooba/thisgottawork/ThisgottaworkApplicationTests.kt @@ -0,0 +1,13 @@ +package com.hooba.thisgottawork + +import org.junit.jupiter.api.Test +import org.springframework.boot.test.context.SpringBootTest + +@SpringBootTest +class ThisgottaworkApplicationTests { + + @Test + fun contextLoads() { + } + +} From b6975c47f053af30ab485e60cd8cb7c2222b9e3d Mon Sep 17 00:00:00 2001 From: abdulwahab alsenan Date: Thu, 10 Apr 2025 17:46:03 +0300 Subject: [PATCH 5/7] part 2 --- thisgottawork/pom.xml | 42 ++++++------------- .../thisgottawork/HelloWorldController.kt | 2 +- .../hooba/thisgottawork/UsersRepository.kt | 10 +++-- .../src/main/resources/application.properties | 1 + 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/thisgottawork/pom.xml b/thisgottawork/pom.xml index 1e5cfc0..eb29831 100644 --- a/thisgottawork/pom.xml +++ b/thisgottawork/pom.xml @@ -31,10 +31,18 @@ 1.9.25 + + org.springframework.boot + spring-boot-starter-data-jpa + org.springframework.boot spring-boot-starter-web + + com.fasterxml.jackson.module + jackson-module-kotlin + org.jetbrains.kotlin kotlin-reflect @@ -44,6 +52,11 @@ kotlin-stdlib + + com.h2database + h2 + runtime + org.springframework.boot spring-boot-starter-test @@ -54,36 +67,7 @@ kotlin-test-junit5 test - - org.springframework - spring-web - 6.2.5 - - - jakarta.inject - jakarta.inject-api - 2.0.1 - - - org.springframework.boot - spring-boot-starter-data-jpa - - - com.h2database - h2 - - - jakarta.persistence - jakarta.persistence-api - 3.2.0-M1 - - - org.springframework.data - spring-data-jpa - 3.4.4 - - ${project.basedir}/src/main/kotlin ${project.basedir}/src/test/kotlin diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt index 7fdac79..6c473be 100644 --- a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt @@ -16,7 +16,7 @@ class HelloWorldController( @PostMapping("/order") fun saveMyOrder( @RequestBody request: MyOrderRequest) = - usersRepository.save(Order(name = request.name, restaurant = request.restaurant, items = request.items)) + usersRepository.save(Order(name = request.name, restaurant = request.restaurant,)) } diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/UsersRepository.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/UsersRepository.kt index cbd3607..d27d615 100644 --- a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/UsersRepository.kt +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/UsersRepository.kt @@ -1,10 +1,10 @@ package com.hooba.thisgottawork -import jakarta.inject.Named import jakarta.persistence.* import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.stereotype.Repository -@Named +@Repository interface UsersRepository : JpaRepository @Entity @@ -13,9 +13,11 @@ data class Order( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val id: Long? = null, + @Column(name = "name") val name: String, + @Column(name = "restaurant") val restaurant: String, - val items: MutableList + // val items: MutableList ){ - constructor() : this(null, "","", mutableListOf()) + constructor() : this(null, "","") } \ No newline at end of file diff --git a/thisgottawork/src/main/resources/application.properties b/thisgottawork/src/main/resources/application.properties index 8635501..5d01696 100644 --- a/thisgottawork/src/main/resources/application.properties +++ b/thisgottawork/src/main/resources/application.properties @@ -1 +1,2 @@ spring.application.name=thisgottawork +server.port=8081 From 8df39b22ebe162dd6e55bb566f27c592c0c4c5c4 Mon Sep 17 00:00:00 2001 From: abdulwahab alsenan Date: Thu, 10 Apr 2025 19:32:53 +0300 Subject: [PATCH 6/7] part 2 --- thisgottawork/pom.xml | 15 ++++++-- .../thisgottawork/HelloWorldController.kt | 22 ++++++++---- .../com/hooba/thisgottawork/Repository.kt | 34 +++++++++++++++++++ .../hooba/thisgottawork/UsersRepository.kt | 23 ------------- .../thisgottawork/orders/OrdersController.kt | 14 ++++++++ .../thisgottawork/orders/OrdersService.kt | 23 +++++++++++++ .../thisgottawork/users/UsersController.kt | 14 ++++++++ .../hooba/thisgottawork/users/UsersService.kt | 23 +++++++++++++ .../src/main/resources/application.properties | 4 +++ 9 files changed, 139 insertions(+), 33 deletions(-) create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/Repository.kt delete mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/UsersRepository.kt create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersController.kt create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersService.kt create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersController.kt create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersService.kt diff --git a/thisgottawork/pom.xml b/thisgottawork/pom.xml index eb29831..95f5a6d 100644 --- a/thisgottawork/pom.xml +++ b/thisgottawork/pom.xml @@ -53,9 +53,8 @@ - com.h2database - h2 - runtime + org.postgresql + postgresql org.springframework.boot @@ -67,6 +66,16 @@ kotlin-test-junit5 test + + jakarta.platform + jakarta.jakartaee-api + 10.0.0 + + + jakarta.platform + jakarta.jakartaee-web-api + 10.0.0 + ${project.basedir}/src/main/kotlin diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt index 6c473be..f61a4bb 100644 --- a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt @@ -7,22 +7,30 @@ import org.springframework.web.bind.annotation.RestController @RestController class HelloWorldController( - val usersRepository: UsersRepository + val usersRepository: UsersRepository, + val orderRepository: OrdersRepository ){ @GetMapping("/home") fun helloWorld() = "Welcome to online ordering!" - @PostMapping("/order") - fun saveMyOrder( @RequestBody request: MyOrderRequest) = - usersRepository.save(Order(name = request.name, restaurant = request.restaurant,)) + @PostMapping("/add-name") + fun sayMyName( @RequestBody request: SayMyNameRequest) + = usersRepository.save(UserEntity(id =request.id,name = request.name, age = request.age)) + @PostMapping("/add-order") + fun sayMyOrder( @RequestBody request: SayMyOrderRequest) + = orderRepository.save(OrderEntity(id =request.id,name = request.name, age = request.age)) } -data class MyOrderRequest( +data class SayMyNameRequest( val id: Long?, val name: String, - val restaurant: String, - val items: MutableList + val age: Int +) +data class SayMyOrderRequest( + val id: Long?, + val name: String, + val age: Int ) \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/Repository.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/Repository.kt new file mode 100644 index 0000000..0118e0f --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/Repository.kt @@ -0,0 +1,34 @@ +package com.hooba.thisgottawork + +import jakarta.persistence.* +import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.stereotype.Repository + +@Repository +interface UsersRepository : JpaRepository +@Repository +interface OrdersRepository : JpaRepository + +@Entity +@Table(name = "users") +data class UserEntity( + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + var id: Long? = null, + var name: String, + var age: Int +){ + constructor() : this(null, "", 0) +} + +@Entity +@Table(name = "orders") +data class OrderEntity( + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + var id: Long? = null, + var name: String, + var age: Int +){ + constructor() : this(null, "", 0) +} \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/UsersRepository.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/UsersRepository.kt deleted file mode 100644 index d27d615..0000000 --- a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/UsersRepository.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.hooba.thisgottawork - -import jakarta.persistence.* -import org.springframework.data.jpa.repository.JpaRepository -import org.springframework.stereotype.Repository - -@Repository -interface UsersRepository : JpaRepository - -@Entity -@Table(name = "orders") -data class Order( - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - val id: Long? = null, - @Column(name = "name") - val name: String, - @Column(name = "restaurant") - val restaurant: String, - // val items: MutableList -){ - constructor() : this(null, "","") -} \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersController.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersController.kt new file mode 100644 index 0000000..43d9f83 --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersController.kt @@ -0,0 +1,14 @@ +package com.hooba.thisgottawork.users + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RestController + + +@RestController +class OrdersController( + private val ordersService: OrdersService +) { + + @GetMapping("/orders/v1/list") + fun orders() = ordersService.listOrders() +} \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersService.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersService.kt new file mode 100644 index 0000000..02e4128 --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersService.kt @@ -0,0 +1,23 @@ +package com.hooba.thisgottawork.users + + +import com.hooba.thisgottawork.OrdersRepository +import jakarta.inject.Named + +@Named +class OrdersService( + private val ordersRepository: OrdersRepository, +) { + + fun listOrders(): List = ordersRepository.findAll().map { + Order( + name = it.name, + age = it.age + ) + } +} + +data class Order( + val name: String, + val age : Int +) diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersController.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersController.kt new file mode 100644 index 0000000..a12f677 --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersController.kt @@ -0,0 +1,14 @@ +package com.hooba.thisgottawork.users + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RestController + + +@RestController +class UsersController( + private val usersService: UsersService +) { + + @GetMapping("/users/v1/list") + fun users() = usersService.listUsers() +} \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersService.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersService.kt new file mode 100644 index 0000000..d170e8a --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersService.kt @@ -0,0 +1,23 @@ +package com.hooba.thisgottawork.users + + +import com.hooba.thisgottawork.UsersRepository +import jakarta.inject.Named + +@Named +class UsersService( + private val usersRepository: UsersRepository, +) { + + fun listUsers(): List = usersRepository.findAll().map { + User( + name = it.name, + age = it.age + ) + } +} + +data class User( + val name: String, + val age : Int +) diff --git a/thisgottawork/src/main/resources/application.properties b/thisgottawork/src/main/resources/application.properties index 5d01696..a5c4325 100644 --- a/thisgottawork/src/main/resources/application.properties +++ b/thisgottawork/src/main/resources/application.properties @@ -1,2 +1,6 @@ spring.application.name=thisgottawork server.port=8081 +spring.datasource.url=jdbc:postgresql://localhost:5432/myHelloDatabase +spring.datasource.username=postgres +spring.datasource.password=password +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect \ No newline at end of file From e71ace19b88f50cab6628a176af52140a4af106e Mon Sep 17 00:00:00 2001 From: abdulwahab alsenan Date: Sun, 20 Apr 2025 18:14:59 +0300 Subject: [PATCH 7/7] part 2 --- thisgottawork/pom.xml | 18 ++++++- .../thisgottawork/HelloWorldController.kt | 27 +++++----- .../com/hooba/thisgottawork/Repository.kt | 34 ------------ .../CustomUserDetailsService.kt | 21 ++++++++ .../authentication/SecurityConfig.kt | 34 ++++++++++++ .../thisgottawork/items/ItemsRepository.kt | 28 ++++++++++ .../thisgottawork/orders/OrderRepository.kt | 31 +++++++++++ .../thisgottawork/orders/OrdersController.kt | 37 +++++++++++-- .../thisgottawork/orders/OrdersService.kt | 52 +++++++++++++------ .../thisgottawork/users/UserRepository.kt | 25 +++++++++ .../thisgottawork/users/UsersController.kt | 27 ++++++++-- .../hooba/thisgottawork/users/UsersService.kt | 37 +++++++------ .../src/main/resources/application.properties | 2 +- 13 files changed, 284 insertions(+), 89 deletions(-) delete mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/Repository.kt create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/authentication/CustomUserDetailsService.kt create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/authentication/SecurityConfig.kt create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/items/ItemsRepository.kt create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrderRepository.kt create mode 100644 thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UserRepository.kt diff --git a/thisgottawork/pom.xml b/thisgottawork/pom.xml index 95f5a6d..6fc6ec7 100644 --- a/thisgottawork/pom.xml +++ b/thisgottawork/pom.xml @@ -76,7 +76,23 @@ jakarta.jakartaee-web-api 10.0.0 - + + org.springframework.security + spring-security-crypto + 6.4.4 + + + org.testng + testng + RELEASE + compile + + + org.springframework.security + spring-security-core + 6.4.4 + + ${project.basedir}/src/main/kotlin ${project.basedir}/src/test/kotlin diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt index f61a4bb..23d7553 100644 --- a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/HelloWorldController.kt @@ -1,5 +1,7 @@ package com.hooba.thisgottawork +import com.hooba.thisgottawork.users.UserEntity +import com.hooba.thisgottawork.users.UserRepository import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody @@ -7,8 +9,7 @@ import org.springframework.web.bind.annotation.RestController @RestController class HelloWorldController( - val usersRepository: UsersRepository, - val orderRepository: OrdersRepository + val usersRepository: UserRepository, ){ @GetMapping("/home") @@ -17,20 +18,22 @@ class HelloWorldController( @PostMapping("/add-name") fun sayMyName( @RequestBody request: SayMyNameRequest) - = usersRepository.save(UserEntity(id =request.id,name = request.name, age = request.age)) + = usersRepository.save( + UserEntity( + id =request.id, + name = request.name, + age = request.age, + username = request.username, + password = request.password + ) + ) - @PostMapping("/add-order") - fun sayMyOrder( @RequestBody request: SayMyOrderRequest) - = orderRepository.save(OrderEntity(id =request.id,name = request.name, age = request.age)) } data class SayMyNameRequest( val id: Long?, val name: String, - val age: Int + val age: Int, + val username: String, + val password: String ) -data class SayMyOrderRequest( - val id: Long?, - val name: String, - val age: Int -) \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/Repository.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/Repository.kt deleted file mode 100644 index 0118e0f..0000000 --- a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/Repository.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.hooba.thisgottawork - -import jakarta.persistence.* -import org.springframework.data.jpa.repository.JpaRepository -import org.springframework.stereotype.Repository - -@Repository -interface UsersRepository : JpaRepository -@Repository -interface OrdersRepository : JpaRepository - -@Entity -@Table(name = "users") -data class UserEntity( - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - var id: Long? = null, - var name: String, - var age: Int -){ - constructor() : this(null, "", 0) -} - -@Entity -@Table(name = "orders") -data class OrderEntity( - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - var id: Long? = null, - var name: String, - var age: Int -){ - constructor() : this(null, "", 0) -} \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/authentication/CustomUserDetailsService.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/authentication/CustomUserDetailsService.kt new file mode 100644 index 0000000..559630c --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/authentication/CustomUserDetailsService.kt @@ -0,0 +1,21 @@ +package com.hooba.thisgottawork.authentication + + +import com.hooba.thisgottawork.users.UserRepository +import org.springframework.security.core.userdetails.* +import org.springframework.stereotype.Service + +@Service +class CustomUserDetailsService( + private val usersRepository: UserRepository +) : UserDetailsService { + override fun loadUserByUsername(username: String): UserDetails { + val user = usersRepository.findByUsername(username) + ?: throw UsernameNotFoundException("User not found") + + return User.builder() + .username(user.username) + .password(user.password) + .build() + } +} \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/authentication/SecurityConfig.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/authentication/SecurityConfig.kt new file mode 100644 index 0000000..0a1329d --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/authentication/SecurityConfig.kt @@ -0,0 +1,34 @@ +//package com.hooba.thisgottawork.authentication +// +//import org.springframework.context.annotation.Bean +//import org.springframework.context.annotation.Configuration +//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder +//import org.springframework.security.crypto.password.PasswordEncoder +// +//import org.springframework.security.config.annotation.web.builders.HttpSecurity +//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity +//import org.springframework.security.core.userdetails.UserDetailsService +//import org.springframework.security.web.SecurityFilterChain +// +//@Configuration +//@EnableWebSecurity +//class SecurityConfig( +// private val userDetailsService: UserDetailsService +//) { +// +// @Bean +// fun passwordEncoder(): PasswordEncoder = BCryptPasswordEncoder() +// +// @Bean +// fun securityFilterChain(http: HttpSecurity): SecurityFilterChain { +// http.csrf { it.disable() } +// .authorizeHttpRequests { +// it.requestMatchers("/public/**").permitAll() +// .anyRequest().authenticated() +// } +// .formLogin { it.defaultSuccessUrl("/hello", true) } +// .userDetailsService(userDetailsService) +// return http.build(); +// } +//} + diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/items/ItemsRepository.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/items/ItemsRepository.kt new file mode 100644 index 0000000..6263c26 --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/items/ItemsRepository.kt @@ -0,0 +1,28 @@ +package com.hooba.thisgottawork.items + +import com.fasterxml.jackson.annotation.JsonBackReference +import com.hooba.thisgottawork.orders.OrderEntity +import jakarta.inject.Named +import jakarta.persistence.* +import org.springframework.data.jpa.repository.JpaRepository + +@Named +interface ItemsRepository: JpaRepository + +@Entity +@Table(name = "items") +data class ItemsEntity( + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + var id: Long? = null, + + // maps each item to its parent order using the foreign key items.order_id → orders.id + @ManyToOne + @JoinColumn(name = "order_id") + @JsonBackReference + val order: OrderEntity, + val name: String, + val price: Double +){ + constructor() : this(null, OrderEntity(), "", 0.0) +} \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrderRepository.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrderRepository.kt new file mode 100644 index 0000000..5958041 --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrderRepository.kt @@ -0,0 +1,31 @@ +package com.hooba.thisgottawork.orders + +import com.fasterxml.jackson.annotation.JsonManagedReference +import com.hooba.thisgottawork.items.ItemsEntity +import com.hooba.thisgottawork.users.UserEntity +import jakarta.persistence.* +import org.springframework.data.jpa.repository.JpaRepository +import java.time.LocalDateTime + +interface OrderRepository: JpaRepository + +@Entity +@Table(name = "orders") + data class OrderEntity( + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + var id: Long? = null, + + @ManyToOne + @JoinColumn(name = "user_id") + var user: UserEntity, + + var restaurant: String, + + @OneToMany(mappedBy = "order", fetch = FetchType.LAZY) + @JsonManagedReference + val items: List? = null, + var timeOrdered: LocalDateTime? = null +){ + constructor() : this(null, UserEntity(), "",null,null) +} \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersController.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersController.kt index 43d9f83..a64c322 100644 --- a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersController.kt +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersController.kt @@ -1,14 +1,41 @@ -package com.hooba.thisgottawork.users +package com.hooba.thisgottawork.orders 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.RestController - @RestController class OrdersController( private val ordersService: OrdersService ) { - @GetMapping("/orders/v1/list") - fun orders() = ordersService.listOrders() -} \ No newline at end of file + @GetMapping("/orders") + fun getOrders() = ordersService.getOrders() + + @PostMapping("/orders") + fun addOrder(@RequestBody request: OrderRequest) = + ordersService.addOrder(request) +} + + + +// the DTO (Data Transfer Object) for our orders and items list +data class RequestItem( + val name: String, + val price: Double +) + +data class OrderRequest( + val userId: Long, + val restaurant: String, + val items: List +) + +data class OrderResponseDTO( + val id: Long, + val username: String, + val restaurant: String, + val items: List, + val timeOrdered: String? +) \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersService.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersService.kt index 02e4128..e67c818 100644 --- a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersService.kt +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/orders/OrdersService.kt @@ -1,23 +1,45 @@ -package com.hooba.thisgottawork.users +package com.hooba.thisgottawork.orders +import com.hooba.thisgottawork.items.ItemsEntity +import com.hooba.thisgottawork.users.UserRepository +import org.springframework.stereotype.Service -import com.hooba.thisgottawork.OrdersRepository -import jakarta.inject.Named -@Named +@Service class OrdersService( - private val ordersRepository: OrdersRepository, + private val orderRepository: OrderRepository, + private var userRepository: UserRepository ) { + fun getOrders(): List = orderRepository.findAll().filter { it.user != null }.sortedBy { it.timeOrdered } - fun listOrders(): List = ordersRepository.findAll().map { - Order( - name = it.name, - age = it.age + fun addOrder(request: OrderRequest): OrderResponseDTO { + val user = userRepository.findById(request.userId).orElseThrow { + IllegalArgumentException("User with ID ${request.userId} not found") + } + + val order = orderRepository.save( + OrderEntity( + user = user, + restaurant = request.restaurant + ) ) - } -} -data class Order( - val name: String, - val age : Int -) + val items = request.items.map { item -> + ItemsEntity( + order = order, + name = item.name, + price = item.price + ) + } + + return OrderResponseDTO( + id = order.id!!, + username = user.username, + restaurant = order.restaurant, + timeOrdered = order.timeOrdered.toString(), + items = items.map { + RequestItem(name = it.name, price = it.price) + } + ) + } +} \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UserRepository.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UserRepository.kt new file mode 100644 index 0000000..014a59a --- /dev/null +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UserRepository.kt @@ -0,0 +1,25 @@ +package com.hooba.thisgottawork.users + +import jakarta.persistence.* +import org.springframework.data.jpa.repository.JpaRepository +import jakarta.inject.Named + +@Named +interface UserRepository : JpaRepository{ + fun findByUsername(userName: String): UserEntity? + fun existsByUsername(username: String): Boolean +} + +@Entity +@Table(name = "users") +data class UserEntity( + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + val id: Long? = null, + val name: String, + val age: Int, + val username: String, + val password: String +){ + constructor() : this(null, "",0,"", "") +} \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersController.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersController.kt index a12f677..5bc12c1 100644 --- a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersController.kt +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersController.kt @@ -1,6 +1,9 @@ package com.hooba.thisgottawork.users -import org.springframework.web.bind.annotation.GetMapping +import jakarta.validation.constraints.NotBlank +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RestController @@ -9,6 +12,22 @@ class UsersController( private val usersService: UsersService ) { - @GetMapping("/users/v1/list") - fun users() = usersService.listUsers() -} \ No newline at end of file + @PostMapping("register") + fun registerUser(@RequestBody request: CreateUserRequest): ResponseEntity { + return usersService.registerUser(request) + + } +} + +data class CreateUserRequest( + @field:NotBlank(message = "Username is required") + val name: String, + + @field:NotBlank(message = "Password is required") + val age: Int, + @field:NotBlank(message = "Username is required") + val username: String, + + @field:NotBlank(message = "Password is required") + val password: String +) \ No newline at end of file diff --git a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersService.kt b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersService.kt index d170e8a..ffab2ce 100644 --- a/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersService.kt +++ b/thisgottawork/src/main/kotlin/com/hooba/thisgottawork/users/UsersService.kt @@ -1,23 +1,26 @@ package com.hooba.thisgottawork.users +import org.springframework.http.HttpStatus +import org.springframework.http.ResponseEntity +import org.springframework.security.crypto.password.PasswordEncoder +import org.springframework.stereotype.Service -import com.hooba.thisgottawork.UsersRepository -import jakarta.inject.Named - -@Named +@Service class UsersService( - private val usersRepository: UsersRepository, -) { + private val userRepository: UserRepository, +// private val passwordEncoder: PasswordEncoder +) + { + fun registerUser(request: CreateUserRequest): ResponseEntity { + if (userRepository.existsByUsername(request.username)) { + return ResponseEntity.status(HttpStatus.BAD_REQUEST) + .body(mapOf("error" to "username ${request.username} already exists")) + } - fun listUsers(): List = usersRepository.findAll().map { - User( - name = it.name, - age = it.age - ) - } -} +// val hashedPassword = passwordEncoder.encode(request.password) +// val newUser = UserEntity(name =request.name, age =request.age, username = request.username, password = hashedPassword) +// userRepository.save(newUser) -data class User( - val name: String, - val age : Int -) + return ResponseEntity.ok().build() + } +} \ No newline at end of file diff --git a/thisgottawork/src/main/resources/application.properties b/thisgottawork/src/main/resources/application.properties index a5c4325..d6c2fb5 100644 --- a/thisgottawork/src/main/resources/application.properties +++ b/thisgottawork/src/main/resources/application.properties @@ -1,6 +1,6 @@ spring.application.name=thisgottawork server.port=8081 -spring.datasource.url=jdbc:postgresql://localhost:5432/myHelloDatabase +spring.datasource.url=jdbc:postgresql://localhost:5432/postgres spring.datasource.username=postgres spring.datasource.password=password spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect \ No newline at end of file