diff --git a/.ai/mcp/mcp.json b/.ai/mcp/mcp.json
new file mode 100644
index 00000000..e69de29b
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 00000000..94dd499c
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 00000000..712ab9d9
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..5bdfd22d
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 00000000..72f32147
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,138 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SpringBootHomeWork/.DS_Store b/SpringBootHomeWork/.DS_Store
new file mode 100644
index 00000000..9a874b57
Binary files /dev/null and b/SpringBootHomeWork/.DS_Store differ
diff --git a/SpringBootHomeWork/.gitattributes b/SpringBootHomeWork/.gitattributes
new file mode 100644
index 00000000..3b41682a
--- /dev/null
+++ b/SpringBootHomeWork/.gitattributes
@@ -0,0 +1,2 @@
+/mvnw text eol=lf
+*.cmd text eol=crlf
diff --git a/SpringBootHomeWork/.gitignore b/SpringBootHomeWork/.gitignore
new file mode 100644
index 00000000..d8817778
--- /dev/null
+++ b/SpringBootHomeWork/.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/SpringBootHomeWork/.mvn/wrapper/maven-wrapper.properties b/SpringBootHomeWork/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 00000000..8dea6c22
--- /dev/null
+++ b/SpringBootHomeWork/.mvn/wrapper/maven-wrapper.properties
@@ -0,0 +1,3 @@
+wrapperVersion=3.3.4
+distributionType=only-script
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip
diff --git a/SpringBootHomeWork/mvnw b/SpringBootHomeWork/mvnw
new file mode 100755
index 00000000..bd8896bf
--- /dev/null
+++ b/SpringBootHomeWork/mvnw
@@ -0,0 +1,295 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Apache Maven Wrapper startup batch script, version 3.3.4
+#
+# Optional ENV vars
+# -----------------
+# JAVA_HOME - location of a JDK home dir, required when download maven via java source
+# MVNW_REPOURL - repo url base for downloading maven distribution
+# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
+# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
+# ----------------------------------------------------------------------------
+
+set -euf
+[ "${MVNW_VERBOSE-}" != debug ] || set -x
+
+# OS specific support.
+native_path() { printf %s\\n "$1"; }
+case "$(uname)" in
+CYGWIN* | MINGW*)
+ [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
+ native_path() { cygpath --path --windows "$1"; }
+ ;;
+esac
+
+# set JAVACMD and JAVACCMD
+set_java_home() {
+ # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
+ if [ -n "${JAVA_HOME-}" ]; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ]; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ JAVACCMD="$JAVA_HOME/jre/sh/javac"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ JAVACCMD="$JAVA_HOME/bin/javac"
+
+ if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
+ echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
+ echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
+ return 1
+ fi
+ fi
+ else
+ JAVACMD="$(
+ 'set' +e
+ 'unset' -f command 2>/dev/null
+ 'command' -v java
+ )" || :
+ JAVACCMD="$(
+ 'set' +e
+ 'unset' -f command 2>/dev/null
+ 'command' -v javac
+ )" || :
+
+ if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
+ echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
+ return 1
+ fi
+ fi
+}
+
+# hash string like Java String::hashCode
+hash_string() {
+ str="${1:-}" h=0
+ while [ -n "$str" ]; do
+ char="${str%"${str#?}"}"
+ h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
+ str="${str#?}"
+ done
+ printf %x\\n $h
+}
+
+verbose() { :; }
+[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
+
+die() {
+ printf %s\\n "$1" >&2
+ exit 1
+}
+
+trim() {
+ # MWRAPPER-139:
+ # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
+ # Needed for removing poorly interpreted newline sequences when running in more
+ # exotic environments such as mingw bash on Windows.
+ printf "%s" "${1}" | tr -d '[:space:]'
+}
+
+scriptDir="$(dirname "$0")"
+scriptName="$(basename "$0")"
+
+# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
+while IFS="=" read -r key value; do
+ case "${key-}" in
+ distributionUrl) distributionUrl=$(trim "${value-}") ;;
+ distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
+ esac
+done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
+[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
+
+case "${distributionUrl##*/}" in
+maven-mvnd-*bin.*)
+ MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
+ case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
+ *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
+ :Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
+ :Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
+ :Linux*x86_64*) distributionPlatform=linux-amd64 ;;
+ *)
+ echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
+ distributionPlatform=linux-amd64
+ ;;
+ esac
+ distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
+ ;;
+maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
+*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
+esac
+
+# apply MVNW_REPOURL and calculate MAVEN_HOME
+# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/
+[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
+distributionUrlName="${distributionUrl##*/}"
+distributionUrlNameMain="${distributionUrlName%.*}"
+distributionUrlNameMain="${distributionUrlNameMain%-bin}"
+MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
+MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
+
+exec_maven() {
+ unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
+ exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
+}
+
+if [ -d "$MAVEN_HOME" ]; then
+ verbose "found existing MAVEN_HOME at $MAVEN_HOME"
+ exec_maven "$@"
+fi
+
+case "${distributionUrl-}" in
+*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
+*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
+esac
+
+# prepare tmp dir
+if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
+ clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
+ trap clean HUP INT TERM EXIT
+else
+ die "cannot create temp dir"
+fi
+
+mkdir -p -- "${MAVEN_HOME%/*}"
+
+# Download and Install Apache Maven
+verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
+verbose "Downloading from: $distributionUrl"
+verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
+
+# select .zip or .tar.gz
+if ! command -v unzip >/dev/null; then
+ distributionUrl="${distributionUrl%.zip}.tar.gz"
+ distributionUrlName="${distributionUrl##*/}"
+fi
+
+# verbose opt
+__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
+[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
+
+# normalize http auth
+case "${MVNW_PASSWORD:+has-password}" in
+'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
+has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
+esac
+
+if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
+ verbose "Found wget ... using wget"
+ wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
+elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
+ verbose "Found curl ... using curl"
+ curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
+elif set_java_home; then
+ verbose "Falling back to use Java to download"
+ javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
+ targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
+ cat >"$javaSource" <<-END
+ public class Downloader extends java.net.Authenticator
+ {
+ protected java.net.PasswordAuthentication getPasswordAuthentication()
+ {
+ return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
+ }
+ public static void main( String[] args ) throws Exception
+ {
+ setDefault( new Downloader() );
+ java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
+ }
+ }
+ END
+ # For Cygwin/MinGW, switch paths to Windows format before running javac and java
+ verbose " - Compiling Downloader.java ..."
+ "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
+ verbose " - Running Downloader.java ..."
+ "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
+fi
+
+# If specified, validate the SHA-256 sum of the Maven distribution zip file
+if [ -n "${distributionSha256Sum-}" ]; then
+ distributionSha256Result=false
+ if [ "$MVN_CMD" = mvnd.sh ]; then
+ echo "Checksum validation is not supported for maven-mvnd." >&2
+ echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
+ exit 1
+ elif command -v sha256sum >/dev/null; then
+ if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
+ distributionSha256Result=true
+ fi
+ elif command -v shasum >/dev/null; then
+ if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
+ distributionSha256Result=true
+ fi
+ else
+ echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
+ echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
+ exit 1
+ fi
+ if [ $distributionSha256Result = false ]; then
+ echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
+ echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
+ exit 1
+ fi
+fi
+
+# unzip and move
+if command -v unzip >/dev/null; then
+ unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
+else
+ tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
+fi
+
+# Find the actual extracted directory name (handles snapshots where filename != directory name)
+actualDistributionDir=""
+
+# First try the expected directory name (for regular distributions)
+if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
+ if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
+ actualDistributionDir="$distributionUrlNameMain"
+ fi
+fi
+
+# If not found, search for any directory with the Maven executable (for snapshots)
+if [ -z "$actualDistributionDir" ]; then
+ # enable globbing to iterate over items
+ set +f
+ for dir in "$TMP_DOWNLOAD_DIR"/*; do
+ if [ -d "$dir" ]; then
+ if [ -f "$dir/bin/$MVN_CMD" ]; then
+ actualDistributionDir="$(basename "$dir")"
+ break
+ fi
+ fi
+ done
+ set -f
+fi
+
+if [ -z "$actualDistributionDir" ]; then
+ verbose "Contents of $TMP_DOWNLOAD_DIR:"
+ verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
+ die "Could not find Maven distribution directory in extracted archive"
+fi
+
+verbose "Found extracted Maven distribution directory: $actualDistributionDir"
+printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
+mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
+
+clean || :
+exec_maven "$@"
diff --git a/SpringBootHomeWork/mvnw.cmd b/SpringBootHomeWork/mvnw.cmd
new file mode 100644
index 00000000..92450f93
--- /dev/null
+++ b/SpringBootHomeWork/mvnw.cmd
@@ -0,0 +1,189 @@
+<# : batch portion
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Apache Maven Wrapper startup batch script, version 3.3.4
+@REM
+@REM Optional ENV vars
+@REM MVNW_REPOURL - repo url base for downloading maven distribution
+@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
+@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
+@REM ----------------------------------------------------------------------------
+
+@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
+@SET __MVNW_CMD__=
+@SET __MVNW_ERROR__=
+@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
+@SET PSModulePath=
+@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
+ IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
+)
+@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
+@SET __MVNW_PSMODULEP_SAVE=
+@SET __MVNW_ARG0_NAME__=
+@SET MVNW_USERNAME=
+@SET MVNW_PASSWORD=
+@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*)
+@echo Cannot start maven from wrapper >&2 && exit /b 1
+@GOTO :EOF
+: end batch / begin powershell #>
+
+$ErrorActionPreference = "Stop"
+if ($env:MVNW_VERBOSE -eq "true") {
+ $VerbosePreference = "Continue"
+}
+
+# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
+$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
+if (!$distributionUrl) {
+ Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
+}
+
+switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
+ "maven-mvnd-*" {
+ $USE_MVND = $true
+ $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
+ $MVN_CMD = "mvnd.cmd"
+ break
+ }
+ default {
+ $USE_MVND = $false
+ $MVN_CMD = $script -replace '^mvnw','mvn'
+ break
+ }
+}
+
+# apply MVNW_REPOURL and calculate MAVEN_HOME
+# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/
+if ($env:MVNW_REPOURL) {
+ $MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" }
+ $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
+}
+$distributionUrlName = $distributionUrl -replace '^.*/',''
+$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
+
+$MAVEN_M2_PATH = "$HOME/.m2"
+if ($env:MAVEN_USER_HOME) {
+ $MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
+}
+
+if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
+ New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
+}
+
+$MAVEN_WRAPPER_DISTS = $null
+if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) {
+ $MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
+} else {
+ $MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
+}
+
+$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
+$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
+$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
+
+if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
+ Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
+ Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
+ exit $?
+}
+
+if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
+ Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
+}
+
+# prepare tmp dir
+$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
+$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
+$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
+trap {
+ if ($TMP_DOWNLOAD_DIR.Exists) {
+ try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
+ catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
+ }
+}
+
+New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
+
+# Download and Install Apache Maven
+Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
+Write-Verbose "Downloading from: $distributionUrl"
+Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
+
+$webclient = New-Object System.Net.WebClient
+if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
+ $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
+}
+[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
+$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
+
+# If specified, validate the SHA-256 sum of the Maven distribution zip file
+$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
+if ($distributionSha256Sum) {
+ if ($USE_MVND) {
+ Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
+ }
+ Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
+ if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
+ Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
+ }
+}
+
+# unzip and move
+Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
+
+# Find the actual extracted directory name (handles snapshots where filename != directory name)
+$actualDistributionDir = ""
+
+# First try the expected directory name (for regular distributions)
+$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain"
+$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD"
+if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) {
+ $actualDistributionDir = $distributionUrlNameMain
+}
+
+# If not found, search for any directory with the Maven executable (for snapshots)
+if (!$actualDistributionDir) {
+ Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object {
+ $testPath = Join-Path $_.FullName "bin/$MVN_CMD"
+ if (Test-Path -Path $testPath -PathType Leaf) {
+ $actualDistributionDir = $_.Name
+ }
+ }
+}
+
+if (!$actualDistributionDir) {
+ Write-Error "Could not find Maven distribution directory in extracted archive"
+}
+
+Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir"
+Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null
+try {
+ Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
+} catch {
+ if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
+ Write-Error "fail to move MAVEN_HOME"
+ }
+} finally {
+ try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
+ catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
+}
+
+Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
diff --git a/SpringBootHomeWork/pom.xml b/SpringBootHomeWork/pom.xml
new file mode 100644
index 00000000..83467f7c
--- /dev/null
+++ b/SpringBootHomeWork/pom.xml
@@ -0,0 +1,90 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 4.0.3
+
+
+ org.example
+ SpringBootHomeWork
+ 0.0.1-SNAPSHOT
+ SpringBootHomeWork
+ SpringBootHomeWork
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 17
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+
+
+
diff --git a/SpringBootHomeWork/src/.DS_Store b/SpringBootHomeWork/src/.DS_Store
new file mode 100644
index 00000000..7b0d3672
Binary files /dev/null and b/SpringBootHomeWork/src/.DS_Store differ
diff --git a/SpringBootHomeWork/src/main/.DS_Store b/SpringBootHomeWork/src/main/.DS_Store
new file mode 100644
index 00000000..55c1fcbe
Binary files /dev/null and b/SpringBootHomeWork/src/main/.DS_Store differ
diff --git a/SpringBootHomeWork/src/main/java/.DS_Store b/SpringBootHomeWork/src/main/java/.DS_Store
new file mode 100644
index 00000000..e6dc460b
Binary files /dev/null and b/SpringBootHomeWork/src/main/java/.DS_Store differ
diff --git a/SpringBootHomeWork/src/main/java/org/.DS_Store b/SpringBootHomeWork/src/main/java/org/.DS_Store
new file mode 100644
index 00000000..57a55533
Binary files /dev/null and b/SpringBootHomeWork/src/main/java/org/.DS_Store differ
diff --git a/SpringBootHomeWork/src/main/java/org/example/.DS_Store b/SpringBootHomeWork/src/main/java/org/example/.DS_Store
new file mode 100644
index 00000000..b699686e
Binary files /dev/null and b/SpringBootHomeWork/src/main/java/org/example/.DS_Store differ
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/.DS_Store b/SpringBootHomeWork/src/main/java/org/example/springboothomework/.DS_Store
new file mode 100644
index 00000000..4a3b5d22
Binary files /dev/null and b/SpringBootHomeWork/src/main/java/org/example/springboothomework/.DS_Store differ
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/SpringBootHomeWorkApplication.java b/SpringBootHomeWork/src/main/java/org/example/springboothomework/SpringBootHomeWorkApplication.java
new file mode 100644
index 00000000..25880aef
--- /dev/null
+++ b/SpringBootHomeWork/src/main/java/org/example/springboothomework/SpringBootHomeWorkApplication.java
@@ -0,0 +1,13 @@
+package org.example.springboothomework;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpringBootHomeWorkApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringBootHomeWorkApplication.class, args);
+ }
+
+}
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/controller/CourseController.java b/SpringBootHomeWork/src/main/java/org/example/springboothomework/controller/CourseController.java
new file mode 100644
index 00000000..bed01602
--- /dev/null
+++ b/SpringBootHomeWork/src/main/java/org/example/springboothomework/controller/CourseController.java
@@ -0,0 +1,74 @@
+package org.example.springboothomework.controller;
+
+import jakarta.validation.Valid;
+import lombok.RequiredArgsConstructor;
+import org.example.springboothomework.model.Course;
+import org.example.springboothomework.service.CourseService;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/api/courses")
+public class CourseController {
+
+ private final CourseService courseService;
+
+ public CourseController(CourseService courseService) {
+ this.courseService = courseService;
+ }
+
+ @PostMapping
+ public ResponseEntity createCourse(@Valid @RequestBody Course course) {
+ Course addedCourse = courseService.addCourse(course);
+ return ResponseEntity.status(HttpStatus.CREATED)
+ .body(course);
+ }
+
+ @GetMapping
+ public ResponseEntity> getAllCourses() {
+ return ResponseEntity.ok(courseService.getAllCourses());
+ }
+
+ @GetMapping("/{courseId}")
+ public ResponseEntity getCourseById(@PathVariable String courseId) {
+ return ResponseEntity.ok(courseService.getCourseById(courseId));
+ }
+
+ @PutMapping("/{courseId}")
+ public ResponseEntity updateCourse(@PathVariable String courseId,
+ @Valid @RequestBody Course course) {
+ Course updatedCourse = courseService.updateCourse(courseId, course);
+ return ResponseEntity.ok(updatedCourse);
+ }
+
+ @DeleteMapping("/{courseId}")
+ public ResponseEntity deleteCourse(@PathVariable String courseId) {
+ courseService.deleteCourse(courseId);
+ return ResponseEntity.noContent().build();
+ }
+
+ @PutMapping("/{courseId}/teacher")
+ public ResponseEntity assignTeacher(@PathVariable String courseId,
+ @RequestBody String teacher) {
+ courseService.assignTeacher(courseId, teacher);
+ return ResponseEntity.ok("Teacher assigned successfully");
+ }
+
+ @PutMapping("/{courseId}/student")
+ public ResponseEntity assignStudent(@PathVariable String courseId,
+ @RequestBody String student) {
+ courseService.assignStudent(courseId, student);
+ return ResponseEntity.ok("Student assigned successfully");
+ }
+
+ @PostMapping("/{courseId}/enroll/{studentId}")
+ public ResponseEntity enrollStudent(@PathVariable String courseId,
+ @PathVariable String studentId) {
+ courseService.enrollStudent(studentId, courseId);
+ return ResponseEntity.status(HttpStatus.CREATED)
+ .body("Student enrolled successfully");
+ }
+}
\ No newline at end of file
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/controller/SchoolController.java b/SpringBootHomeWork/src/main/java/org/example/springboothomework/controller/SchoolController.java
new file mode 100644
index 00000000..d7b1a92b
--- /dev/null
+++ b/SpringBootHomeWork/src/main/java/org/example/springboothomework/controller/SchoolController.java
@@ -0,0 +1,33 @@
+package org.example.springboothomework.controller;
+
+import lombok.RequiredArgsConstructor;
+import org.example.springboothomework.service.SchoolService;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/api/school")
+public class SchoolController {
+ private final SchoolService schoolService;
+
+ public SchoolController(SchoolService schoolService) {
+ this.schoolService = schoolService;
+ }
+
+ @GetMapping("/profit")
+ public ResponseEntity showProfit() {
+ return ResponseEntity.ok(schoolService.showProfit());
+ }
+
+ @GetMapping("/moneyEarn")
+ public ResponseEntity showMoneyEarn() {
+ return ResponseEntity.ok(schoolService.showMoneyEarned());
+ }
+
+ @GetMapping("/moneySpent")
+ public ResponseEntity showMoneySpent() {
+ return ResponseEntity.ok(schoolService.showMoneySpent());
+ }
+}
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/controller/StudentController.java b/SpringBootHomeWork/src/main/java/org/example/springboothomework/controller/StudentController.java
new file mode 100644
index 00000000..3ebbe4c2
--- /dev/null
+++ b/SpringBootHomeWork/src/main/java/org/example/springboothomework/controller/StudentController.java
@@ -0,0 +1,48 @@
+package org.example.springboothomework.controller;
+
+import jakarta.validation.Valid;
+import org.example.springboothomework.model.Student;
+import org.example.springboothomework.service.StudentService;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/api/students")
+public class StudentController {
+
+ private final StudentService studentService;
+
+ public StudentController(StudentService studentService) {
+ this.studentService = studentService;
+ }
+
+ @PostMapping
+ public ResponseEntity createStudent(@Valid @RequestBody Student student) {
+ Student createdStudent = studentService.createStudent(student);
+ return ResponseEntity.status(HttpStatus.CREATED).body(createdStudent);
+ }
+
+ @GetMapping
+ public ResponseEntity> getAllStudents() {
+ return ResponseEntity.ok(studentService.getAllStudents());
+ }
+
+ @GetMapping("/{id}")
+ public ResponseEntity getStudentById(@PathVariable String id) {
+ return ResponseEntity.ok(studentService.getStudentById(id));
+ }
+
+ @PutMapping("/{id}")
+ public ResponseEntity updateStudent(@PathVariable String id,
+ @Valid @RequestBody Student student) {
+ return ResponseEntity.ok(studentService.updateStudent(id, student));
+ }
+
+ @GetMapping("/course/{courseId}")
+ public ResponseEntity> getStudentsByCourse(@PathVariable String courseId) {
+ return ResponseEntity.ok(studentService.getStudentsByCourseId(courseId));
+ }
+}
\ No newline at end of file
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/controller/TeacherController.java b/SpringBootHomeWork/src/main/java/org/example/springboothomework/controller/TeacherController.java
new file mode 100644
index 00000000..3eabe725
--- /dev/null
+++ b/SpringBootHomeWork/src/main/java/org/example/springboothomework/controller/TeacherController.java
@@ -0,0 +1,47 @@
+package org.example.springboothomework.controller;
+
+import jakarta.validation.Valid;
+import lombok.RequiredArgsConstructor;
+import org.example.springboothomework.model.Teacher;
+import org.example.springboothomework.service.TeacherService;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("/api/teachers")
+public class TeacherController {
+ private final TeacherService teacherService;
+
+ public TeacherController(TeacherService teacherService) {
+ this.teacherService = teacherService;
+ }
+
+ @PostMapping
+ public ResponseEntity createTeacher(@Valid @RequestBody Teacher teacher) {
+ Teacher createdTeacher = teacherService.createTeacher(teacher);
+ return ResponseEntity.status(HttpStatus.CREATED).body(createdTeacher);
+ }
+
+ @GetMapping
+ public ResponseEntity> getAllTeachers() {
+ return ResponseEntity.ok(teacherService.getAllTeachers());
+ }
+
+ @GetMapping("/{teacherId}")
+ public ResponseEntity getTeacherById(@PathVariable String teacherId) {
+ return ResponseEntity.ok(teacherService.getTeacherById(teacherId));
+ }
+
+ @PutMapping("/{teacherId}")
+ public ResponseEntity updateTeacher(@PathVariable String teacherId,
+ @Valid @RequestBody Teacher teacher) {
+ return ResponseEntity.ok(teacherService.updateTeacher(teacherId, teacher));
+ }
+
+ @DeleteMapping("/{teacherId}")
+ public ResponseEntity deleteTeacher(@PathVariable String teacherId) {
+ teacherService.deleteTeacher(teacherId);
+ return ResponseEntity.noContent().build();
+ }
+}
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/exceptions/GlobalHandlerException.java b/SpringBootHomeWork/src/main/java/org/example/springboothomework/exceptions/GlobalHandlerException.java
new file mode 100644
index 00000000..ba749aa4
--- /dev/null
+++ b/SpringBootHomeWork/src/main/java/org/example/springboothomework/exceptions/GlobalHandlerException.java
@@ -0,0 +1,41 @@
+package org.example.springboothomework.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@RestControllerAdvice
+public class GlobalHandlerException {
+
+ @ExceptionHandler(NotFoundException.class)
+ @ResponseStatus(HttpStatus.NOT_FOUND)
+ public Map handleProductNotFound(NotFoundException ex) {
+ Map error = new HashMap<>();
+ error.put("error", ex.getMessage());
+ return error;
+ }
+
+ @ExceptionHandler(MethodArgumentNotValidException.class)
+ @ResponseStatus(HttpStatus.BAD_REQUEST)
+ public Map handleValidationException(MethodArgumentNotValidException ex) {
+ Map errors = new HashMap<>();
+
+ ex.getBindingResult().getFieldErrors()
+ .forEach(err -> errors.put(err.getField(), err.getDefaultMessage()));
+
+ return errors;
+ }
+
+ @ExceptionHandler(Exception.class)
+ @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
+ public Map handleGeneralException(Exception ex) {
+ Map error = new HashMap<>();
+ error.put("error", "Internal Server Error");
+ return error;
+ }
+}
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/exceptions/NotFoundException.java b/SpringBootHomeWork/src/main/java/org/example/springboothomework/exceptions/NotFoundException.java
new file mode 100644
index 00000000..b1dcc1bb
--- /dev/null
+++ b/SpringBootHomeWork/src/main/java/org/example/springboothomework/exceptions/NotFoundException.java
@@ -0,0 +1,7 @@
+package org.example.springboothomework.exceptions;
+
+public class NotFoundException extends RuntimeException {
+ public NotFoundException(String message) {
+ super(message);
+ }
+}
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/model/Course.java b/SpringBootHomeWork/src/main/java/org/example/springboothomework/model/Course.java
new file mode 100644
index 00000000..e7ee33bd
--- /dev/null
+++ b/SpringBootHomeWork/src/main/java/org/example/springboothomework/model/Course.java
@@ -0,0 +1,90 @@
+package org.example.springboothomework.model;
+
+import jakarta.validation.constraints.*;
+
+public class Course {
+ private static int counter = 1;
+ private String courseId;
+
+ @NotBlank(message = "Course name cannot be empty")
+ @Size(min = 3, max = 100, message = "Course name must be between 3 and 100 characters")
+ private String name;
+
+ @Min(value = 0, message = "Price cannot be negative")
+ private Double price;
+
+ @Min(value = 0, message = "Money earned cannot be negative")
+ private Double money_earned;
+
+// @NotNull(message = "Teacher must be provided if assigning")
+ private String teacherId;
+
+// @NotNull(message = "Student must be provided if assigning")
+ private String studentId;
+
+
+ public Course(String name, double price) {
+ this.courseId = String.valueOf(counter++);
+ this.name = name;
+ this.price = price;
+ }
+
+ public Course() {
+ }
+
+ public static int getCounter() {
+ return counter;
+ }
+
+ public static void setCounter(int counter) {
+ Course.counter = counter;
+ }
+
+ public String getCourseId() {
+ return courseId;
+ }
+
+ public void setCourseId(String courseId) {
+ this.courseId = courseId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Double getPrice() {
+ return price;
+ }
+
+ public void setPrice(Double price) {
+ this.price = price;
+ }
+
+ public Double getMoney_earned() {
+ return money_earned;
+ }
+
+ public void setMoney_earned(Double money_earned) {
+ this.money_earned = money_earned;
+ }
+
+ public String getTeacherId() {
+ return teacherId;
+ }
+
+ public void setTeacherId(String teacherId) {
+ this.teacherId = teacherId;
+ }
+
+ public String getStudentId() {
+ return studentId;
+ }
+
+ public void setStudentId(String studentId) {
+ this.studentId = studentId;
+ }
+}
\ No newline at end of file
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/model/Student.java b/SpringBootHomeWork/src/main/java/org/example/springboothomework/model/Student.java
new file mode 100644
index 00000000..5ae40da1
--- /dev/null
+++ b/SpringBootHomeWork/src/main/java/org/example/springboothomework/model/Student.java
@@ -0,0 +1,75 @@
+package org.example.springboothomework.model;
+
+import jakarta.validation.constraints.Email;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Size;
+
+public class Student {
+ private static int counter = 1;
+
+ private String studentId;
+
+ @NotBlank(message = "Name cannot be empty")
+ @Size(min = 2, max = 50, message = "Name must be between 2 and 50 characters")
+ private String name;
+
+ @NotBlank(message = "Address cannot be empty")
+ @Size(min = 5, max = 100, message = "Address must be between 5 and 100 characters")
+ private String address;
+
+ @NotBlank(message = "Email cannot be empty")
+ @Email(message = "Email should be valid")
+ private String email;
+
+ private String courseId;
+
+ public Student(String name, String address, String email) {
+ this.studentId = String.valueOf(counter++);
+ this.name = name;
+ this.address = address;
+ this.email = email;
+ }
+
+ public Student() {
+ }
+
+ public String getStudentId() {
+ return studentId;
+ }
+
+ public void setStudentId(String studentId) {
+ this.studentId = studentId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getCourseId() {
+ return courseId;
+ }
+
+ public void setCourseId(String courseId) {
+ this.courseId = courseId;
+ }
+}
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/model/Teacher.java b/SpringBootHomeWork/src/main/java/org/example/springboothomework/model/Teacher.java
new file mode 100644
index 00000000..81101c63
--- /dev/null
+++ b/SpringBootHomeWork/src/main/java/org/example/springboothomework/model/Teacher.java
@@ -0,0 +1,46 @@
+package org.example.springboothomework.model;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Positive;
+
+import java.util.UUID;
+
+public class Teacher {
+ private static int counter = 1;
+
+ private String teacherId;
+
+ @NotBlank(message = "Name cannot be blank")
+ private String name;
+
+ @Positive(message = "Salary must be greater than 0")
+ private Double salary;
+
+ public Teacher(String name, double salary) {
+ this.teacherId = String.valueOf(counter++);
+ this.name = name;
+ this.salary = salary;
+ }
+
+ public Teacher() {
+ }
+
+ public String getTeacherId() {
+ return teacherId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Double getSalary() {
+ return salary;
+ }
+
+ public void setName(@NotBlank(message = "Name cannot be blank") String name) {
+ this.name = name;
+ }
+
+ public void setSalary(@Positive(message = "Salary must be greater than 0") Double salary) {
+ this.salary = salary;
+ }
+}
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/service/CourseService.java b/SpringBootHomeWork/src/main/java/org/example/springboothomework/service/CourseService.java
new file mode 100644
index 00000000..b1815739
--- /dev/null
+++ b/SpringBootHomeWork/src/main/java/org/example/springboothomework/service/CourseService.java
@@ -0,0 +1,109 @@
+package org.example.springboothomework.service;
+
+import lombok.RequiredArgsConstructor;
+import org.example.springboothomework.exceptions.NotFoundException;
+import org.example.springboothomework.model.Course;
+import org.example.springboothomework.model.Student;
+import org.example.springboothomework.model.Teacher;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+@Service
+public class CourseService {
+
+ private final StudentService studentService;
+ private final TeacherService teacherService;
+ private final Map courseRepo = new HashMap<>();
+
+ public CourseService(@Lazy StudentService studentService, TeacherService teacherService) {
+ this.studentService = studentService;
+ this.teacherService = teacherService;
+ }
+
+ public Course addCourse(Course course) {
+ courseRepo.put(course.getCourseId(), course);
+ return course;
+ }
+
+ public List getAllCourses() {
+ return new ArrayList<>(courseRepo.values());
+ }
+
+ public Course getCourseById(String id) {
+ Course course = courseRepo.get(id);
+ if (course == null) {
+ throw new NotFoundException("Course not found by id: " + id);
+ }
+ return course;
+ }
+
+
+ public Course updateCourse(String id, Course course) {
+ if (course == null) {
+ throw new RuntimeException("Course is null");
+ }
+
+ Course courseModel = getCourseById(id);
+ Teacher teacher = teacherService.getTeacherById(courseModel.getTeacherId());
+ Student student = studentService.getStudentById(course.getStudentId());
+
+ if (course.getName() != null) courseModel.setName(course.getName());
+ if (course.getTeacherId() != null) courseModel.setTeacherId(course.getTeacherId());
+ if (course.getStudentId() != null) courseModel.setStudentId(course.getStudentId());
+ if (course.getPrice() != null) courseModel.setPrice(course.getPrice());
+ if (course.getMoney_earned() != null) courseModel.setMoney_earned(course.getMoney_earned());
+
+ courseRepo.put(id, courseModel);
+
+ return course;
+ }
+
+
+ public void deleteCourse(String courseId) {
+ if (!courseRepo.containsKey(courseId)) {
+ throw new NotFoundException("Course not found");
+ }
+ courseRepo.remove(courseId);
+ }
+
+
+ public void assignTeacher(String courseId, String teacher) {
+ Course course = courseRepo.get(courseId);
+ if (course == null)
+ throw new RuntimeException("Course not found");
+
+ course.setTeacherId(teacher);
+ }
+
+ public void assignStudent(String courseId, String student) {
+ Course course = courseRepo.get(courseId);
+ if (course == null) {
+ throw new RuntimeException("Course not found");
+ }
+ course.setStudentId(student);
+ }
+
+ public void enrollStudent(String studentId, String courseId) {
+
+ Student student = studentService.getStudentById(studentId);
+
+ Course course = courseRepo.get(courseId);
+ if (course == null) {
+ throw new NotFoundException("Course not found with ID: " + courseId);
+ }
+
+ if (course.getStudentId() == null || !course.getStudentId().equals(student.getStudentId())) {
+ course.setStudentId(studentId);
+ course.setMoney_earned(course.getMoney_earned() + course.getPrice());
+ }
+ }
+
+ public double getTotalMoneyEarned() {
+ return courseRepo.values()
+ .stream()
+ .mapToDouble(Course::getMoney_earned)
+ .sum();
+ }
+}
\ No newline at end of file
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/service/SchoolService.java b/SpringBootHomeWork/src/main/java/org/example/springboothomework/service/SchoolService.java
new file mode 100644
index 00000000..4442f0fb
--- /dev/null
+++ b/SpringBootHomeWork/src/main/java/org/example/springboothomework/service/SchoolService.java
@@ -0,0 +1,29 @@
+package org.example.springboothomework.service;
+
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+@Service
+@RequiredArgsConstructor
+public class SchoolService {
+
+ private final CourseService courseService;
+ private final TeacherService teacherService;
+
+ public double showProfit() {
+ double moneyEarned = courseService.getTotalMoneyEarned();
+ double moneySpent = teacherService.getTotalSalary();
+
+ return moneyEarned - moneySpent;
+ }
+
+ public double showMoneyEarned() {
+ double moneyEarned = courseService.getTotalMoneyEarned();
+ return moneyEarned;
+ }
+
+ public double showMoneySpent() {
+ double moneySpent = teacherService.getTotalSalary();
+ return moneySpent;
+ }
+}
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/service/StudentService.java b/SpringBootHomeWork/src/main/java/org/example/springboothomework/service/StudentService.java
new file mode 100644
index 00000000..69c0047d
--- /dev/null
+++ b/SpringBootHomeWork/src/main/java/org/example/springboothomework/service/StudentService.java
@@ -0,0 +1,77 @@
+package org.example.springboothomework.service;
+
+import lombok.RequiredArgsConstructor;
+import org.example.springboothomework.exceptions.NotFoundException;
+import org.example.springboothomework.model.Course;
+import org.example.springboothomework.model.Student;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Service
+public class StudentService {
+
+ private final Map students = new HashMap<>();
+ private final CourseService courseService;
+
+ public StudentService(@Lazy CourseService courseService) {
+ this.courseService = courseService;
+ }
+
+ public Student createStudent(Student student) {
+ students.put(student.getStudentId(), student);
+ return student;
+ }
+
+ public List getAllStudents() {
+ return new ArrayList<>(students.values());
+ }
+
+ public Student getStudentById(String studentId) {
+ Student student = students.get(studentId);
+ if (student == null) {
+ throw new NotFoundException("Student not found");
+ }
+ return students.get(studentId);
+ }
+
+ public Student updateStudent(String id, Student student) {
+
+ if (student == null) {
+ throw new RuntimeException("Student is null");
+ }
+
+ Student studentModel = getStudentById(id);
+
+ if (student.getName() != null) {
+ studentModel.setName(student.getName());
+ }
+
+ if (student.getCourseId() != null) {
+ studentModel.setCourseId(student.getCourseId());
+ }
+ if (student.getEmail() != null) {
+ studentModel.setEmail(student.getEmail());
+ }
+
+ if (student.getAddress() != null) {
+ studentModel.setAddress(student.getAddress());
+ }
+
+ students.put(id, studentModel);
+
+ return studentModel;
+ }
+
+ public List getStudentsByCourseId(String courseId) {
+ courseService.getCourseById(courseId);
+
+ return students.values()
+ .stream()
+ .filter(s -> s.getCourseId() != null &&
+ s.getCourseId().equals(courseId))
+ .collect(Collectors.toList());
+ }
+}
diff --git a/SpringBootHomeWork/src/main/java/org/example/springboothomework/service/TeacherService.java b/SpringBootHomeWork/src/main/java/org/example/springboothomework/service/TeacherService.java
new file mode 100644
index 00000000..df6c17a7
--- /dev/null
+++ b/SpringBootHomeWork/src/main/java/org/example/springboothomework/service/TeacherService.java
@@ -0,0 +1,67 @@
+package org.example.springboothomework.service;
+
+import lombok.RequiredArgsConstructor;
+import org.example.springboothomework.exceptions.NotFoundException;
+import org.example.springboothomework.model.Teacher;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+@Service
+public class TeacherService {
+
+ private final Map teachers = new HashMap<>();
+
+ public Teacher createTeacher(Teacher teacher) {
+ teachers.put(teacher.getTeacherId(), teacher);
+ return teacher;
+ }
+
+ public List getAllTeachers() {
+ return new ArrayList<>(teachers.values());
+ }
+
+ public Teacher getTeacherById(String teacherId) {
+ Teacher teacher = teachers.get(teacherId);
+ if (teacher == null) {
+ throw new NotFoundException("Teacher not found");
+ }
+ return teacher;
+ }
+
+ public Teacher updateTeacher(String teacherId, Teacher updatedTeacher) {
+
+ if (updatedTeacher == null) {
+ throw new RuntimeException("Teacher is null");
+ }
+
+ if (!teachers.containsKey(teacherId)) {
+ throw new NotFoundException("Teacher not found");
+ }
+
+ Teacher teacher = getTeacherById(teacherId);
+
+ if (updatedTeacher.getName() != null) {
+ teacher.setName(updatedTeacher.getName());
+ }
+
+ if (updatedTeacher.getSalary() != null) {
+ teacher.setSalary(updatedTeacher.getSalary());
+ }
+
+ teachers.put(teacherId, teacher);
+
+ return teacher;
+ }
+
+ public void deleteTeacher(String teacherId) {
+ if (!teachers.containsKey(teacherId)) {
+ throw new NotFoundException("Teacher not found");
+ }
+ teachers.remove(teacherId);
+ }
+
+ public double getTotalSalary() {
+ return teachers.values().stream().mapToDouble(Teacher::getSalary).sum();
+ }
+}
diff --git a/SpringBootHomeWork/src/main/resources/application.properties b/SpringBootHomeWork/src/main/resources/application.properties
new file mode 100644
index 00000000..96447a37
--- /dev/null
+++ b/SpringBootHomeWork/src/main/resources/application.properties
@@ -0,0 +1 @@
+spring.application.name=SpringBootHomeWork
diff --git a/SpringBootHomeWork/src/test/java/org/example/springboothomework/CourseControllerTest.java b/SpringBootHomeWork/src/test/java/org/example/springboothomework/CourseControllerTest.java
new file mode 100644
index 00000000..04c6000d
--- /dev/null
+++ b/SpringBootHomeWork/src/test/java/org/example/springboothomework/CourseControllerTest.java
@@ -0,0 +1,140 @@
+package org.example.springboothomework;
+
+import org.example.springboothomework.controller.CourseController;
+import org.example.springboothomework.model.Course;
+import org.example.springboothomework.service.CourseService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import tools.jackson.databind.ObjectMapper;
+
+import java.util.List;
+
+import static org.mockito.Mockito.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+
+@ExtendWith(MockitoExtension.class)
+class CourseControllerTest {
+
+ private MockMvc mockMvc;
+ private ObjectMapper objectMapper;
+
+ @Mock
+ private CourseService courseService;
+
+ @InjectMocks
+ private CourseController courseController;
+
+ @BeforeEach
+ void setup() {
+ objectMapper = new ObjectMapper();
+ mockMvc = MockMvcBuilders.standaloneSetup(courseController).build();
+ }
+
+ @Test
+ void shouldCreateCourse() throws Exception {
+ Course course = new Course("Java", 100.0);
+
+ when(courseService.addCourse(any(Course.class))).thenReturn(course);
+
+ mockMvc.perform(post("/api/courses")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content("""
+ {
+ "name": "Java",
+ "price": 100
+ }
+ """))
+ .andExpect(status().isCreated())
+ .andExpect(jsonPath("$.name").value("Java"))
+ .andExpect(jsonPath("$.price").value(100));
+ }
+
+ @Test
+ void shouldReturnAllCourses() throws Exception {
+ Course course = new Course("Java", 500.0);
+ when(courseService.getAllCourses()).thenReturn(List.of(course));
+
+ mockMvc.perform(get("/api/courses"))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void shouldReturnCourseById() throws Exception {
+ Course course = new Course("Java", 500.0);
+ when(courseService.getCourseById("1")).thenReturn(course);
+
+ mockMvc.perform(get("/api/courses/1"))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void shouldReturn404WhenCourseNotFound() throws Exception {
+ when(courseService.getCourseById("999")).thenReturn(null);
+
+ mockMvc.perform(get("/api/courses/999"))
+ .andExpect(status().isNotFound());
+ }
+
+ @Test
+ void shouldUpdateCourse() throws Exception {
+ Course course = new Course("Java", 500.0);
+ when(courseService.updateCourse(eq("1"), any(Course.class))).thenReturn(course);
+
+ mockMvc.perform(put("/api/courses/1")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(objectMapper.writeValueAsString(course)))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void shouldDeleteCourse() throws Exception {
+ doNothing().when(courseService).deleteCourse("1");
+
+ mockMvc.perform(delete("/api/courses/1"))
+ .andExpect(status().isNoContent());
+ }
+
+ @Test
+ void shouldAssignTeacher() throws Exception {
+ doNothing().when(courseService).assignTeacher("1", "Ali");
+
+ mockMvc.perform(put("/api/courses/1/teacher")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content("Ali"))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void shouldAssignStudent() throws Exception {
+ doNothing().when(courseService).assignStudent("1", "Veli");
+
+ mockMvc.perform(put("/api/courses/1/student")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content("Veli"))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void shouldEnrollStudent() throws Exception {
+ doNothing().when(courseService).enrollStudent("2", "1");
+
+ mockMvc.perform(post("/api/courses/1/enroll/2"))
+ .andExpect(status().isCreated());
+ }
+
+ @Test
+ void shouldReturn400WhenEnrollingNonExistentStudent() throws Exception {
+ doThrow(new RuntimeException("Student not found")).when(courseService).enrollStudent("99", "1");
+
+ mockMvc.perform(post("/api/courses/1/enroll/99"))
+ .andExpect(status().isBadRequest());
+ }
+}
\ No newline at end of file
diff --git a/SpringBootHomeWork/src/test/java/org/example/springboothomework/SchoolControllerTest.java b/SpringBootHomeWork/src/test/java/org/example/springboothomework/SchoolControllerTest.java
new file mode 100644
index 00000000..1ec60eb6
--- /dev/null
+++ b/SpringBootHomeWork/src/test/java/org/example/springboothomework/SchoolControllerTest.java
@@ -0,0 +1,96 @@
+package org.example.springboothomework;
+
+import org.example.springboothomework.controller.SchoolController;
+import org.example.springboothomework.service.SchoolService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+import static org.mockito.Mockito.when;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+
+@ExtendWith(MockitoExtension.class)
+class SchoolControllerTest {
+
+ private MockMvc mockMvc;
+
+ @Mock
+ private SchoolService schoolService;
+
+ @InjectMocks
+ private SchoolController schoolController;
+
+ @BeforeEach
+ void setup() {
+ mockMvc = MockMvcBuilders.standaloneSetup(schoolController).build();
+ }
+
+ @Test
+ void shouldReturnProfit() throws Exception {
+ when(schoolService.showProfit()).thenReturn(2000.0);
+
+ mockMvc.perform(get("/api/school/profit"))
+ .andExpect(status().isOk())
+ .andExpect(content().string("2000.0"));
+ }
+
+ @Test
+ void shouldReturnZeroProfitWhenNoData() throws Exception {
+ when(schoolService.showProfit()).thenReturn(0.0);
+
+ mockMvc.perform(get("/api/school/profit"))
+ .andExpect(status().isOk())
+ .andExpect(content().string("0.0"));
+ }
+
+ @Test
+ void shouldReturnNegativeProfitWhenLoss() throws Exception {
+ when(schoolService.showProfit()).thenReturn(-500.0);
+
+ mockMvc.perform(get("/api/school/profit"))
+ .andExpect(status().isOk())
+ .andExpect(content().string("-500.0"));
+ }
+
+ @Test
+ void shouldReturnMoneyEarned() throws Exception {
+ when(schoolService.showMoneyEarned()).thenReturn(5000.0);
+
+ mockMvc.perform(get("/api/school/moneyEarn"))
+ .andExpect(status().isOk())
+ .andExpect(content().string("5000.0"));
+ }
+
+ @Test
+ void shouldReturnZeroMoneyEarnedWhenNoEnrollments() throws Exception {
+ when(schoolService.showMoneyEarned()).thenReturn(0.0);
+
+ mockMvc.perform(get("/api/school/moneyEarn"))
+ .andExpect(status().isOk())
+ .andExpect(content().string("0.0"));
+ }
+
+ @Test
+ void shouldReturnMoneySpent() throws Exception {
+ when(schoolService.showMoneySpent()).thenReturn(3000.0);
+
+ mockMvc.perform(get("/api/school/moneySpent"))
+ .andExpect(status().isOk())
+ .andExpect(content().string("3000.0"));
+ }
+
+ @Test
+ void shouldReturnZeroMoneySpentWhenNoTeachers() throws Exception {
+ when(schoolService.showMoneySpent()).thenReturn(0.0);
+
+ mockMvc.perform(get("/api/school/moneySpent"))
+ .andExpect(status().isOk())
+ .andExpect(content().string("0.0"));
+ }
+}
\ No newline at end of file
diff --git a/SpringBootHomeWork/src/test/java/org/example/springboothomework/SpringBootHomeWorkApplicationTests.java b/SpringBootHomeWork/src/test/java/org/example/springboothomework/SpringBootHomeWorkApplicationTests.java
new file mode 100644
index 00000000..077aa0bf
--- /dev/null
+++ b/SpringBootHomeWork/src/test/java/org/example/springboothomework/SpringBootHomeWorkApplicationTests.java
@@ -0,0 +1,13 @@
+package org.example.springboothomework;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class SpringBootHomeWorkApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/SpringBootHomeWork/src/test/java/org/example/springboothomework/StudentControllerTest.java b/SpringBootHomeWork/src/test/java/org/example/springboothomework/StudentControllerTest.java
new file mode 100644
index 00000000..6fd35e56
--- /dev/null
+++ b/SpringBootHomeWork/src/test/java/org/example/springboothomework/StudentControllerTest.java
@@ -0,0 +1,108 @@
+package org.example.springboothomework;
+
+import org.example.springboothomework.controller.StudentController;
+import org.example.springboothomework.model.Student;
+import org.example.springboothomework.service.StudentService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import tools.jackson.databind.ObjectMapper;
+
+
+import java.util.List;
+
+import static org.mockito.Mockito.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+
+@ExtendWith(MockitoExtension.class)
+class StudentControllerTest {
+
+ private MockMvc mockMvc;
+ private ObjectMapper objectMapper;
+
+ @Mock
+ private StudentService studentService;
+
+ @InjectMocks
+ private StudentController studentController;
+
+ @BeforeEach
+ void setup() {
+ objectMapper = new ObjectMapper();
+ mockMvc = MockMvcBuilders.standaloneSetup(studentController).build();
+ }
+
+ @Test
+ void shouldReturnAllStudents() throws Exception {
+ Student student = new Student("Yusif", "Baku", "yusif@mail.com");
+ when(studentService.getAllStudents()).thenReturn(List.of(student));
+
+ mockMvc.perform(get("/students"))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void shouldReturnStudentById() throws Exception {
+ Student student = new Student("Yusif", "Baku", "yusif@mail.com");
+ when(studentService.getStudentById("1")).thenReturn(student);
+
+ mockMvc.perform(get("/students/1"))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void shouldReturn404WhenStudentNotFound() throws Exception {
+ when(studentService.getStudentById("invalid-id")).thenReturn(null);
+
+ mockMvc.perform(get("/students/invalid-id"))
+ .andExpect(status().isNotFound());
+ }
+
+ @Test
+ void shouldCreateStudent() throws Exception {
+ Student student = new Student("Yusif", "Baku", "yusif@mail.com");
+
+ when(studentService.createStudent(any(Student.class))).thenReturn(student);
+
+ mockMvc.perform(post("/api/students")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content("""
+ {
+ "name": "Yusif",
+ "address": "Baku",
+ "email": "yusif@mail.com"
+ }
+ """))
+ .andExpect(status().isCreated())
+ .andExpect(jsonPath("$.name").value("Yusif"))
+ .andExpect(jsonPath("$.address").value("Baku"))
+ .andExpect(jsonPath("$.email").value("yusif@mail.com"));
+ }
+
+ @Test
+ void shouldUpdateStudent() throws Exception {
+ Student student = new Student("Yusif", "Baku", "yusif@mail.com");
+ when(studentService.updateStudent(eq("1"), any(Student.class))).thenReturn(student);
+
+ mockMvc.perform(put("/students/1")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(objectMapper.writeValueAsString(student)))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void shouldReturnEmptyListWhenNoStudentsForCourse() throws Exception {
+ when(studentService.getStudentsByCourseId("empty-course")).thenReturn(List.of());
+
+ mockMvc.perform(get("/students/course/empty-course"))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.length()").value(0));
+ }
+}
\ No newline at end of file
diff --git a/SpringBootHomeWork/src/test/java/org/example/springboothomework/TeacherControllerTest.java b/SpringBootHomeWork/src/test/java/org/example/springboothomework/TeacherControllerTest.java
new file mode 100644
index 00000000..6287de28
--- /dev/null
+++ b/SpringBootHomeWork/src/test/java/org/example/springboothomework/TeacherControllerTest.java
@@ -0,0 +1,107 @@
+package org.example.springboothomework;
+
+import org.example.springboothomework.controller.TeacherController;
+import org.example.springboothomework.model.Teacher;
+import org.example.springboothomework.service.TeacherService;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import tools.jackson.databind.ObjectMapper;
+
+import java.util.List;
+
+import static org.mockito.Mockito.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+
+@ExtendWith(MockitoExtension.class)
+class TeacherControllerTest {
+
+ private MockMvc mockMvc;
+ private ObjectMapper objectMapper;
+
+ @Mock
+ private TeacherService teacherService;
+
+ @InjectMocks
+ private TeacherController teacherController;
+
+ @BeforeEach
+ void setup() {
+ objectMapper = new ObjectMapper();
+ mockMvc = MockMvcBuilders.standaloneSetup(teacherController).build();
+ }
+
+ @Test
+ void shouldCreateTeacher() throws Exception {
+ Teacher teacher = new Teacher("Ali", 3000.0);
+ when(teacherService.createTeacher(any(Teacher.class))).thenReturn(teacher);
+
+ mockMvc.perform(post("/api/teachers")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(objectMapper.writeValueAsString(teacher)))
+ .andExpect(status().isCreated());
+ }
+
+ @Test
+ void shouldReturn400WhenTeacherSalaryIsInvalid() throws Exception {
+ Teacher teacher = new Teacher("Ali", -100.0);
+ when(teacherService.createTeacher(any(Teacher.class))).thenThrow(new IllegalArgumentException("Invalid salary"));
+
+ mockMvc.perform(post("/api/teachers")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(objectMapper.writeValueAsString(teacher)))
+ .andExpect(status().isBadRequest());
+ }
+
+ @Test
+ void shouldReturnAllTeachers() throws Exception {
+ Teacher teacher = new Teacher("Ali", 3000.0);
+ when(teacherService.getAllTeachers()).thenReturn(List.of(teacher));
+
+ mockMvc.perform(get("/api/teachers"))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void shouldReturnTeacherById() throws Exception {
+ Teacher teacher = new Teacher("Ali", 3000.0);
+ when(teacherService.getTeacherById("1")).thenReturn(teacher);
+
+ mockMvc.perform(get("/api/teachers/1"))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void shouldReturn404WhenTeacherNotFound() throws Exception {
+ when(teacherService.getTeacherById("unknown")).thenReturn(null);
+
+ mockMvc.perform(get("/api/teachers/unknown"))
+ .andExpect(status().isNotFound());
+ }
+
+ @Test
+ void shouldUpdateTeacher() throws Exception {
+ Teacher teacher = new Teacher("Ali", 3000.0);
+ when(teacherService.updateTeacher(eq("1"), any(Teacher.class))).thenReturn(teacher);
+
+ mockMvc.perform(put("/api/teachers/1")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(objectMapper.writeValueAsString(teacher)))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void shouldDeleteTeacher() throws Exception {
+ doNothing().when(teacherService).deleteTeacher("1");
+
+ mockMvc.perform(delete("/api/teachers/1"))
+ .andExpect(status().isNoContent());
+ }
+}
\ No newline at end of file