From 58862e903837626f20399e9eb8c4ead9adfdd709 Mon Sep 17 00:00:00 2001 From: Makuu Date: Sat, 30 Aug 2025 14:41:00 +0800 Subject: [PATCH 01/11] feat: implemented springboot-activity --- galagar-springboot-api/HELP.md | 30 ++ galagar-springboot-api/mvnw | 259 ++++++++++++++++++ galagar-springboot-api/mvnw.cmd | 149 ++++++++++ galagar-springboot-api/pom.xml | 60 ++++ .../Controller/StudentController.java | 76 +++++ .../GalagarSpringbootApiApplication.java | 13 + .../galagar_springboot_api/Model/Student.java | 41 +++ .../Service/StudentServiceImpl.java | 47 ++++ .../Service/StudentServices.java | 20 ++ .../src/main/resources/application.properties | 1 + .../GalagarSpringbootApiApplicationTests.java | 13 + .../target/classes/application.properties | 1 + .../Controller/StudentController.class | Bin 0 -> 4766 bytes .../GalagarSpringbootApiApplication.class | Bin 0 -> 823 bytes .../Model/Student.class | Bin 0 -> 1233 bytes .../Service/StudentServiceImpl.class | Bin 0 -> 3116 bytes .../Service/StudentServices.class | Bin 0 -> 819 bytes .../compile/default-compile/createdFiles.lst | 1 + .../compile/default-compile/inputFiles.lst | 5 + .../default-testCompile/createdFiles.lst | 0 .../default-testCompile/inputFiles.lst | 1 + ...GalagarSpringbootApiApplicationTests.class | Bin 0 -> 621 bytes 22 files changed, 717 insertions(+) create mode 100644 galagar-springboot-api/HELP.md create mode 100644 galagar-springboot-api/mvnw create mode 100644 galagar-springboot-api/mvnw.cmd create mode 100644 galagar-springboot-api/pom.xml create mode 100644 galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Controller/StudentController.java create mode 100644 galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/GalagarSpringbootApiApplication.java create mode 100644 galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Model/Student.java create mode 100644 galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/StudentServiceImpl.java create mode 100644 galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/StudentServices.java create mode 100644 galagar-springboot-api/src/main/resources/application.properties create mode 100644 galagar-springboot-api/src/test/java/com/springboot/galagar_springboot_api/GalagarSpringbootApiApplicationTests.java create mode 100644 galagar-springboot-api/target/classes/application.properties create mode 100644 galagar-springboot-api/target/classes/com/springboot/galagar_springboot_api/Controller/StudentController.class create mode 100644 galagar-springboot-api/target/classes/com/springboot/galagar_springboot_api/GalagarSpringbootApiApplication.class create mode 100644 galagar-springboot-api/target/classes/com/springboot/galagar_springboot_api/Model/Student.class create mode 100644 galagar-springboot-api/target/classes/com/springboot/galagar_springboot_api/Service/StudentServiceImpl.class create mode 100644 galagar-springboot-api/target/classes/com/springboot/galagar_springboot_api/Service/StudentServices.class create mode 100644 galagar-springboot-api/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 galagar-springboot-api/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 galagar-springboot-api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst create mode 100644 galagar-springboot-api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst create mode 100644 galagar-springboot-api/target/test-classes/com/springboot/galagar_springboot_api/GalagarSpringbootApiApplicationTests.class diff --git a/galagar-springboot-api/HELP.md b/galagar-springboot-api/HELP.md new file mode 100644 index 0000000..4aec7fb --- /dev/null +++ b/galagar-springboot-api/HELP.md @@ -0,0 +1,30 @@ +# Read Me First +The following was discovered as part of building this project: + +* The original package name 'com.springboot.galagar-springboot-api' is invalid and this project uses 'com.springboot.galagar_springboot_api' instead. + +# Getting Started + +### Reference Documentation +For further reference, please consider the following sections: + +* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) +* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/3.5.5/maven-plugin) +* [Create an OCI image](https://docs.spring.io/spring-boot/3.5.5/maven-plugin/build-image.html) +* [Spring Web](https://docs.spring.io/spring-boot/3.5.5/reference/web/servlet.html) +* [Spring Boot DevTools](https://docs.spring.io/spring-boot/3.5.5/reference/using/devtools.html) + +### Guides +The following guides illustrate how to use some features concretely: + +* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) +* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) +* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/) + +### Maven Parent overrides + +Due to Maven's design, elements are inherited from the parent POM to the project POM. +While most of the inheritance is fine, it also inherits unwanted elements like `` and `` from the parent. +To prevent this, the project POM contains empty overrides for these elements. +If you manually switch to a different parent and actually want the inheritance, you need to remove those overrides. + diff --git a/galagar-springboot-api/mvnw b/galagar-springboot-api/mvnw new file mode 100644 index 0000000..19529dd --- /dev/null +++ b/galagar-springboot-api/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/galagar-springboot-api/mvnw.cmd b/galagar-springboot-api/mvnw.cmd new file mode 100644 index 0000000..b150b91 --- /dev/null +++ b/galagar-springboot-api/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/galagar-springboot-api/pom.xml b/galagar-springboot-api/pom.xml new file mode 100644 index 0000000..b241bda --- /dev/null +++ b/galagar-springboot-api/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.5.5 + + + com.springboot + galagar-springboot-api + 0.0.1-SNAPSHOT + galagar-springboot-api + Demo project for Spring Boot + + + + + + + + + + + + + + + 21 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Controller/StudentController.java b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Controller/StudentController.java new file mode 100644 index 0000000..24b40b8 --- /dev/null +++ b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Controller/StudentController.java @@ -0,0 +1,76 @@ +package com.springboot.galagar_springboot_api.Controller; + +import java.util.List; +import java.util.Optional; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import com.springboot.galagar_springboot_api.Model.Student; +import com.springboot.galagar_springboot_api.Service.StudentServices; + +@RestController +@RequestMapping("/api/students") +public class StudentController { + + @Autowired + private StudentServices studentService; + + @GetMapping + public List getAllStudents() { + return studentService.getAllStudent(); + } + + @GetMapping("/{id}") + public ResponseEntity getStudentById(@PathVariable long id) { + Optional studentOptional = studentService.getStudentById(id); + + if (studentOptional.isPresent()) { + return ResponseEntity.ok(studentOptional.get()); + } else { + return ResponseEntity.status(404).body("Student with ID " + id + " not found"); + } + } + + @PostMapping + public ResponseEntity addStudent(@RequestBody Student student) { + Student savedStudent = studentService.addStudent(student); + return ResponseEntity.ok(savedStudent); + } + + @PutMapping("/{id}") + public ResponseEntity updateStudent(@PathVariable long id, @RequestBody Student updatedData) { + Optional studentOptional = studentService.getStudentById(id); + + if (studentOptional.isPresent()) { + Student existingStudent = studentOptional.get(); + + if (updatedData.getName() != null && !updatedData.getName().isEmpty()) { + existingStudent.setName(updatedData.getName()); + } + + if (updatedData.getCourse() != null && !updatedData.getCourse().isEmpty()) { + existingStudent.setCourse(updatedData.getCourse()); + } + + studentService.updateStudent(id, existingStudent); + + return ResponseEntity.ok(existingStudent); + } else { + return ResponseEntity.status(404).body("Student with ID " + id + " not found"); + } + } + + @DeleteMapping("/{id}") + public ResponseEntity deleteStudent(@PathVariable long id) { + Optional studentOptional = studentService.getStudentById(id); + + if (studentOptional.isPresent()) { + studentService.deleteStudent(id); + return ResponseEntity.ok("Student with ID " + id + " has been deleted."); + } else { + return ResponseEntity.status(404).body("Student with ID " + id + " not found."); + } + } +} diff --git a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/GalagarSpringbootApiApplication.java b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/GalagarSpringbootApiApplication.java new file mode 100644 index 0000000..f75fa26 --- /dev/null +++ b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/GalagarSpringbootApiApplication.java @@ -0,0 +1,13 @@ +package com.springboot.galagar_springboot_api; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class GalagarSpringbootApiApplication { + + public static void main(String[] args) { + SpringApplication.run(GalagarSpringbootApiApplication.class, args); + } + +} diff --git a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Model/Student.java b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Model/Student.java new file mode 100644 index 0000000..59eab79 --- /dev/null +++ b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Model/Student.java @@ -0,0 +1,41 @@ +package com.springboot.galagar_springboot_api.Model; + +public class Student { + + private long pkStudentID; + private String name; + private String course; + + public Student() { + } + + public Student(long pkStudentID, String name, String course) { + this.pkStudentID = pkStudentID; + this.name = name; + this.course = course; + } + + public long getPkStudentID() { + return pkStudentID; + } + + public void setPkStudentID(long pkStudentID) { + this.pkStudentID = pkStudentID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCourse() { + return course; + } + + public void setCourse(String course) { + this.course = course; + } +} diff --git a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/StudentServiceImpl.java b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/StudentServiceImpl.java new file mode 100644 index 0000000..1635cf7 --- /dev/null +++ b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/StudentServiceImpl.java @@ -0,0 +1,47 @@ +package com.springboot.galagar_springboot_api.Service; + +import java.util.*; +import org.springframework.stereotype.Service; +import com.springboot.galagar_springboot_api.Model.Student; + +@Service +public class StudentServiceImpl implements StudentServices { + + private Map studentDB = new HashMap<>(); + private long idCounter = 1; + + @Override + public List getAllStudent() { + return new ArrayList<>(studentDB.values()); + } + + @Override + public Optional getStudentById(long id) { + return Optional.ofNullable(studentDB.get(id)); + } + + @Override + public Student addStudent(Student student) { + if (student.getPkStudentID() == 0) { + student.setPkStudentID(idCounter++); + } + studentDB.put(student.getPkStudentID(), student); + return student; + } + + @Override + public Student updateStudent(long id, Student student) { + if (studentDB.containsKey(id)) { + student.setPkStudentID(id); // keep ID consistent + studentDB.put(id, student); + return student; + } else { + throw new RuntimeException("Student with ID " + id + " not found."); + } + } + + @Override + public boolean deleteStudent(long id) { + return studentDB.remove(id) != null; + } +} diff --git a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/StudentServices.java b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/StudentServices.java new file mode 100644 index 0000000..a48917d --- /dev/null +++ b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/StudentServices.java @@ -0,0 +1,20 @@ +package com.springboot.galagar_springboot_api.Service; + +import java.util.List; +import java.util.Optional; + +import com.springboot.galagar_springboot_api.Model.Student; + +public interface StudentServices { + + public List getAllStudent(); + + public Optional getStudentById(long id); + + public Student addStudent(Student student); + + public Student updateStudent(long id, Student student); + + public boolean deleteStudent(long id); + +} diff --git a/galagar-springboot-api/src/main/resources/application.properties b/galagar-springboot-api/src/main/resources/application.properties new file mode 100644 index 0000000..72566de --- /dev/null +++ b/galagar-springboot-api/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.application.name=galagar-springboot-api diff --git a/galagar-springboot-api/src/test/java/com/springboot/galagar_springboot_api/GalagarSpringbootApiApplicationTests.java b/galagar-springboot-api/src/test/java/com/springboot/galagar_springboot_api/GalagarSpringbootApiApplicationTests.java new file mode 100644 index 0000000..bc74c61 --- /dev/null +++ b/galagar-springboot-api/src/test/java/com/springboot/galagar_springboot_api/GalagarSpringbootApiApplicationTests.java @@ -0,0 +1,13 @@ +package com.springboot.galagar_springboot_api; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class GalagarSpringbootApiApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/galagar-springboot-api/target/classes/application.properties b/galagar-springboot-api/target/classes/application.properties new file mode 100644 index 0000000..72566de --- /dev/null +++ b/galagar-springboot-api/target/classes/application.properties @@ -0,0 +1 @@ +spring.application.name=galagar-springboot-api diff --git a/galagar-springboot-api/target/classes/com/springboot/galagar_springboot_api/Controller/StudentController.class b/galagar-springboot-api/target/classes/com/springboot/galagar_springboot_api/Controller/StudentController.class new file mode 100644 index 0000000000000000000000000000000000000000..d839f54da309fa59f26d49a6c86206d43a58db1e GIT binary patch literal 4766 zcmcInYjfMi6+KIlqC`QDD7F&CvCSk-EGdrAD7IsnepC(>c2_^+F z04POG)Aap*H*K2!fqqSAI&PE?oqp|`_|uy^m?z4zR+cQ5|_ z?~nfiU=HtRkrJ5SaJEga=34e<$#HyhQsbni7q_hij77aZGnooZFN=9*tGE8A~M zvPcVzJdiumtV(;+yjgmnHhh60FVtL9?vAyg1TGgl+bmkp*eM!%1%dI^y6s!r>bB)s zrK*~&+=^LJ()P^za>IArJyXUD%(=Sn>{_lW(`@er z%eMSW0zDIxw*}G*PFdy9gFyrR$O#M=EnD5FZ2V}X`&$+r zS?n;(CW4Jfn-V%Tw5j~LYBhqJc1I^Bivh}Y->RBL%k!z#zh-UP(yzO8YUzN&g$`X= zX28{k7lli-d%7)}yQ*ZCEW4Zp@|yCOWvxa675X9Yq=5{22k;c0&fP3rZgUz9a*gto;qf?Xp_PVG=K9 zF-2M&oHcL?FOeITx8f>~hc#gK9lgdh@EN?!F%cCw)L=~F;1;rYMc|dr($+$p9M0g? zEY1p?Y zZdJ?5EsU~4UN-Pq%rOJovZ8o0H>AIA`CELWdE2M?!*Ol`pVxd{MVY+?T*+dQ7IRc^F*tjPHe#uEy*mqrCwEknHiPwAS^6rbk({{RmEljqqw=S{M|h!h ze!;HPV@~8SgL?+vfF#(g;5T^bJX*!0GL*vxR2HlsiPkKfGjLyD4_V8*vR(7{w9zdC z79QvfHjExlmgC6g*rqc}BlG+O@O)R+!gB8A@LhaAi|+}X2)c~mp0n&7r=r*`>gz7N7_Wx?wZ1Wb zAn>~+bt3K1;A_$@SCx07=s1;nt&q6zBZeg;Eemh)B5R|5H=!SXb`+v+De38gWE*Yy zsxaJ(@ATov0!N}evf`BB5s07oXDg3rvM$}8d=GBC^bivtV2F?DzhdSioc{1J@!m%`fBa)y0`@VV3j9e2QH}=7 zkI?UNu> zU>#owJj>vVd`mTaS?4mrVthCD0&Z%FY|YX9};JnoU?>*7WYtq!o>if(~OsH#{lg{$<(qs0qUWpN|4qxZC%3- zWtlj^;ariy>jV#@=U+I-1ZOcb{tt3S=ea)>|v2z#_90-Ju0x5;#g6(LGA{h(P93R5S6co|iWpmkZw|m;#1O8U3 zAPRl}KMFB>j<5?$G!!>;J2U&{&D;6)`^QfJ6FlysCGaw}g{(@aO_o^eWkxw=>PG^eT>uj>@A zgHNsT>YJBSYtD35yP(5L9}b6f7=m2Js_d>o=Er!g{JA}SM}f9ijtiritzD{K>7et$ zKVI}{&_!VXeQmrh)Ld6O@G!>u=EWKBXf6Fl9jd+MIU4>-F0^{V>$Nh+7*D`*@hSo> z{^NaM+vSsFFW7fRSLj_f>4{{4w>;pVxAKE?w{s2vY;nn~E literal 0 HcmV?d00001 diff --git a/galagar-springboot-api/target/classes/com/springboot/galagar_springboot_api/Model/Student.class b/galagar-springboot-api/target/classes/com/springboot/galagar_springboot_api/Model/Student.class new file mode 100644 index 0000000000000000000000000000000000000000..6e06160fc5c6dfab54bb70b7a99991c2f5a05ddd GIT binary patch literal 1233 zcmbVKUvJWI6g@xw!wSp|7;`F{Q&%wBhs7t&5;J2WVRH!!uSKjdO(zS+O5;29%8}qAa^vz+<_}sp+I-bJD=u3$B^g%(@6=FkkU@2@h z=HR9$v)(EsI?lu$^J(IpJ+!?Og{WR_@tsr7${>oIh72|o@(p`volgdB%e^$)eV@-ANYtDR~q4TYkHI1*CrXhsj8#Vm5TjbaLaRc1*8J0!hNp{oo3EbyWfZd@%qN_0{J>ktW4ym~Wcs zyE@Zkvtxa2*H4(;yjB&P^(N)sJ)t^RNIYBQJxc)e2_-MENOH6 zK>lU%U7z%36qf$T}NLOtMV#uds(lyowrwsscN=D12ih!Z`@p zw%1yDj3=R$6Izj33E#$Cdl1GBRh4~)67j+rgdtU+SG2{IZ&aaz{h6k_h;LE)PRydF zy|tPS@N}jr5=^VTWU9-WDjc?dk0#l=^7Eo5$x7jHt)}v_ro*+Go~_rku;U=7BWlv` Q(Ih*ZX$p4t+z;f%Kk}Kly#N3J literal 0 HcmV?d00001 diff --git a/galagar-springboot-api/target/classes/com/springboot/galagar_springboot_api/Service/StudentServiceImpl.class b/galagar-springboot-api/target/classes/com/springboot/galagar_springboot_api/Service/StudentServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..cc8c48ae63a1a5e5e6f8fbc8161f2721b9d5d072 GIT binary patch literal 3116 zcmbtWTXz#x6#h<9I&?aPwzRZGqyY=2H=vDXlJ6U0Inqb7r5t_xJ7F{Pp*%-vCVDdkqPJ%LTWb z@hhI?lvZ6g$dsflOVYbn-?}F&R%XfcHm!o0SqiE}(+T3oT)ARvXcB0@FE?ezmQE?N zuzKGt1R9zJF8&|gzCeo~S(}~|IGhhnR0GS-%*jfYZ0?G8?vOv=mPv}UZ!$2DjX*eR# zQFnAk`s;L7M<+U3AaK-xhJ$L=YoHZ|f@L}8e6_r4dN<{&O(>mtw;=6h=~?PI-fRli zEfO;MmN@=BT7=YAGJ^@*jw4Bf>A?o}@|GV^D7R~K{4H(2$)Sdm0!QkcOn9E$QdU~= z9!_f*phxw$WXr%AyicY#rCl`%x_5^wQ?6|@zbx0u>PTTw@jfKbmu|q&AftkGh=60X zlUuo>Ku>zM5%NMssgpKg&+q+azu0wT@S%ne=tBsxmXHQM!Z`sg#JI3Vf@+3qGFe5? zc>^Eg6Q&z62%L#gHWXSmM$)*Y;ZuQg`$%~mSzOdG&ZMY^WSbrXm+-lO?yk*OZ97WV z^uIe4R_gXyQk$^IeEXakth>cU>B+LmqGEV;SuECa(N6Cx%Ley#O2-9UF>n=ML^-m! z5&Myw4(oeX3FHjS;u-~fGuR=}#E31c5X~8w#{y4OstnPEJs4@|Mp1X%D`?CHKWcXZ z=l6w&g|rmN!Uk(7ZX0dYN>K)8joxy4c3+zJ$FCx1*}yG)CD2-Moj_WSf6d$y=-z{* z!P^>c3mmH#$_@5it889*STMs1?c~_{+Q40W!xApb4RgwM3NpB51?yb-fph}qQ}@nF zS_;%?W3O1jx2jjjH>}6+Ri9{M^Jh}l*isR`tw5Lt)>IKTduG|)WRKRD+^SbFuUe{M z_rwPpX5v`|f=ww#ux$Ajd-;UpxPer?hHj?wu2+f&@0zNH2d=k~@mUk58*EiLX`_kD z%4whEVD@@7`ICzte?je4sL4J>fk5x=b4k0Trvxl2u9|So$9y6JGz>ubL z(UBj-4#H)TuTH+>D80;hMu-wTk2hXN=5Ta>|#(BmYhbCUl9NbtvT z&2tQ}!3*~|Cq338HdX3JN=jeLMNBt>!ehrWI@!E+dUJvrB z^H?joxIV@mgKBsf@8CG^0`KAk4MisVLj&2^K*wvOR)(IS`z1~ZJV*L54yF#5uX@~N$PPMumIzGYO z1N@5Qjh`o&qL`wjN^I)D$nY~vxBU1EI){f=o}lNhF3HI=%qYX^9c>T4L_UdI!^&_n z1QRjUN0*PGm#hqt69p`CVx;E82o`ajc5j3yMK3>ULvI#&6IjB{*qa~7x#E7T4)@Ch zen#JDf9#6lU^Mb$^zmz~tn|Oa9gyOCzlXXN#YdSEz$vt|BXnbcztieVCG;#6(m7W1 zY%HdSHbWni+diHNeQZgDj75H~q7eIeeRo)j3H*rzO^=d~YJNna9&KP`cUWRZI=30Q k%+pOM@tVLoEZ&ut`@C=PuTuOw{yhYI(z&YQ0k+Wh4{?t+RsaA1 literal 0 HcmV?d00001 diff --git a/galagar-springboot-api/target/classes/com/springboot/galagar_springboot_api/Service/StudentServices.class b/galagar-springboot-api/target/classes/com/springboot/galagar_springboot_api/Service/StudentServices.class new file mode 100644 index 0000000000000000000000000000000000000000..e6b16cad9c0f319393983ddde7f0fa342936c076 GIT binary patch literal 819 zcmbVK!A` z!SuE>Z+7SHd-M7A{sCZ!o(+rP-j7yp8Ye0Y7Exr}fNLJ`WPYUPJXWqJleO}t>zPc* z&=fGWQDJB=`I@_$hk-j=ETwN4nt?P!tqV0n$LUYDs>~?uPE=|J40TThAvakf8AiVZ zca#5hHjRYT`@RMb^lppH3+KnpNHFxA@lX3%Y*Z9-P15JTE9Jc{MSkt6G;fi3;R#Zonz@SM9C!nO4@ literal 0 HcmV?d00001 diff --git a/galagar-springboot-api/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/galagar-springboot-api/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..63f8980 --- /dev/null +++ b/galagar-springboot-api/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1 @@ +com\springboot\galagar_springboot_api\Service\StudentServices.class diff --git a/galagar-springboot-api/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/galagar-springboot-api/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..7f79332 --- /dev/null +++ b/galagar-springboot-api/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,5 @@ +C:\Users\John\Downloads\galagar-springboot-api\galagar-springboot-api\src\main\java\com\springboot\galagar_springboot_api\Controller\StudentController.java +C:\Users\John\Downloads\galagar-springboot-api\galagar-springboot-api\src\main\java\com\springboot\galagar_springboot_api\GalagarSpringbootApiApplication.java +C:\Users\John\Downloads\galagar-springboot-api\galagar-springboot-api\src\main\java\com\springboot\galagar_springboot_api\Model\Student.java +C:\Users\John\Downloads\galagar-springboot-api\galagar-springboot-api\src\main\java\com\springboot\galagar_springboot_api\Service\StudentServiceImpl.java +C:\Users\John\Downloads\galagar-springboot-api\galagar-springboot-api\src\main\java\com\springboot\galagar_springboot_api\Service\StudentServices.java diff --git a/galagar-springboot-api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/galagar-springboot-api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/galagar-springboot-api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/galagar-springboot-api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..cd9dced --- /dev/null +++ b/galagar-springboot-api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +C:\Users\John\Downloads\galagar-springboot-api\galagar-springboot-api\src\test\java\com\springboot\galagar_springboot_api\GalagarSpringbootApiApplicationTests.java diff --git a/galagar-springboot-api/target/test-classes/com/springboot/galagar_springboot_api/GalagarSpringbootApiApplicationTests.class b/galagar-springboot-api/target/test-classes/com/springboot/galagar_springboot_api/GalagarSpringbootApiApplicationTests.class new file mode 100644 index 0000000000000000000000000000000000000000..ab0a0baa062fd92b6e65c9e127bdcbdec9a2cd5d GIT binary patch literal 621 zcmb_Z%Sr<=6g`<%t8KNlx)EHsv zsa}?)Di%%|J&?J}Yp61`C*o1?ROp1?L=zc1hUF8bl{;mq>~)6>)pIkJbyTq0#1fVn zTA|YNdNz%u9f&BE44u%#A{`2=d_FH$-Mz{g!tnooe9X{{jdt?cg+`2tefxH%otny_ z$`w7`)7rRVLh9{=#wL6+qhZKq%1O(;Hhy?ws`t&z#_~e>3A%p~?9gk)a8&S?g5Oy& zl~2Y#@M0T|sQLVdycGY8wp6@`U67=-N+6&^Qc_-{h?8f&vj2*em!e%K>)RkegKV<| qkYA$=Sf_4)7DXP_Chv(3==eMAH%a3M2}xLx1lS;GfX;$u6ZiroxuHn_ literal 0 HcmV?d00001 From e4294ab96eb2aec39aa14c13bc143e00f3d5abfc Mon Sep 17 00:00:00 2001 From: Makuu Date: Sat, 30 Aug 2025 18:42:49 +0800 Subject: [PATCH 02/11] update: mvn wrapper --- .../.mvn/wrapper/maven-wrapper.properties | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 galagar-springboot-api/.mvn/wrapper/maven-wrapper.properties diff --git a/galagar-springboot-api/.mvn/wrapper/maven-wrapper.properties b/galagar-springboot-api/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..12fbe1e --- /dev/null +++ b/galagar-springboot-api/.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.11/apache-maven-3.9.11-bin.zip From 3b3cff8b5f04d3971ac74ed0b01f3aa9b3dac84a Mon Sep 17 00:00:00 2001 From: Makuu Date: Sat, 30 Aug 2025 18:45:29 +0800 Subject: [PATCH 03/11] update: pom.xml --- galagar-springboot-api/pom.xml | 116 +++++++++++++++++---------------- 1 file changed, 59 insertions(+), 57 deletions(-) diff --git a/galagar-springboot-api/pom.xml b/galagar-springboot-api/pom.xml index b241bda..d174460 100644 --- a/galagar-springboot-api/pom.xml +++ b/galagar-springboot-api/pom.xml @@ -1,60 +1,62 @@ - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.5.5 - - - com.springboot - galagar-springboot-api - 0.0.1-SNAPSHOT - galagar-springboot-api - Demo project for Spring Boot - - - - - - - - - - - - - - - 21 - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-devtools - runtime - true - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.5.5 + + + + com.example + demo + 0.0.1-SNAPSHOT + demo + Demo project for Spring Boot + + + 17 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.10.1 + + ${java.version} + ${java.version} + + + + + org.springframework.boot + spring-boot-maven-plugin + + + From d9e6e0baa562e7ee2665c1400bdf6d624af03cef Mon Sep 17 00:00:00 2001 From: Makuu Date: Sat, 30 Aug 2025 19:16:38 +0800 Subject: [PATCH 04/11] update: added impl folder --- .../impl/StudentServiceImpl.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 galagar-springboot-api/impl/StudentServiceImpl.java diff --git a/galagar-springboot-api/impl/StudentServiceImpl.java b/galagar-springboot-api/impl/StudentServiceImpl.java new file mode 100644 index 0000000..6e3467d --- /dev/null +++ b/galagar-springboot-api/impl/StudentServiceImpl.java @@ -0,0 +1,47 @@ +package com.springboot.galagar_springboot_api.Service; + +import java.util.*; +import org.springframework.stereotype.Service; +import com.springboot.galagar_springboot_api.Model.Student; + +@Service +public class StudentServiceImpl implements StudentServices { + + private Map studentDB = new HashMap<>(); + private long idCounter = 1; + + @Override + public List getAllStudent() { + return new ArrayList<>(studentDB.values()); + } + + @Override + public Optional getStudentById(long id) { + return Optional.ofNullable(studentDB.get(id)); + } + + @Override + public Student addStudent(Student student) { + if (student.getPkStudentID() == 0) { + student.setPkStudentID(idCounter++); + } + studentDB.put(student.getPkStudentID(), student); + return student; + } + + @Override + public Student updateStudent(long id, Student student) { + if (studentDB.containsKey(id)) { + student.setPkStudentID(id); // keep ID consistent + studentDB.put(id, student); + return student; + } else { + throw new RuntimeException("Student with ID " + id + " not found."); + } + } + + @Override + public boolean deleteStudent(long id) { + return studentDB.remove(id) != null; + } +} From 86ea9ea68db478982775747e9dbf3b5a4e6e275c Mon Sep 17 00:00:00 2001 From: Makuu Date: Sat, 30 Aug 2025 19:17:06 +0800 Subject: [PATCH 05/11] delete: galagar-springboot-api/impl directory --- .../impl/StudentServiceImpl.java | 47 ------------------- 1 file changed, 47 deletions(-) delete mode 100644 galagar-springboot-api/impl/StudentServiceImpl.java diff --git a/galagar-springboot-api/impl/StudentServiceImpl.java b/galagar-springboot-api/impl/StudentServiceImpl.java deleted file mode 100644 index 6e3467d..0000000 --- a/galagar-springboot-api/impl/StudentServiceImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.springboot.galagar_springboot_api.Service; - -import java.util.*; -import org.springframework.stereotype.Service; -import com.springboot.galagar_springboot_api.Model.Student; - -@Service -public class StudentServiceImpl implements StudentServices { - - private Map studentDB = new HashMap<>(); - private long idCounter = 1; - - @Override - public List getAllStudent() { - return new ArrayList<>(studentDB.values()); - } - - @Override - public Optional getStudentById(long id) { - return Optional.ofNullable(studentDB.get(id)); - } - - @Override - public Student addStudent(Student student) { - if (student.getPkStudentID() == 0) { - student.setPkStudentID(idCounter++); - } - studentDB.put(student.getPkStudentID(), student); - return student; - } - - @Override - public Student updateStudent(long id, Student student) { - if (studentDB.containsKey(id)) { - student.setPkStudentID(id); // keep ID consistent - studentDB.put(id, student); - return student; - } else { - throw new RuntimeException("Student with ID " + id + " not found."); - } - } - - @Override - public boolean deleteStudent(long id) { - return studentDB.remove(id) != null; - } -} From 57419aac69fbba84af6c34d4df8afadb6607c2b2 Mon Sep 17 00:00:00 2001 From: Makuu Date: Sat, 30 Aug 2025 19:17:44 +0800 Subject: [PATCH 06/11] update: added impl folder --- .../Service/impl/StudentServiceImpl.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/impl/StudentServiceImpl.java diff --git a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/impl/StudentServiceImpl.java b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/impl/StudentServiceImpl.java new file mode 100644 index 0000000..6e3467d --- /dev/null +++ b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/impl/StudentServiceImpl.java @@ -0,0 +1,47 @@ +package com.springboot.galagar_springboot_api.Service; + +import java.util.*; +import org.springframework.stereotype.Service; +import com.springboot.galagar_springboot_api.Model.Student; + +@Service +public class StudentServiceImpl implements StudentServices { + + private Map studentDB = new HashMap<>(); + private long idCounter = 1; + + @Override + public List getAllStudent() { + return new ArrayList<>(studentDB.values()); + } + + @Override + public Optional getStudentById(long id) { + return Optional.ofNullable(studentDB.get(id)); + } + + @Override + public Student addStudent(Student student) { + if (student.getPkStudentID() == 0) { + student.setPkStudentID(idCounter++); + } + studentDB.put(student.getPkStudentID(), student); + return student; + } + + @Override + public Student updateStudent(long id, Student student) { + if (studentDB.containsKey(id)) { + student.setPkStudentID(id); // keep ID consistent + studentDB.put(id, student); + return student; + } else { + throw new RuntimeException("Student with ID " + id + " not found."); + } + } + + @Override + public boolean deleteStudent(long id) { + return studentDB.remove(id) != null; + } +} From 5dbd6673fe1a18a046222814c145173b947929cd Mon Sep 17 00:00:00 2001 From: Makuu Date: Sat, 30 Aug 2025 19:18:07 +0800 Subject: [PATCH 07/11] delete: StudentServiceImpl.java --- .../Service/StudentServiceImpl.java | 47 ------------------- 1 file changed, 47 deletions(-) delete mode 100644 galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/StudentServiceImpl.java diff --git a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/StudentServiceImpl.java b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/StudentServiceImpl.java deleted file mode 100644 index 1635cf7..0000000 --- a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/StudentServiceImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.springboot.galagar_springboot_api.Service; - -import java.util.*; -import org.springframework.stereotype.Service; -import com.springboot.galagar_springboot_api.Model.Student; - -@Service -public class StudentServiceImpl implements StudentServices { - - private Map studentDB = new HashMap<>(); - private long idCounter = 1; - - @Override - public List getAllStudent() { - return new ArrayList<>(studentDB.values()); - } - - @Override - public Optional getStudentById(long id) { - return Optional.ofNullable(studentDB.get(id)); - } - - @Override - public Student addStudent(Student student) { - if (student.getPkStudentID() == 0) { - student.setPkStudentID(idCounter++); - } - studentDB.put(student.getPkStudentID(), student); - return student; - } - - @Override - public Student updateStudent(long id, Student student) { - if (studentDB.containsKey(id)) { - student.setPkStudentID(id); // keep ID consistent - studentDB.put(id, student); - return student; - } else { - throw new RuntimeException("Student with ID " + id + " not found."); - } - } - - @Override - public boolean deleteStudent(long id) { - return studentDB.remove(id) != null; - } -} From 0f24ba740645fa4f9211116563f06f6edc985f0c Mon Sep 17 00:00:00 2001 From: Makuu Date: Sat, 30 Aug 2025 19:19:24 +0800 Subject: [PATCH 08/11] fix: student bug --- .../galagar_springboot_api/Controller/StudentController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Controller/StudentController.java b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Controller/StudentController.java index 24b40b8..53c56c3 100644 --- a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Controller/StudentController.java +++ b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Controller/StudentController.java @@ -35,8 +35,7 @@ public ResponseEntity getStudentById(@PathVariable long id) { @PostMapping public ResponseEntity addStudent(@RequestBody Student student) { - Student savedStudent = studentService.addStudent(student); - return ResponseEntity.ok(savedStudent); + return ResponseEntity.ok(student); } @PutMapping("/{id}") @@ -74,3 +73,4 @@ public ResponseEntity deleteStudent(@PathVariable long id) { } } } + From 4071b4fa7da134814d7d40a6bbef598c91d7ceda Mon Sep 17 00:00:00 2001 From: Makuu Date: Sat, 30 Aug 2025 19:24:04 +0800 Subject: [PATCH 09/11] fix: StudentServiceImpl file package --- .../galagar_springboot_api/Service/impl/StudentServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/impl/StudentServiceImpl.java b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/impl/StudentServiceImpl.java index 6e3467d..7ed6be0 100644 --- a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/impl/StudentServiceImpl.java +++ b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/impl/StudentServiceImpl.java @@ -1,4 +1,4 @@ -package com.springboot.galagar_springboot_api.Service; +package com.springboot.galagar_springboot_api.Service.impl; import java.util.*; import org.springframework.stereotype.Service; From 17ef65d41a77f3d03af167dc71500ed28449f114 Mon Sep 17 00:00:00 2001 From: Makuu Date: Sat, 30 Aug 2025 19:28:42 +0800 Subject: [PATCH 10/11] fix: StudentServiceImpl import error --- .../galagar_springboot_api/Service/impl/StudentServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/impl/StudentServiceImpl.java b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/impl/StudentServiceImpl.java index 7ed6be0..285f0b7 100644 --- a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/impl/StudentServiceImpl.java +++ b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Service/impl/StudentServiceImpl.java @@ -3,6 +3,7 @@ import java.util.*; import org.springframework.stereotype.Service; import com.springboot.galagar_springboot_api.Model.Student; +import com.springboot.galagar_springboot_api.Service.StudentServices; @Service public class StudentServiceImpl implements StudentServices { From b0ceb7a833075661555b564b07114d32e4b56fbb Mon Sep 17 00:00:00 2001 From: Makuu Date: Sat, 30 Aug 2025 19:50:18 +0800 Subject: [PATCH 11/11] fix: StudentController Bug --- .../galagar_springboot_api/Controller/StudentController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Controller/StudentController.java b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Controller/StudentController.java index 53c56c3..6904104 100644 --- a/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Controller/StudentController.java +++ b/galagar-springboot-api/src/main/java/com/springboot/galagar_springboot_api/Controller/StudentController.java @@ -35,8 +35,9 @@ public ResponseEntity getStudentById(@PathVariable long id) { @PostMapping public ResponseEntity addStudent(@RequestBody Student student) { - return ResponseEntity.ok(student); + return ResponseEntity.ok(studentService.addStudent(student)); } + @PutMapping("/{id}") public ResponseEntity updateStudent(@PathVariable long id, @RequestBody Student updatedData) { @@ -74,3 +75,4 @@ public ResponseEntity deleteStudent(@PathVariable long id) { } } +