From 29284f6eac1c752b6eccdad3165db45f5c001f98 Mon Sep 17 00:00:00 2001 From: Sebastiaan de Schaetzen Date: Sun, 1 Mar 2026 13:22:26 +0100 Subject: [PATCH] Add spring backend --- backend-spring/.gitignore | 2 + backend-spring/Dockerfile | 17 + backend-spring/build.gradle.kts | 37 + .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 46175 bytes .../gradle/wrapper/gradle-wrapper.properties | 7 + backend-spring/gradlew | 248 ++++ backend-spring/gradlew.bat | 93 ++ backend-spring/settings.gradle.kts | 1 + .../AllowancePlannerApplication.java | 13 + .../controller/ApiController.java | 506 +++++++ .../controller/WebController.java | 173 +++ .../dto/AddAllowanceAmountRequest.java | 5 + .../allowanceplanner/dto/AllowanceDto.java | 8 + .../dto/BulkUpdateAllowanceRequest.java | 5 + .../dto/CreateAllowanceRequest.java | 5 + .../dto/CreateTaskRequest.java | 11 + .../allowanceplanner/dto/ErrorResponse.java | 5 + .../allowanceplanner/dto/HistoryDto.java | 7 + .../allowanceplanner/dto/IdResponse.java | 5 + .../allowanceplanner/dto/MessageResponse.java | 5 + .../dto/PostHistoryRequest.java | 5 + .../allowanceplanner/dto/TaskDto.java | 8 + .../allowanceplanner/dto/TransferRequest.java | 5 + .../dto/UpdateAllowanceRequest.java | 5 + .../allowanceplanner/dto/UserDto.java | 5 + .../dto/UserWithAllowanceDto.java | 5 + .../allowanceplanner/entity/Allowance.java | 99 ++ .../allowanceplanner/entity/History.java | 73 + .../allowanceplanner/entity/Task.java | 97 ++ .../allowanceplanner/entity/User.java | 61 + .../repository/AllowanceRepository.java | 27 + .../repository/HistoryRepository.java | 13 + .../repository/TaskRepository.java | 16 + .../repository/UserRepository.java | 13 + .../service/AllowanceService.java | 298 ++++ .../allowanceplanner/service/TaskService.java | 132 ++ .../service/TransferService.java | 102 ++ .../allowanceplanner/service/UserService.java | 42 + .../allowanceplanner/util/ColourUtil.java | 42 + .../src/main/resources/application.properties | 12 + .../resources/db/migration/V1__initial.sql | 42 + .../src/main/resources/templates/index.html | 122 ++ .../seeseepuff/allowanceplanner/ApiTest.java | 1242 +++++++++++++++++ .../allowanceplanner/ColourUtilTest.java | 33 + 44 files changed, 3652 insertions(+) create mode 100644 backend-spring/.gitignore create mode 100644 backend-spring/Dockerfile create mode 100644 backend-spring/build.gradle.kts create mode 100644 backend-spring/gradle/wrapper/gradle-wrapper.jar create mode 100644 backend-spring/gradle/wrapper/gradle-wrapper.properties create mode 100755 backend-spring/gradlew create mode 100644 backend-spring/gradlew.bat create mode 100644 backend-spring/settings.gradle.kts create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/AllowancePlannerApplication.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/controller/ApiController.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/controller/WebController.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/AddAllowanceAmountRequest.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/AllowanceDto.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/BulkUpdateAllowanceRequest.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/CreateAllowanceRequest.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/CreateTaskRequest.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/ErrorResponse.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/HistoryDto.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/IdResponse.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/MessageResponse.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/PostHistoryRequest.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/TaskDto.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/TransferRequest.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/UpdateAllowanceRequest.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/UserDto.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/UserWithAllowanceDto.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/Allowance.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/History.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/Task.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/User.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/AllowanceRepository.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/HistoryRepository.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/TaskRepository.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/UserRepository.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/AllowanceService.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/TaskService.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/TransferService.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/UserService.java create mode 100644 backend-spring/src/main/java/be/seeseepuff/allowanceplanner/util/ColourUtil.java create mode 100644 backend-spring/src/main/resources/application.properties create mode 100644 backend-spring/src/main/resources/db/migration/V1__initial.sql create mode 100644 backend-spring/src/main/resources/templates/index.html create mode 100644 backend-spring/src/test/java/be/seeseepuff/allowanceplanner/ApiTest.java create mode 100644 backend-spring/src/test/java/be/seeseepuff/allowanceplanner/ColourUtilTest.java diff --git a/backend-spring/.gitignore b/backend-spring/.gitignore new file mode 100644 index 0000000..67bcc2f --- /dev/null +++ b/backend-spring/.gitignore @@ -0,0 +1,2 @@ +.gradle/ +build/ diff --git a/backend-spring/Dockerfile b/backend-spring/Dockerfile new file mode 100644 index 0000000..c040705 --- /dev/null +++ b/backend-spring/Dockerfile @@ -0,0 +1,17 @@ +FROM eclipse-temurin:25-jdk-alpine AS build + +WORKDIR /app +COPY gradle ./gradle +COPY gradlew build.gradle.kts settings.gradle.kts ./ +RUN ./gradlew dependencies --no-daemon + +COPY src ./src +RUN ./gradlew bootJar --no-daemon -x test + +FROM eclipse-temurin:25-jre-alpine + +WORKDIR /app +COPY --from=build /app/build/libs/*.jar app.jar + +EXPOSE 8080 +CMD ["java", "-jar", "app.jar"] diff --git a/backend-spring/build.gradle.kts b/backend-spring/build.gradle.kts new file mode 100644 index 0000000..069add2 --- /dev/null +++ b/backend-spring/build.gradle.kts @@ -0,0 +1,37 @@ +plugins { + java + id("org.springframework.boot") version "4.0.3" + id("io.spring.dependency-management") version "1.1.7" +} + +group = "be.seeseepuff" +version = "0.0.1-SNAPSHOT" + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(25) + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.boot:spring-boot-starter-data-jpa") + implementation("org.springframework.boot:spring-boot-starter-thymeleaf") + implementation("org.springframework.boot:spring-boot-starter-flyway") + implementation("org.flywaydb:flyway-database-postgresql") + runtimeOnly("org.postgresql:postgresql") + + testImplementation("org.springframework.boot:spring-boot-starter-test") + testImplementation("org.springframework.boot:spring-boot-testcontainers") + testImplementation("org.testcontainers:testcontainers-junit-jupiter:2.0.3") + testImplementation("org.testcontainers:testcontainers-postgresql:2.0.3") + testImplementation("io.rest-assured:rest-assured:6.0.0") +} + +tasks.withType { + useJUnitPlatform() +} diff --git a/backend-spring/gradle/wrapper/gradle-wrapper.jar b/backend-spring/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..61285a659d17295f1de7c53e24fdf13ad755c379 GIT binary patch literal 46175 zcma&NWmKG9wk?cn;qLD4?(Xgo+}#P9AcecTOK=k0-KB7X7w!%r36R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#gBV5Y@bA7+3DzB?F~`&QR(f^X2@Ud?}D{yE%DCHvdM^n&(};grErGS5tZ z)0sC#(phgcEQtOOkp8?$H#Mq-ZUMzJ{sGV*DzM)jo;M|3Z%-!PEWbznP2b&=Q@riG zlk>lv|J75!(1^Wz<~L>kt`!-7SU%tHo&RgV{pS2{s#)D0Wse1JLHtLi=ug!I?>6S9 zLejN_$q!o>{RPthtd(^a_okAL;4NH8iCeh;A2p`Cpf{CVu0?u&n3B{j(0^wQ{z$Ut zF3L@@iQ8Q&Df3g5{|HR{ZyGUoac@%YUrSm1Fhqr4PyPM@@$21lzgbIt%?SF#R&{=X@po9`C;Xsy0dCeKT$g13uui+5 z0{puM;jR|cUB@?HjlbPHOP;@U{EOm-yBIgK!q+d^|FClJUt#>_!rsi?U8j_P7-95J z-TpMeeD`E;CZujp^Iu|r>h)Jyz`M?GhLx{#T0cxN{^!pBAj5SRyKy50$qLSTURK|Fca-~JC(R-+UE literal 0 HcmV?d00001 diff --git a/backend-spring/gradle/wrapper/gradle-wrapper.properties b/backend-spring/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..37f78a6 --- /dev/null +++ b/backend-spring/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/backend-spring/gradlew b/backend-spring/gradlew new file mode 100755 index 0000000..adff685 --- /dev/null +++ b/backend-spring/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed 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 +# +# https://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. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + + + +# Determine the Java command to use to start the JVM. +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 + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/backend-spring/gradlew.bat b/backend-spring/gradlew.bat new file mode 100644 index 0000000..e509b2d --- /dev/null +++ b/backend-spring/gradlew.bat @@ -0,0 +1,93 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/backend-spring/settings.gradle.kts b/backend-spring/settings.gradle.kts new file mode 100644 index 0000000..61d5455 --- /dev/null +++ b/backend-spring/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "allowance-planner" diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/AllowancePlannerApplication.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/AllowancePlannerApplication.java new file mode 100644 index 0000000..dbc9452 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/AllowancePlannerApplication.java @@ -0,0 +1,13 @@ +package be.seeseepuff.allowanceplanner; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class AllowancePlannerApplication +{ + public static void main(String[] args) + { + SpringApplication.run(AllowancePlannerApplication.class, args); + } +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/controller/ApiController.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/controller/ApiController.java new file mode 100644 index 0000000..72dcb63 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/controller/ApiController.java @@ -0,0 +1,506 @@ +package be.seeseepuff.allowanceplanner.controller; + +import be.seeseepuff.allowanceplanner.dto.*; +import be.seeseepuff.allowanceplanner.service.AllowanceService; +import be.seeseepuff.allowanceplanner.service.TaskService; +import be.seeseepuff.allowanceplanner.service.TransferService; +import be.seeseepuff.allowanceplanner.service.UserService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Optional; + +@RestController +@RequestMapping("/api") +@CrossOrigin(origins = "*") +public class ApiController +{ + private final UserService userService; + private final AllowanceService allowanceService; + private final TaskService taskService; + private final TransferService transferService; + + public ApiController(UserService userService, + AllowanceService allowanceService, + TaskService taskService, + TransferService transferService) + { + this.userService = userService; + this.allowanceService = allowanceService; + this.taskService = taskService; + this.transferService = transferService; + } + + // ---- Users ---- + + @GetMapping("/users") + public List getUsers() + { + return userService.getUsers(); + } + + @GetMapping("/user/{userId}") + public ResponseEntity getUser(@PathVariable String userId) + { + int id; + try + { + id = Integer.parseInt(userId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid user ID")); + } + + Optional user = userService.getUser(id); + if (user.isEmpty()) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("User not found")); + } + return ResponseEntity.ok(user.get()); + } + + // ---- History ---- + + @PostMapping("/user/{userId}/history") + public ResponseEntity postHistory(@PathVariable String userId, @RequestBody PostHistoryRequest request) + { + int id; + try + { + id = Integer.parseInt(userId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid user ID")); + } + + if (request.description() == null || request.description().isEmpty()) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Description cannot be empty")); + } + + if (!userService.userExists(id)) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("User not found")); + } + + allowanceService.addHistory(id, request); + return ResponseEntity.ok(new MessageResponse("History updated successfully")); + } + + @GetMapping("/user/{userId}/history") + public ResponseEntity getHistory(@PathVariable String userId) + { + int id; + try + { + id = Integer.parseInt(userId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid user ID")); + } + + List history = allowanceService.getHistory(id); + return ResponseEntity.ok(history); + } + + // ---- Allowances ---- + + @GetMapping("/user/{userId}/allowance") + public ResponseEntity getUserAllowance(@PathVariable String userId) + { + int id; + try + { + id = Integer.parseInt(userId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid user ID")); + } + + if (!userService.userExists(id)) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("User not found")); + } + + return ResponseEntity.ok(allowanceService.getUserAllowances(id)); + } + + @PostMapping("/user/{userId}/allowance") + public ResponseEntity createUserAllowance(@PathVariable String userId, + @RequestBody CreateAllowanceRequest request) + { + int id; + try + { + id = Integer.parseInt(userId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid user ID")); + } + + if (request.name() == null || request.name().isEmpty()) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Allowance name cannot be empty")); + } + + if (!userService.userExists(id)) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("User not found")); + } + + int allowanceId = allowanceService.createAllowance(id, request); + return ResponseEntity.status(HttpStatus.CREATED).body(new IdResponse(allowanceId)); + } + + @PutMapping("/user/{userId}/allowance") + public ResponseEntity bulkPutUserAllowance(@PathVariable String userId, + @RequestBody List requests) + { + int id; + try + { + id = Integer.parseInt(userId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid user ID")); + } + + if (!userService.userExists(id)) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("User not found")); + } + + allowanceService.bulkUpdateAllowance(id, requests); + return ResponseEntity.ok(new MessageResponse("Allowance updated successfully")); + } + + @GetMapping("/user/{userId}/allowance/{allowanceId}") + public ResponseEntity getUserAllowanceById(@PathVariable String userId, @PathVariable String allowanceId) + { + int uid; + try + { + uid = Integer.parseInt(userId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid user ID")); + } + + int aid; + try + { + aid = Integer.parseInt(allowanceId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid allowance ID")); + } + + if (!userService.userExists(uid)) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("User not found")); + } + + Optional allowance = allowanceService.getUserAllowanceById(uid, aid); + if (allowance.isEmpty()) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("Allowance not found")); + } + return ResponseEntity.ok(allowance.get()); + } + + @DeleteMapping("/user/{userId}/allowance/{allowanceId}") + public ResponseEntity deleteUserAllowance(@PathVariable String userId, @PathVariable String allowanceId) + { + int uid; + try + { + uid = Integer.parseInt(userId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid user ID")); + } + + int aid; + try + { + aid = Integer.parseInt(allowanceId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid allowance ID")); + } + + if (aid == 0) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Allowance id zero cannot be deleted")); + } + + if (!userService.userExists(uid)) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("User not found")); + } + + boolean deleted = allowanceService.deleteAllowance(uid, aid); + if (!deleted) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("History not found")); + } + return ResponseEntity.ok(new MessageResponse("History deleted successfully")); + } + + @PutMapping("/user/{userId}/allowance/{allowanceId}") + public ResponseEntity putUserAllowance(@PathVariable String userId, @PathVariable String allowanceId, + @RequestBody UpdateAllowanceRequest request) + { + int uid; + try + { + uid = Integer.parseInt(userId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid user ID")); + } + + int aid; + try + { + aid = Integer.parseInt(allowanceId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid allowance ID")); + } + + if (!userService.userExists(uid)) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("User not found")); + } + + boolean updated = allowanceService.updateAllowance(uid, aid, request); + if (!updated) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("Allowance not found")); + } + return ResponseEntity.ok(new MessageResponse("Allowance updated successfully")); + } + + @PostMapping("/user/{userId}/allowance/{allowanceId}/complete") + public ResponseEntity completeAllowance(@PathVariable String userId, @PathVariable String allowanceId) + { + int uid; + try + { + uid = Integer.parseInt(userId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid user ID")); + } + + int aid; + try + { + aid = Integer.parseInt(allowanceId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid allowance ID")); + } + + if (!userService.userExists(uid)) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("User not found")); + } + + boolean completed = allowanceService.completeAllowance(uid, aid); + if (!completed) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("Allowance not found")); + } + return ResponseEntity.ok(new MessageResponse("Allowance completed successfully")); + } + + @PostMapping("/user/{userId}/allowance/{allowanceId}/add") + public ResponseEntity addToAllowance(@PathVariable String userId, @PathVariable String allowanceId, + @RequestBody AddAllowanceAmountRequest request) + { + int uid; + try + { + uid = Integer.parseInt(userId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid user ID")); + } + + int aid; + try + { + aid = Integer.parseInt(allowanceId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid allowance ID")); + } + + if (!userService.userExists(uid)) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("User not found")); + } + + boolean result = allowanceService.addAllowanceAmount(uid, aid, request); + if (!result) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("Allowance not found")); + } + return ResponseEntity.ok(new MessageResponse("Allowance completed successfully")); + } + + // ---- Tasks ---- + + @PostMapping("/tasks") + public ResponseEntity createTask(@RequestBody CreateTaskRequest request) + { + if (request.name() == null || request.name().isEmpty()) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Task name cannot be empty")); + } + + if (request.schedule() != null) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Schedules are not yet supported")); + } + + if (request.assigned() != null) + { + if (!userService.userExists(request.assigned())) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("User not found")); + } + } + + int taskId = taskService.createTask(request); + return ResponseEntity.status(HttpStatus.CREATED).body(new IdResponse(taskId)); + } + + @GetMapping("/tasks") + public List getTasks() + { + return taskService.getTasks(); + } + + @GetMapping("/task/{taskId}") + public ResponseEntity getTask(@PathVariable String taskId) + { + int id; + try + { + id = Integer.parseInt(taskId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid task ID")); + } + + Optional task = taskService.getTask(id); + if (task.isEmpty()) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("Task not found")); + } + return ResponseEntity.ok(task.get()); + } + + @PutMapping("/task/{taskId}") + public ResponseEntity putTask(@PathVariable String taskId, @RequestBody CreateTaskRequest request) + { + int id; + try + { + id = Integer.parseInt(taskId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid task ID")); + } + + Optional existing = taskService.getTask(id); + if (existing.isEmpty()) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("Task not found")); + } + + taskService.updateTask(id, request); + return ResponseEntity.ok(new MessageResponse("Task updated successfully")); + } + + @DeleteMapping("/task/{taskId}") + public ResponseEntity deleteTask(@PathVariable String taskId) + { + int id; + try + { + id = Integer.parseInt(taskId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid task ID")); + } + + if (!taskService.hasTask(id)) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("Task not found")); + } + + taskService.deleteTask(id); + return ResponseEntity.ok(new MessageResponse("Task deleted successfully")); + } + + @PostMapping("/task/{taskId}/complete") + public ResponseEntity completeTask(@PathVariable String taskId) + { + int id; + try + { + id = Integer.parseInt(taskId); + } + catch (NumberFormatException e) + { + return ResponseEntity.badRequest().body(new ErrorResponse("Invalid task ID")); + } + + boolean completed = taskService.completeTask(id); + if (!completed) + { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("Task not found")); + } + return ResponseEntity.ok(new MessageResponse("Task completed successfully")); + } + + // ---- Transfer ---- + + @PostMapping("/transfer") + public ResponseEntity transfer(@RequestBody TransferRequest request) + { + TransferService.TransferResult result = transferService.transfer(request); + return switch (result.status()) + { + case SUCCESS -> ResponseEntity.ok(new MessageResponse(result.message())); + case BAD_REQUEST -> ResponseEntity.badRequest().body(new ErrorResponse(result.message())); + case NOT_FOUND -> + ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse(result.message())); + }; + } +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/controller/WebController.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/controller/WebController.java new file mode 100644 index 0000000..d290984 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/controller/WebController.java @@ -0,0 +1,173 @@ +package be.seeseepuff.allowanceplanner.controller; + +import be.seeseepuff.allowanceplanner.dto.*; +import be.seeseepuff.allowanceplanner.service.AllowanceService; +import be.seeseepuff.allowanceplanner.service.TaskService; +import be.seeseepuff.allowanceplanner.service.UserService; +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.Arrays; +import java.util.List; + +@Controller +public class WebController +{ + private final UserService userService; + private final AllowanceService allowanceService; + private final TaskService taskService; + + public WebController(UserService userService, AllowanceService allowanceService, TaskService taskService) + { + this.userService = userService; + this.allowanceService = allowanceService; + this.taskService = taskService; + } + + @GetMapping("/") + public String index(HttpServletRequest request, HttpServletResponse response, Model model) + { + Integer currentUser = getCurrentUser(request, response); + if (currentUser == null) + { + model.addAttribute("users", userService.getUsers()); + return "index"; + } + return renderWithUser(model, currentUser); + } + + @GetMapping("/login") + public String login(@RequestParam(required = false) String user, HttpServletResponse response) + { + if (user != null && !user.isEmpty()) + { + Cookie cookie = new Cookie("user", user); + cookie.setMaxAge(3600); + cookie.setHttpOnly(true); + response.addCookie(cookie); + } + return "redirect:/"; + } + + @PostMapping("/createTask") + public String createTask(@RequestParam String name, @RequestParam double reward, + @RequestParam(required = false) String schedule, + HttpServletRequest request, HttpServletResponse response, Model model) + { + Integer currentUser = getCurrentUser(request, response); + if (currentUser == null) + { + return "redirect:/"; + } + + if (name.isEmpty() || reward <= 0) + { + model.addAttribute("error", "Invalid input"); + return "index"; + } + + CreateTaskRequest taskRequest = new CreateTaskRequest(name, reward, null, + (schedule != null && !schedule.isEmpty()) ? schedule : null); + taskService.createTask(taskRequest); + return "redirect:/"; + } + + @GetMapping("/completeTask") + public String completeTask(@RequestParam("task") int taskId) + { + taskService.completeTask(taskId); + return "redirect:/"; + } + + @PostMapping("/createAllowance") + public String createAllowance(@RequestParam String name, @RequestParam double target, + @RequestParam double weight, + HttpServletRequest request, HttpServletResponse response, Model model) + { + Integer currentUser = getCurrentUser(request, response); + if (currentUser == null) + { + return "redirect:/"; + } + + if (name.isEmpty() || target <= 0 || weight <= 0) + { + model.addAttribute("error", "Invalid input"); + return "index"; + } + + allowanceService.createAllowance(currentUser, new CreateAllowanceRequest(name, target, weight, "")); + return "redirect:/"; + } + + @GetMapping("/completeAllowance") + public String completeAllowance(@RequestParam("allowance") int allowanceId, + HttpServletRequest request, HttpServletResponse response) + { + Integer currentUser = getCurrentUser(request, response); + if (currentUser == null) + { + return "redirect:/"; + } + allowanceService.completeAllowance(currentUser, allowanceId); + return "redirect:/"; + } + + private Integer getCurrentUser(HttpServletRequest request, HttpServletResponse response) + { + Cookie[] cookies = request.getCookies(); + if (cookies == null) + { + return null; + } + String userStr = Arrays.stream(cookies) + .filter(c -> "user".equals(c.getName())) + .map(Cookie::getValue) + .findFirst() + .orElse(null); + if (userStr == null) + { + return null; + } + try + { + int userId = Integer.parseInt(userStr); + if (!userService.userExists(userId)) + { + unsetUserCookie(response); + return null; + } + return userId; + } + catch (NumberFormatException e) + { + unsetUserCookie(response); + return null; + } + } + + private void unsetUserCookie(HttpServletResponse response) + { + Cookie cookie = new Cookie("user", ""); + cookie.setMaxAge(0); + cookie.setPath("/"); + cookie.setHttpOnly(true); + response.addCookie(cookie); + } + + private String renderWithUser(Model model, int currentUser) + { + model.addAttribute("users", userService.getUsers()); + model.addAttribute("currentUser", currentUser); + model.addAttribute("allowances", allowanceService.getUserAllowances(currentUser)); + model.addAttribute("tasks", taskService.getTasks()); + model.addAttribute("history", allowanceService.getHistory(currentUser)); + return "index"; + } +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/AddAllowanceAmountRequest.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/AddAllowanceAmountRequest.java new file mode 100644 index 0000000..f1c467d --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/AddAllowanceAmountRequest.java @@ -0,0 +1,5 @@ +package be.seeseepuff.allowanceplanner.dto; + +public record AddAllowanceAmountRequest(double amount, String description) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/AllowanceDto.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/AllowanceDto.java new file mode 100644 index 0000000..fc7b2e7 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/AllowanceDto.java @@ -0,0 +1,8 @@ +package be.seeseepuff.allowanceplanner.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.ALWAYS) +public record AllowanceDto(int id, String name, double target, double progress, double weight, String colour) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/BulkUpdateAllowanceRequest.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/BulkUpdateAllowanceRequest.java new file mode 100644 index 0000000..124a08c --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/BulkUpdateAllowanceRequest.java @@ -0,0 +1,5 @@ +package be.seeseepuff.allowanceplanner.dto; + +public record BulkUpdateAllowanceRequest(int id, double weight) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/CreateAllowanceRequest.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/CreateAllowanceRequest.java new file mode 100644 index 0000000..ac4e8aa --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/CreateAllowanceRequest.java @@ -0,0 +1,5 @@ +package be.seeseepuff.allowanceplanner.dto; + +public record CreateAllowanceRequest(String name, double target, double weight, String colour) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/CreateTaskRequest.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/CreateTaskRequest.java new file mode 100644 index 0000000..e430354 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/CreateTaskRequest.java @@ -0,0 +1,11 @@ +package be.seeseepuff.allowanceplanner.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public record CreateTaskRequest( + String name, + Double reward, + Integer assigned, + String schedule) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/ErrorResponse.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/ErrorResponse.java new file mode 100644 index 0000000..c5763de --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/ErrorResponse.java @@ -0,0 +1,5 @@ +package be.seeseepuff.allowanceplanner.dto; + +public record ErrorResponse(String error) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/HistoryDto.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/HistoryDto.java new file mode 100644 index 0000000..7e404bd --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/HistoryDto.java @@ -0,0 +1,7 @@ +package be.seeseepuff.allowanceplanner.dto; + +import java.time.Instant; + +public record HistoryDto(double allowance, Instant timestamp, String description) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/IdResponse.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/IdResponse.java new file mode 100644 index 0000000..54b2bea --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/IdResponse.java @@ -0,0 +1,5 @@ +package be.seeseepuff.allowanceplanner.dto; + +public record IdResponse(int id) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/MessageResponse.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/MessageResponse.java new file mode 100644 index 0000000..2fef1f9 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/MessageResponse.java @@ -0,0 +1,5 @@ +package be.seeseepuff.allowanceplanner.dto; + +public record MessageResponse(String message) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/PostHistoryRequest.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/PostHistoryRequest.java new file mode 100644 index 0000000..abff1a5 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/PostHistoryRequest.java @@ -0,0 +1,5 @@ +package be.seeseepuff.allowanceplanner.dto; + +public record PostHistoryRequest(double allowance, String description) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/TaskDto.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/TaskDto.java new file mode 100644 index 0000000..168f10c --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/TaskDto.java @@ -0,0 +1,8 @@ +package be.seeseepuff.allowanceplanner.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.ALWAYS) +public record TaskDto(int id, String name, double reward, Integer assigned, String schedule) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/TransferRequest.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/TransferRequest.java new file mode 100644 index 0000000..f631e40 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/TransferRequest.java @@ -0,0 +1,5 @@ +package be.seeseepuff.allowanceplanner.dto; + +public record TransferRequest(int from, int to, double amount) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/UpdateAllowanceRequest.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/UpdateAllowanceRequest.java new file mode 100644 index 0000000..7b1cca8 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/UpdateAllowanceRequest.java @@ -0,0 +1,5 @@ +package be.seeseepuff.allowanceplanner.dto; + +public record UpdateAllowanceRequest(String name, double target, double weight, String colour) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/UserDto.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/UserDto.java new file mode 100644 index 0000000..18a0823 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/UserDto.java @@ -0,0 +1,5 @@ +package be.seeseepuff.allowanceplanner.dto; + +public record UserDto(int id, String name) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/UserWithAllowanceDto.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/UserWithAllowanceDto.java new file mode 100644 index 0000000..553ddc0 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/dto/UserWithAllowanceDto.java @@ -0,0 +1,5 @@ +package be.seeseepuff.allowanceplanner.dto; + +public record UserWithAllowanceDto(int id, String name, double allowance) +{ +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/Allowance.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/Allowance.java new file mode 100644 index 0000000..f562b25 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/Allowance.java @@ -0,0 +1,99 @@ +package be.seeseepuff.allowanceplanner.entity; + +import jakarta.persistence.*; + +@Entity +@Table(name = "allowances") +public class Allowance +{ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int id; + + @Column(name = "user_id", nullable = false) + private int userId; + + @Column(nullable = false) + private String name; + + @Column(nullable = false) + private long target; + + @Column(nullable = false) + private long balance = 0; + + @Column(nullable = false) + private double weight; + + private Integer colour; + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public int getUserId() + { + return userId; + } + + public void setUserId(int userId) + { + this.userId = userId; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public long getTarget() + { + return target; + } + + public void setTarget(long target) + { + this.target = target; + } + + public long getBalance() + { + return balance; + } + + public void setBalance(long balance) + { + this.balance = balance; + } + + public double getWeight() + { + return weight; + } + + public void setWeight(double weight) + { + this.weight = weight; + } + + public Integer getColour() + { + return colour; + } + + public void setColour(Integer colour) + { + this.colour = colour; + } +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/History.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/History.java new file mode 100644 index 0000000..520422b --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/History.java @@ -0,0 +1,73 @@ +package be.seeseepuff.allowanceplanner.entity; + +import jakarta.persistence.*; + +@Entity +@Table(name = "history") +public class History +{ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int id; + + @Column(name = "user_id", nullable = false) + private int userId; + + @Column(nullable = false) + private long timestamp; + + @Column(nullable = false) + private long amount; + + private String description; + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public int getUserId() + { + return userId; + } + + public void setUserId(int userId) + { + this.userId = userId; + } + + public long getTimestamp() + { + return timestamp; + } + + public void setTimestamp(long timestamp) + { + this.timestamp = timestamp; + } + + public long getAmount() + { + return amount; + } + + public void setAmount(long amount) + { + this.amount = amount; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String description) + { + this.description = description; + } +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/Task.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/Task.java new file mode 100644 index 0000000..474c98e --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/Task.java @@ -0,0 +1,97 @@ +package be.seeseepuff.allowanceplanner.entity; + +import jakarta.persistence.*; + +@Entity +@Table(name = "tasks") +public class Task +{ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int id; + + @Column(nullable = false) + private String name; + + @Column(nullable = false) + private long reward; + + private Integer assigned; + + private String schedule; + + private Long completed; + + @Column(name = "next_run") + private Long nextRun; + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public long getReward() + { + return reward; + } + + public void setReward(long reward) + { + this.reward = reward; + } + + public Integer getAssigned() + { + return assigned; + } + + public void setAssigned(Integer assigned) + { + this.assigned = assigned; + } + + public String getSchedule() + { + return schedule; + } + + public void setSchedule(String schedule) + { + this.schedule = schedule; + } + + public Long getCompleted() + { + return completed; + } + + public void setCompleted(Long completed) + { + this.completed = completed; + } + + public Long getNextRun() + { + return nextRun; + } + + public void setNextRun(Long nextRun) + { + this.nextRun = nextRun; + } +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/User.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/User.java new file mode 100644 index 0000000..5b1b501 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/entity/User.java @@ -0,0 +1,61 @@ +package be.seeseepuff.allowanceplanner.entity; + +import jakarta.persistence.*; + +@Entity +@Table(name = "users") +public class User +{ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int id; + + @Column(nullable = false) + private String name; + + @Column(nullable = false) + private double weight = 10.0; + + @Column(nullable = false) + private long balance = 0; + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public double getWeight() + { + return weight; + } + + public void setWeight(double weight) + { + this.weight = weight; + } + + public long getBalance() + { + return balance; + } + + public void setBalance(long balance) + { + this.balance = balance; + } +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/AllowanceRepository.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/AllowanceRepository.java new file mode 100644 index 0000000..ba79bfb --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/AllowanceRepository.java @@ -0,0 +1,27 @@ +package be.seeseepuff.allowanceplanner.repository; + +import be.seeseepuff.allowanceplanner.entity.Allowance; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Optional; + +@Repository +public interface AllowanceRepository extends JpaRepository +{ + List findByUserIdOrderByIdAsc(int userId); + + Optional findByIdAndUserId(int id, int userId); + + int countByIdAndUserId(int id, int userId); + + void deleteByIdAndUserId(int id, int userId); + + @Query("SELECT a FROM Allowance a WHERE a.userId = :userId AND a.weight > 0 ORDER BY (a.target - a.balance) ASC") + List findByUserIdWithPositiveWeightOrderByRemainingAsc(int userId); + + @Query("SELECT COALESCE(SUM(a.weight), 0) FROM Allowance a WHERE a.userId = :userId AND a.weight > 0") + double sumPositiveWeights(int userId); +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/HistoryRepository.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/HistoryRepository.java new file mode 100644 index 0000000..67030fe --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/HistoryRepository.java @@ -0,0 +1,13 @@ +package be.seeseepuff.allowanceplanner.repository; + +import be.seeseepuff.allowanceplanner.entity.History; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface HistoryRepository extends JpaRepository +{ + List findByUserIdOrderByIdDesc(int userId); +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/TaskRepository.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/TaskRepository.java new file mode 100644 index 0000000..7e6fac0 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/TaskRepository.java @@ -0,0 +1,16 @@ +package be.seeseepuff.allowanceplanner.repository; + +import be.seeseepuff.allowanceplanner.entity.Task; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Optional; + +@Repository +public interface TaskRepository extends JpaRepository +{ + List findByCompletedIsNull(); + + Optional findByIdAndCompletedIsNull(int id); +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/UserRepository.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/UserRepository.java new file mode 100644 index 0000000..edf7723 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/repository/UserRepository.java @@ -0,0 +1,13 @@ +package be.seeseepuff.allowanceplanner.repository; + +import be.seeseepuff.allowanceplanner.entity.User; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +@Repository +public interface UserRepository extends JpaRepository +{ + @Query("SELECT COALESCE(SUM(h.amount), 0) FROM History h WHERE h.userId = :userId") + long sumHistoryAmount(int userId); +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/AllowanceService.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/AllowanceService.java new file mode 100644 index 0000000..0b3d6a7 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/AllowanceService.java @@ -0,0 +1,298 @@ +package be.seeseepuff.allowanceplanner.service; + +import be.seeseepuff.allowanceplanner.dto.*; +import be.seeseepuff.allowanceplanner.entity.Allowance; +import be.seeseepuff.allowanceplanner.entity.History; +import be.seeseepuff.allowanceplanner.entity.User; +import be.seeseepuff.allowanceplanner.repository.AllowanceRepository; +import be.seeseepuff.allowanceplanner.repository.HistoryRepository; +import be.seeseepuff.allowanceplanner.repository.UserRepository; +import be.seeseepuff.allowanceplanner.util.ColourUtil; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +@Service +public class AllowanceService +{ + private final AllowanceRepository allowanceRepository; + private final UserRepository userRepository; + private final HistoryRepository historyRepository; + + public AllowanceService(AllowanceRepository allowanceRepository, + UserRepository userRepository, + HistoryRepository historyRepository) + { + this.allowanceRepository = allowanceRepository; + this.userRepository = userRepository; + this.historyRepository = historyRepository; + } + + public List getUserAllowances(int userId) + { + User user = userRepository.findById(userId).orElseThrow(); + List result = new ArrayList<>(); + + // Add the "rest" allowance (id=0) + result.add(new AllowanceDto(0, "", 0, user.getBalance() / 100.0, user.getWeight(), "")); + + // Add named allowances + for (Allowance a : allowanceRepository.findByUserIdOrderByIdAsc(userId)) + { + result.add(toDto(a)); + } + return result; + } + + public Optional getUserAllowanceById(int userId, int allowanceId) + { + if (allowanceId == 0) + { + return userRepository.findById(userId) + .map(u -> new AllowanceDto(0, "", 0, u.getBalance() / 100.0, u.getWeight(), "")); + } + return allowanceRepository.findByIdAndUserId(allowanceId, userId) + .map(this::toDto); + } + + @Transactional + public int createAllowance(int userId, CreateAllowanceRequest request) + { + int colour = ColourUtil.convertStringToColour(request.colour()); + Allowance allowance = new Allowance(); + allowance.setUserId(userId); + allowance.setName(request.name()); + allowance.setTarget(Math.round(request.target() * 100.0)); + allowance.setWeight(request.weight()); + allowance.setColour(colour); + allowance = allowanceRepository.save(allowance); + return allowance.getId(); + } + + @Transactional + public boolean deleteAllowance(int userId, int allowanceId) + { + int count = allowanceRepository.countByIdAndUserId(allowanceId, userId); + if (count == 0) + { + return false; + } + allowanceRepository.deleteByIdAndUserId(allowanceId, userId); + return true; + } + + @Transactional + public boolean updateAllowance(int userId, int allowanceId, UpdateAllowanceRequest request) + { + if (allowanceId == 0) + { + User user = userRepository.findById(userId).orElseThrow(); + user.setWeight(request.weight()); + userRepository.save(user); + return true; + } + + Optional opt = allowanceRepository.findByIdAndUserId(allowanceId, userId); + if (opt.isEmpty()) + { + return false; + } + + int colour = ColourUtil.convertStringToColour(request.colour()); + Allowance allowance = opt.get(); + allowance.setName(request.name()); + allowance.setTarget(Math.round(request.target() * 100.0)); + allowance.setWeight(request.weight()); + allowance.setColour(colour); + allowanceRepository.save(allowance); + return true; + } + + @Transactional + public void bulkUpdateAllowance(int userId, List requests) + { + for (BulkUpdateAllowanceRequest req : requests) + { + if (req.id() == 0) + { + User user = userRepository.findById(userId).orElseThrow(); + user.setWeight(req.weight()); + userRepository.save(user); + } + else + { + allowanceRepository.findByIdAndUserId(req.id(), userId).ifPresent(a -> + { + a.setWeight(req.weight()); + allowanceRepository.save(a); + }); + } + } + } + + @Transactional + public boolean completeAllowance(int userId, int allowanceId) + { + Optional opt = allowanceRepository.findByIdAndUserId(allowanceId, userId); + if (opt.isEmpty()) + { + return false; + } + + Allowance allowance = opt.get(); + long cost = allowance.getBalance(); + String allowanceName = allowance.getName(); + + // Delete the allowance + allowanceRepository.delete(allowance); + + // Add a history entry + History history = new History(); + history.setUserId(userId); + history.setTimestamp(Instant.now().getEpochSecond()); + history.setAmount(-cost); + history.setDescription("Allowance completed: " + allowanceName); + historyRepository.save(history); + + return true; + } + + @Transactional + public boolean addAllowanceAmount(int userId, int allowanceId, AddAllowanceAmountRequest request) + { + long remainingAmount = Math.round(request.amount() * 100); + + // Insert history entry + History history = new History(); + history.setUserId(userId); + history.setTimestamp(Instant.now().getEpochSecond()); + history.setAmount(remainingAmount); + history.setDescription(request.description()); + historyRepository.save(history); + + if (allowanceId == 0) + { + if (remainingAmount < 0) + { + User user = userRepository.findById(userId).orElseThrow(); + if (remainingAmount > user.getBalance()) + { + throw new IllegalArgumentException("cannot remove more than the current balance: " + user.getBalance()); + } + } + User user = userRepository.findById(userId).orElseThrow(); + user.setBalance(user.getBalance() + remainingAmount); + userRepository.save(user); + } + else if (remainingAmount < 0) + { + Allowance allowance = allowanceRepository.findByIdAndUserId(allowanceId, userId).orElse(null); + if (allowance == null) + { + return false; + } + if (remainingAmount > allowance.getBalance()) + { + throw new IllegalArgumentException("cannot remove more than the current allowance balance: " + allowance.getBalance()); + } + allowance.setBalance(allowance.getBalance() + remainingAmount); + allowanceRepository.save(allowance); + } + else + { + Allowance allowance = allowanceRepository.findByIdAndUserId(allowanceId, userId).orElse(null); + if (allowance == null) + { + return false; + } + + long toAdd = remainingAmount; + if (allowance.getBalance() + toAdd > allowance.getTarget()) + { + toAdd = allowance.getTarget() - allowance.getBalance(); + } + remainingAmount -= toAdd; + + if (toAdd > 0) + { + allowance.setBalance(allowance.getBalance() + toAdd); + allowanceRepository.save(allowance); + } + + if (remainingAmount > 0) + { + addDistributedReward(userId, (int) remainingAmount); + } + } + return true; + } + + public void addDistributedReward(int userId, int reward) + { + User user = userRepository.findById(userId).orElseThrow(); + double userWeight = user.getWeight(); + + double sumOfWeights = allowanceRepository.sumPositiveWeights(userId) + userWeight; + + int remainingReward = reward; + + if (sumOfWeights > 0) + { + List allowances = allowanceRepository.findByUserIdWithPositiveWeightOrderByRemainingAsc(userId); + for (Allowance allowance : allowances) + { + int amount = (int) ((allowance.getWeight() / sumOfWeights) * remainingReward); + if (allowance.getBalance() + amount > allowance.getTarget()) + { + amount = (int) (allowance.getTarget() - allowance.getBalance()); + } + sumOfWeights -= allowance.getWeight(); + allowance.setBalance(allowance.getBalance() + amount); + allowanceRepository.save(allowance); + remainingReward -= amount; + } + } + + // Add remaining to user's balance + user = userRepository.findById(userId).orElseThrow(); + user.setBalance(user.getBalance() + remainingReward); + userRepository.save(user); + } + + public List getHistory(int userId) + { + return historyRepository.findByUserIdOrderByIdDesc(userId).stream() + .map(h -> new HistoryDto( + h.getAmount() / 100.0, + Instant.ofEpochSecond(h.getTimestamp()), + h.getDescription())) + .toList(); + } + + @Transactional + public void addHistory(int userId, PostHistoryRequest request) + { + long amount = Math.round(request.allowance() * 100.0); + History history = new History(); + history.setUserId(userId); + history.setTimestamp(Instant.now().getEpochSecond()); + history.setAmount(amount); + history.setDescription(request.description()); + historyRepository.save(history); + } + + private AllowanceDto toDto(Allowance a) + { + return new AllowanceDto( + a.getId(), + a.getName(), + a.getTarget() / 100.0, + a.getBalance() / 100.0, + a.getWeight(), + ColourUtil.convertColourToString(a.getColour())); + } +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/TaskService.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/TaskService.java new file mode 100644 index 0000000..47dd254 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/TaskService.java @@ -0,0 +1,132 @@ +package be.seeseepuff.allowanceplanner.service; + +import be.seeseepuff.allowanceplanner.dto.*; +import be.seeseepuff.allowanceplanner.entity.History; +import be.seeseepuff.allowanceplanner.entity.Task; +import be.seeseepuff.allowanceplanner.entity.User; +import be.seeseepuff.allowanceplanner.repository.HistoryRepository; +import be.seeseepuff.allowanceplanner.repository.TaskRepository; +import be.seeseepuff.allowanceplanner.repository.UserRepository; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.Instant; +import java.util.List; +import java.util.Optional; + +@Service +public class TaskService +{ + private final TaskRepository taskRepository; + private final UserRepository userRepository; + private final HistoryRepository historyRepository; + private final AllowanceService allowanceService; + + public TaskService(TaskRepository taskRepository, + UserRepository userRepository, + HistoryRepository historyRepository, + AllowanceService allowanceService) + { + this.taskRepository = taskRepository; + this.userRepository = userRepository; + this.historyRepository = historyRepository; + this.allowanceService = allowanceService; + } + + @Transactional + public int createTask(CreateTaskRequest request) + { + Task task = new Task(); + task.setName(request.name()); + task.setReward(Math.round((request.reward() != null ? request.reward() : 0.0) * 100.0)); + task.setAssigned(request.assigned()); + task = taskRepository.save(task); + return task.getId(); + } + + public List getTasks() + { + return taskRepository.findByCompletedIsNull().stream() + .map(this::toDto) + .toList(); + } + + public Optional getTask(int taskId) + { + return taskRepository.findByIdAndCompletedIsNull(taskId) + .map(this::toDto); + } + + @Transactional + public boolean updateTask(int taskId, CreateTaskRequest request) + { + Optional opt = taskRepository.findByIdAndCompletedIsNull(taskId); + if (opt.isEmpty()) + { + return false; + } + Task task = opt.get(); + task.setName(request.name()); + task.setReward(Math.round((request.reward() != null ? request.reward() : 0.0) * 100.0)); + task.setAssigned(request.assigned()); + taskRepository.save(task); + return true; + } + + public boolean hasTask(int taskId) + { + return taskRepository.existsById(taskId); + } + + @Transactional + public void deleteTask(int taskId) + { + taskRepository.deleteById(taskId); + } + + @Transactional + public boolean completeTask(int taskId) + { + Optional opt = taskRepository.findById(taskId); + if (opt.isEmpty()) + { + return false; + } + + Task task = opt.get(); + long reward = task.getReward(); + String rewardName = task.getName(); + + // Give reward to all users + List users = userRepository.findAll(); + for (User user : users) + { + // Add history entry + History history = new History(); + history.setUserId(user.getId()); + history.setTimestamp(Instant.now().getEpochSecond()); + history.setAmount(reward); + history.setDescription("Task completed: " + rewardName); + historyRepository.save(history); + + // Distribute reward + allowanceService.addDistributedReward(user.getId(), (int) reward); + } + + // Mark task as completed + task.setCompleted(Instant.now().getEpochSecond()); + taskRepository.save(task); + + return true; + } + + private TaskDto toDto(Task t) + { + return new TaskDto( + t.getId(), + t.getName(), + t.getReward() / 100.0, + t.getAssigned(), + t.getSchedule()); + } +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/TransferService.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/TransferService.java new file mode 100644 index 0000000..7b81ba0 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/TransferService.java @@ -0,0 +1,102 @@ +package be.seeseepuff.allowanceplanner.service; + +import be.seeseepuff.allowanceplanner.dto.TransferRequest; +import be.seeseepuff.allowanceplanner.entity.Allowance; +import be.seeseepuff.allowanceplanner.repository.AllowanceRepository; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Optional; + +@Service +public class TransferService +{ + private final AllowanceRepository allowanceRepository; + + public TransferService(AllowanceRepository allowanceRepository) + { + this.allowanceRepository = allowanceRepository; + } + + @Transactional + public TransferResult transfer(TransferRequest request) + { + if (request.from() == request.to()) + { + return TransferResult.success(); + } + + int amountCents = (int) Math.round(request.amount() * 100.0); + if (amountCents <= 0) + { + return TransferResult.badRequest("amount must be positive"); + } + + Optional fromOpt = allowanceRepository.findById(request.from()); + if (fromOpt.isEmpty()) + { + return TransferResult.notFound(); + } + + Optional toOpt = allowanceRepository.findById(request.to()); + if (toOpt.isEmpty()) + { + return TransferResult.notFound(); + } + + Allowance from = fromOpt.get(); + Allowance to = toOpt.get(); + + if (from.getUserId() != to.getUserId()) + { + return TransferResult.badRequest("Allowances do not belong to the same user"); + } + + long remainingTo = to.getTarget() - to.getBalance(); + if (remainingTo <= 0) + { + return TransferResult.badRequest("target already reached"); + } + + int transfer = amountCents; + if (transfer > remainingTo) + { + transfer = (int) remainingTo; + } + + if (from.getBalance() < transfer) + { + return TransferResult.badRequest("Insufficient funds in source allowance"); + } + + from.setBalance(from.getBalance() - transfer); + to.setBalance(to.getBalance() + transfer); + allowanceRepository.save(from); + allowanceRepository.save(to); + + return TransferResult.success(); + } + + public record TransferResult(Status status, String message) + { + public enum Status + { + SUCCESS, BAD_REQUEST, NOT_FOUND + } + + public static TransferResult success() + { + return new TransferResult(Status.SUCCESS, "Transfer successful"); + } + + public static TransferResult badRequest(String message) + { + return new TransferResult(Status.BAD_REQUEST, message); + } + + public static TransferResult notFound() + { + return new TransferResult(Status.NOT_FOUND, "Allowance not found"); + } + } +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/UserService.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/UserService.java new file mode 100644 index 0000000..ccc74cd --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/service/UserService.java @@ -0,0 +1,42 @@ +package be.seeseepuff.allowanceplanner.service; + +import be.seeseepuff.allowanceplanner.dto.*; +import be.seeseepuff.allowanceplanner.entity.User; +import be.seeseepuff.allowanceplanner.repository.UserRepository; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Optional; + +@Service +public class UserService +{ + private final UserRepository userRepository; + + public UserService(UserRepository userRepository) + { + this.userRepository = userRepository; + } + + public List getUsers() + { + return userRepository.findAll().stream() + .map(u -> new UserDto(u.getId(), u.getName())) + .toList(); + } + + public Optional getUser(int userId) + { + return userRepository.findById(userId) + .map(u -> + { + long totalAmount = userRepository.sumHistoryAmount(userId); + return new UserWithAllowanceDto(u.getId(), u.getName(), totalAmount / 100.0); + }); + } + + public boolean userExists(int userId) + { + return userRepository.existsById(userId); + } +} diff --git a/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/util/ColourUtil.java b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/util/ColourUtil.java new file mode 100644 index 0000000..6fda514 --- /dev/null +++ b/backend-spring/src/main/java/be/seeseepuff/allowanceplanner/util/ColourUtil.java @@ -0,0 +1,42 @@ +package be.seeseepuff.allowanceplanner.util; + +public class ColourUtil +{ + private ColourUtil() + { + } + + public static int convertStringToColour(String colourStr) + { + if (colourStr == null || colourStr.isEmpty()) + { + return 0xFF0000; // Default colour + } + if (colourStr.charAt(0) == '#') + { + colourStr = colourStr.substring(1); + } + if (colourStr.length() != 6 && colourStr.length() != 3) + { + throw new IllegalArgumentException("colour must be a valid hex string"); + } + int colour = Integer.parseInt(colourStr, 16); + if (colourStr.length() == 3) + { + int r = (colour & 0xF00) >> 8; + int g = (colour & 0x0F0) >> 4; + int b = (colour & 0x00F); + colour = (r << 20) | (g << 12) | (b << 4); + } + return colour; + } + + public static String convertColourToString(Integer colour) + { + if (colour == null) + { + return ""; + } + return String.format("#%06X", colour); + } +} diff --git a/backend-spring/src/main/resources/application.properties b/backend-spring/src/main/resources/application.properties new file mode 100644 index 0000000..35e78e6 --- /dev/null +++ b/backend-spring/src/main/resources/application.properties @@ -0,0 +1,12 @@ +spring.application.name=allowance-planner + +spring.datasource.url=jdbc:postgresql://localhost:5432/allowance_planner +spring.datasource.username=postgres +spring.datasource.password=postgres + +spring.jpa.hibernate.ddl-auto=validate +spring.jpa.open-in-view=false + +spring.flyway.enabled=true + +server.port=8080 diff --git a/backend-spring/src/main/resources/db/migration/V1__initial.sql b/backend-spring/src/main/resources/db/migration/V1__initial.sql new file mode 100644 index 0000000..c956d03 --- /dev/null +++ b/backend-spring/src/main/resources/db/migration/V1__initial.sql @@ -0,0 +1,42 @@ +CREATE TABLE users +( + id SERIAL PRIMARY KEY, + name TEXT NOT NULL, + weight DOUBLE PRECISION NOT NULL DEFAULT 10.0, + balance BIGINT NOT NULL DEFAULT 0 +); + +CREATE TABLE history +( + id SERIAL PRIMARY KEY, + user_id INTEGER NOT NULL, + timestamp BIGINT NOT NULL, + amount BIGINT NOT NULL, + description TEXT +); + +CREATE TABLE allowances +( + id SERIAL PRIMARY KEY, + user_id INTEGER NOT NULL, + name TEXT NOT NULL, + target BIGINT NOT NULL, + balance BIGINT NOT NULL DEFAULT 0, + weight DOUBLE PRECISION NOT NULL, + colour INTEGER +); + +CREATE TABLE tasks +( + id SERIAL PRIMARY KEY, + name TEXT NOT NULL, + reward BIGINT NOT NULL, + assigned INTEGER, + schedule TEXT, + completed BIGINT, + next_run BIGINT +); + +INSERT INTO users (name) +VALUES ('Seeseemelk'), + ('Huffle'); diff --git a/backend-spring/src/main/resources/templates/index.html b/backend-spring/src/main/resources/templates/index.html new file mode 100644 index 0000000..a199188 --- /dev/null +++ b/backend-spring/src/main/resources/templates/index.html @@ -0,0 +1,122 @@ + + + + Allowance Planner 2000 + + + +

Allowance Planner 2000

+ +
+

Error

+

+
+ +
+

Users

+ + + + + +
+

Allowances

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameProgressTargetWeightActions
Total + + () + + Mark as completed +
+
+ +

Tasks

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
NameAssignedRewardScheduleActions
+ None + + + Mark as completed +
+
+ +

History

+ + + + + + + + + + + + + +
TimestampAllowance
+
+
+ + diff --git a/backend-spring/src/test/java/be/seeseepuff/allowanceplanner/ApiTest.java b/backend-spring/src/test/java/be/seeseepuff/allowanceplanner/ApiTest.java new file mode 100644 index 0000000..1433976 --- /dev/null +++ b/backend-spring/src/test/java/be/seeseepuff/allowanceplanner/ApiTest.java @@ -0,0 +1,1242 @@ +package be.seeseepuff.allowanceplanner; + +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; +import org.testcontainers.containers.PostgreSQLContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +import org.flywaydb.core.Flyway; +import org.springframework.beans.factory.annotation.Autowired; + +import java.time.Instant; +import java.util.List; +import java.util.Map; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.*; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@Testcontainers +class ApiTest +{ + private static final String TEST_HISTORY_NAME = "Test History"; + + @Container + static PostgreSQLContainer postgres = new PostgreSQLContainer<>("postgres:17") + .withDatabaseName("allowance_planner_test") + .withUsername("test") + .withPassword("test"); + + @LocalServerPort + int port; + + @Autowired + Flyway flyway; + + @DynamicPropertySource + static void configureProperties(DynamicPropertyRegistry registry) + { + registry.add("spring.datasource.url", postgres::getJdbcUrl); + registry.add("spring.datasource.username", postgres::getUsername); + registry.add("spring.datasource.password", postgres::getPassword); + registry.add("spring.flyway.clean-disabled", () -> "false"); + } + + @BeforeEach + void setUp() + { + RestAssured.port = port; + RestAssured.basePath = "/api"; + RestAssured.config = RestAssured.config() + .jsonConfig(io.restassured.config.JsonConfig.jsonConfig() + .numberReturnType(io.restassured.path.json.config.JsonPathConfig.NumberReturnType.DOUBLE)); + + // Clean and re-migrate the database before each test + flyway.clean(); + flyway.migrate(); + } + + // ---- User Tests ---- + + @Test + void getUsers() + { + given() + .when() + .get("/users") + .then() + .statusCode(200) + .body("$.size()", is(2)) + .body("[0].name", isA(String.class)) + .body("[1].name", isA(String.class)); + } + + @Test + void getUser() + { + given() + .when() + .get("/user/1") + .then() + .statusCode(200) + .body("name", is("Seeseemelk")) + .body("id", is(1)) + .body("allowance", is(0.0d)); + } + + @Test + void getUserUnknown() + { + given() + .when() + .get("/user/999") + .then() + .statusCode(404); + } + + @Test + void getUserBadId() + { + given() + .when() + .get("/user/bad-id") + .then() + .statusCode(400); + } + + // ---- Allowance Tests ---- + + @Test + void getUserAllowanceWhenNoAllowancePresent() + { + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("$.size()", is(1)) + .body("[0].id", is(0)); + } + + @Test + void getUserAllowance() + { + createAllowance(1, TEST_HISTORY_NAME, 5000, 10); + + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("$.size()", is(2)) + .body("[1].name", is(TEST_HISTORY_NAME)) + .body("[1].target", is(5000.0d)) + .body("[1].weight", is(10.0d)) + .body("[1].progress", is(0.0d)) + .body("[1]", not(hasKey("user_id"))); + } + + @Test + void getUserAllowanceNoUser() + { + given() + .when() + .get("/user/999/allowance") + .then() + .statusCode(404); + } + + @Test + void getUserAllowanceBadId() + { + given() + .when() + .get("/user/bad-id/allowance") + .then() + .statusCode(400); + } + + @Test + void createUserAllowance() + { + int allowanceId = createAllowance(1, TEST_HISTORY_NAME, 5000, 10); + + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("$.size()", is(2)) + .body("[1].id", is(allowanceId)) + .body("[1].name", is(TEST_HISTORY_NAME)) + .body("[1].target", is(5000.0d)) + .body("[1].weight", is(10.0d)) + .body("[1].progress", is(0.0d)); + } + + @Test + void createUserAllowanceNoUser() + { + given() + .contentType(ContentType.JSON) + .body(Map.of("name", TEST_HISTORY_NAME, "target", 5000, "weight", 10)) + .when() + .post("/user/999/allowance") + .then() + .statusCode(404); + } + + @Test + void createUserAllowanceInvalidInput() + { + // Empty name + given() + .contentType(ContentType.JSON) + .body(Map.of("name", "", "target", 5000, "weight", 10)) + .when() + .post("/user/1/allowance") + .then() + .statusCode(400); + + // Missing name + given() + .contentType(ContentType.JSON) + .body(Map.of("target", 5000)) + .when() + .post("/user/1/allowance") + .then() + .statusCode(400); + } + + @Test + void createUserAllowanceBadId() + { + given() + .contentType(ContentType.JSON) + .body(Map.of("name", TEST_HISTORY_NAME, "target", 5000, "weight", 10)) + .when() + .post("/user/bad-id/allowance") + .then() + .statusCode(400); + } + + @Test + void deleteUserAllowance() + { + int allowanceId = createAllowance(1, TEST_HISTORY_NAME, 1000, 5); + + given() + .when() + .delete("/user/1/allowance/" + allowanceId) + .then() + .statusCode(200) + .body("message", is("History deleted successfully")); + + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("$.size()", is(1)); + } + + @Test + void deleteUserRestAllowance() + { + given() + .when() + .delete("/user/1/allowance/0") + .then() + .statusCode(400); + } + + @Test + void deleteUserAllowanceNotFound() + { + given() + .when() + .delete("/user/1/allowance/999") + .then() + .statusCode(404) + .body("error", is("History not found")); + } + + @Test + void deleteUserAllowanceInvalidId() + { + given() + .when() + .delete("/user/1/allowance/invalid-id") + .then() + .statusCode(400) + .body("error", is("Invalid allowance ID")); + } + + // ---- Task Tests ---- + + @Test + void createTask() + { + // Without assigned user + int taskId = given() + .contentType(ContentType.JSON) + .body(Map.of("name", "Test Task", "reward", 100)) + .when() + .post("/tasks") + .then() + .statusCode(201) + .body("id", notNullValue()) + .extract().path("id"); + + given().when().get("/tasks").then().statusCode(200).body("$.size()", is(1)); + + given() + .when() + .get("/task/" + taskId) + .then() + .statusCode(200) + .body("id", is(taskId)) + .body("name", is("Test Task")) + .body("reward", is(100.0d)) + .body("assigned", nullValue()); + + // With assigned user + given() + .contentType(ContentType.JSON) + .body(Map.of("name", "Test Task Assigned", "reward", 200, "assigned", 1)) + .when() + .post("/tasks") + .then() + .statusCode(201) + .body("id", notNullValue()); + } + + @Test + void deleteTask() + { + int taskId = createTestTask(100); + + given().when().delete("/task/" + taskId).then().statusCode(200); + given().when().get("/task/" + taskId).then().statusCode(404); + } + + @Test + void deleteTaskNotFound() + { + given().when().delete("/task/1").then().statusCode(404); + } + + @Test + void createTaskNoName() + { + given() + .contentType(ContentType.JSON) + .body(Map.of("reward", 100)) + .when() + .post("/tasks") + .then() + .statusCode(400); + } + + @Test + void createTaskInvalidAssignedUser() + { + given() + .contentType(ContentType.JSON) + .body(Map.of("name", "Test Task Invalid User", "reward", 100, "assigned", 999)) + .when() + .post("/tasks") + .then() + .statusCode(404) + .body("error", is("User not found")); + } + + @Test + void createTaskInvalidRequestBody() + { + given() + .contentType(ContentType.JSON) + .body(Map.of("reward", 5000)) + .when() + .post("/tasks") + .then() + .statusCode(400); + } + + @Test + void getTaskWhenNoTasks() + { + given() + .when() + .get("/tasks") + .then() + .statusCode(200) + .body("$.size()", is(0)); + } + + @Test + void getTasksWhenTasks() + { + createTestTask(100); + + given() + .when() + .get("/tasks") + .then() + .statusCode(200) + .body("$.size()", is(1)) + .body("[0].name", is("Test Task")) + .body("[0].reward", is(100.0d)) + .body("[0].assigned", nullValue()); + } + + @Test + void getTask() + { + int taskId = createTestTask(100); + + given() + .when() + .get("/task/" + taskId) + .then() + .statusCode(200) + .body("id", is(taskId)) + .body("name", is("Test Task")) + .body("reward", is(100.0d)) + .body("assigned", nullValue()); + } + + @Test + void getTaskInvalidId() + { + createTestTask(100); + // Task ID won't be found since we use auto-increment and there's only one + given().when().get("/task/99999").then().statusCode(404); + } + + @Test + void getTaskBadId() + { + createTestTask(100); + given().when().get("/task/invalid").then().statusCode(400); + } + + @Test + void putTaskModifiesTask() + { + int taskId = createTestTask(100); + + given() + .contentType(ContentType.JSON) + .body(Map.of("name", "Updated Task", "reward", 100)) + .when() + .put("/task/" + taskId) + .then() + .statusCode(200); + + given() + .when() + .get("/task/" + taskId) + .then() + .statusCode(200) + .body("id", is(taskId)) + .body("name", is("Updated Task")) + .body("reward", is(100.0d)); + } + + @Test + void putTaskInvalidTaskId() + { + createTestTask(100); + + given() + .contentType(ContentType.JSON) + .body(Map.of("name", "Updated Task")) + .when() + .put("/task/999") + .then() + .statusCode(404); + } + + // ---- History Tests ---- + + @Test + void postHistory() + { + given() + .contentType(ContentType.JSON) + .body(Map.of("allowance", 100, "description", "Add a 100")) + .when() + .post("/user/1/history") + .then() + .statusCode(200); + + given() + .contentType(ContentType.JSON) + .body(Map.of("allowance", 20, "description", "Lolol")) + .when() + .post("/user/1/history") + .then() + .statusCode(200); + + given() + .contentType(ContentType.JSON) + .body(Map.of("allowance", -10, "description", "Subtracting")) + .when() + .post("/user/1/history") + .then() + .statusCode(200); + + given() + .when() + .get("/user/1") + .then() + .statusCode(200) + .body("allowance", is(110.0d)); + } + + @Test + void postHistoryInvalidUserId() + { + given() + .contentType(ContentType.JSON) + .body(Map.of("allowance", 100, "description", "Good")) + .when() + .post("/user/999/history") + .then() + .statusCode(404); + } + + @Test + void postHistoryInvalidDescription() + { + given() + .contentType(ContentType.JSON) + .body(Map.of("allowance", 100)) + .when() + .post("/user/1/history") + .then() + .statusCode(400); + } + + @Test + void getHistory() + { + Instant before = Instant.now().minusSeconds(2); + Instant after = Instant.now().plusSeconds(2); + + given() + .contentType(ContentType.JSON) + .body(Map.of("allowance", 100, "description", "Add 100")) + .when() + .post("/user/1/history") + .then() + .statusCode(200); + given() + .contentType(ContentType.JSON) + .body(Map.of("allowance", 20, "description", "Add 20")) + .when() + .post("/user/1/history") + .then() + .statusCode(200); + given() + .contentType(ContentType.JSON) + .body(Map.of("allowance", -10, "description", "Subtract 10")) + .when() + .post("/user/1/history") + .then() + .statusCode(200); + + // History is returned newest first (by ID desc) + given() + .when() + .get("/user/1/history") + .then() + .statusCode(200) + .body("$.size()", is(3)) + .body("[0].allowance", is(-10.0d)) + .body("[0].description", is("Subtract 10")) + .body("[1].allowance", is(20.0d)) + .body("[1].description", is("Add 20")) + .body("[2].allowance", is(100.0d)) + .body("[2].description", is("Add 100")); + } + + // ---- Allowance By ID Tests ---- + + @Test + void getUserAllowanceById() + { + int allowanceId = createAllowanceWithColour(1, TEST_HISTORY_NAME, 5000, 10, "#FF5733"); + + given() + .when() + .get("/user/1/allowance/" + allowanceId) + .then() + .statusCode(200) + .body("id", is(allowanceId)) + .body("name", is(TEST_HISTORY_NAME)) + .body("target", is(5000.0d)) + .body("weight", is(10.0d)) + .body("progress", is(0.0d)) + .body("colour", is("#FF5733")); + + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("$.size()", is(2)) + .body("[1].id", is(allowanceId)) + .body("[1].colour", is("#FF5733")); + } + + @Test + void getUserByAllowanceIdInvalidAllowance() + { + given().when().get("/user/1/allowance/9999").then().statusCode(404); + } + + @Test + void getUserByAllowanceByIdInvalidUserId() + { + given().when().get("/user/999/allowance/1").then().statusCode(404); + } + + @Test + void getUserByAllowanceByIdBadUserId() + { + given().when().get("/user/bad/allowance/1").then().statusCode(400); + } + + @Test + void getUserByAllowanceByIdBadAllowanceId() + { + given().when().get("/user/1/allowance/bad").then().statusCode(400); + } + + @Test + void putAllowanceById() + { + int allowanceId = createAllowanceWithColour(1, TEST_HISTORY_NAME, 5000, 10, "#FF5733"); + + given() + .contentType(ContentType.JSON) + .body(Map.of("name", "Updated Allowance", "target", 6000, "weight", 15, "colour", "#3357FF")) + .when() + .put("/user/1/allowance/" + allowanceId) + .then() + .statusCode(200); + + given() + .when() + .get("/user/1/allowance/" + allowanceId) + .then() + .statusCode(200) + .body("id", is(allowanceId)) + .body("name", is("Updated Allowance")) + .body("target", is(6000.0d)) + .body("weight", is(15.0d)) + .body("colour", is("#3357FF")); + } + + // ---- Complete Task Tests ---- + + @Test + void completeTask() + { + int taskId = createTestTask(101); + + given().when().get("/tasks").then().statusCode(200).body("$.size()", is(1)); + + // Update rest allowance weight + given() + .contentType(ContentType.JSON) + .body(Map.of("name", "", "target", 0, "weight", 25, "colour", "")) + .when() + .put("/user/1/allowance/0") + .then() + .statusCode(200); + + // Create two allowance goals + createAllowance(1, "Test Allowance 1", 100, 50); + createAllowance(1, "Test Allowance 1", 10, 25); + + // Complete the task + given().when().post("/task/" + taskId + "/complete").then().statusCode(200); + + // Verify task is completed + given().when().get("/task/" + taskId).then().statusCode(404); + + // Verify allowances for user 1 + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("$.size()", is(3)) + .body("[0].id", is(0)) + .body("[0].progress", closeTo(30.34, 0.01)) + .body("[1].progress", closeTo(60.66, 0.01)) + .body("[2].progress", closeTo(10.0, 0.01)); + + // Verify allowances for user 2 + given() + .when() + .get("/user/2/allowance") + .then() + .statusCode(200) + .body("$.size()", is(1)) + .body("[0].id", is(0)) + .body("[0].progress", closeTo(101.0, 0.01)); + + // Verify history for both users + for (int userId = 1; userId <= 2; userId++) + { + given() + .when() + .get("/user/" + userId + "/history") + .then() + .statusCode(200) + .body("$.size()", is(1)) + .body("[0].allowance", closeTo(101.0, 0.01)); + } + } + + @Test + void completeTaskWithNoWeights() + { + int taskId = createTestTask(101); + + given().when().get("/tasks").then().statusCode(200).body("$.size()", is(1)); + + // Ensure main allowance has no weight + given() + .contentType(ContentType.JSON) + .body(Map.of("name", "", "target", 0, "weight", 0, "colour", "")) + .when() + .put("/user/1/allowance/0") + .then() + .statusCode(200); + + // Complete the task + given().when().post("/task/" + taskId + "/complete").then().statusCode(200); + + // Verify task is completed + given().when().get("/task/" + taskId).then().statusCode(404); + + // Verify allowances for user 1 + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("$.size()", is(1)) + .body("[0].id", is(0)) + .body("[0].progress", closeTo(101.0, 0.01)); + + // Verify allowances for user 2 + given() + .when() + .get("/user/2/allowance") + .then() + .statusCode(200) + .body("$.size()", is(1)) + .body("[0].id", is(0)) + .body("[0].progress", closeTo(101.0, 0.01)); + } + + @Test + void completeTaskAllowanceWeightsSumTo0() + { + int taskId = createTestTask(101); + + given().when().get("/tasks").then().statusCode(200).body("$.size()", is(1)); + + // Update rest allowance to 0 weight + given() + .contentType(ContentType.JSON) + .body(Map.of("name", "", "target", 0, "weight", 0, "colour", "")) + .when() + .put("/user/1/allowance/0") + .then() + .statusCode(200); + + // Create allowance with 0 weight + createAllowance(1, "Test Allowance 1", 1000, 0); + + // Complete the task + given().when().post("/task/" + taskId + "/complete").then().statusCode(200); + + // Verify allowances for user 1 + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("$.size()", is(2)) + .body("[0].id", is(0)) + .body("[0].progress", closeTo(101.0, 0.01)) + .body("[1].progress", closeTo(0.0, 0.01)); + } + + @Test + void completeTaskInvalidId() + { + given().when().post("/task/999/complete").then().statusCode(404); + } + + // ---- Complete Allowance Tests ---- + + @Test + void completeAllowance() + { + createTestTask(100); + createAllowance(1, "Test Allowance 1", 100, 50); + + // Update base allowance to 0 weight + given() + .contentType(ContentType.JSON) + .body(Map.of("name", "", "target", 0, "weight", 0, "colour", "")) + .when() + .put("/user/1/allowance/0") + .then() + .statusCode(200); + + // Complete the task + given().when().post("/task/1/complete").then().statusCode(200); + + // Get the allowance ID (first named allowance) + int allowanceId = given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .extract() + .path("[1].id"); + + // Complete allowance + given().when().post("/user/1/allowance/" + allowanceId + "/complete").then().statusCode(200); + + // Verify allowance no longer exists + given().when().get("/user/1/allowance/" + allowanceId).then().statusCode(404); + + // Verify history (newest first) + given() + .when() + .get("/user/1/history") + .then() + .statusCode(200) + .body("$.size()", is(2)) + .body("[0].allowance", closeTo(-100.0, 0.01)) + .body("[0].description", is("Allowance completed: Test Allowance 1")) + .body("[1].allowance", closeTo(100.0, 0.01)) + .body("[1].description", is("Task completed: Test Task")); + } + + @Test + void completeAllowanceInvalidUserId() + { + given().when().post("/user/999/allowance/1/complete").then().statusCode(404); + } + + @Test + void completeAllowanceInvalidAllowanceId() + { + given().when().post("/user/1/allowance/999/complete").then().statusCode(404); + } + + // ---- Bulk Update Tests ---- + + @Test + void putBulkAllowance() + { + int id1 = createAllowance(1, "Test Allowance 1", 1000, 1); + int id2 = createAllowance(1, "Test Allowance 2", 1000, 2); + + given() + .contentType(ContentType.JSON) + .body(List.of( + Map.of("id", id1, "weight", 5), + Map.of("id", 0, "weight", 99), + Map.of("id", id2, "weight", 10))) + .when() + .put("/user/1/allowance") + .then() + .statusCode(200); + + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("$.size()", is(3)) + .body("[0].id", is(0)) + .body("[0].weight", closeTo(99.0, 0.01)) + .body("[1].id", is(id1)) + .body("[1].weight", closeTo(5.0, 0.01)) + .body("[2].id", is(id2)) + .body("[2].weight", closeTo(10.0, 0.01)); + } + + // ---- Add Allowance Amount Tests ---- + + @Test + void addAllowanceSimple() + { + int allowanceId = createAllowance(1, "Test Allowance 1", 1000, 1); + + given() + .contentType(ContentType.JSON) + .body(Map.of("amount", 10, "description", "Added to allowance 1")) + .when() + .post("/user/1/allowance/" + allowanceId + "/add") + .then() + .statusCode(200); + + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("[1].id", is(allowanceId)) + .body("[1].progress", closeTo(10.0, 0.01)); + + given() + .when() + .get("/user/1/history") + .then() + .statusCode(200) + .body("$.size()", is(1)) + .body("[0].allowance", closeTo(10.0, 0.01)) + .body("[0].description", is("Added to allowance 1")); + } + + @Test + void addAllowanceWithSpillage() + { + int id1 = createAllowance(1, "Test Allowance 1", 5, 1); + int id2 = createAllowance(1, "Test Allowance 2", 5, 1); + given() + .contentType(ContentType.JSON) + .body(Map.of("name", "", "target", 0, "weight", 1, "colour", "")) + .when() + .put("/user/1/allowance/0") + .then() + .statusCode(200); + + given() + .contentType(ContentType.JSON) + .body(Map.of("amount", 10, "description", "Added to allowance 1")) + .when() + .post("/user/1/allowance/" + id1 + "/add") + .then() + .statusCode(200); + + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("[1].id", is(id1)) + .body("[1].progress", closeTo(5.0, 0.01)) + .body("[2].id", is(id2)) + .body("[2].progress", closeTo(2.5, 0.01)) + .body("[0].id", is(0)) + .body("[0].progress", closeTo(2.5, 0.01)); + + given() + .when() + .get("/user/1/history") + .then() + .statusCode(200) + .body("$.size()", is(1)) + .body("[0].allowance", closeTo(10.0, 0.01)) + .body("[0].description", is("Added to allowance 1")); + } + + @Test + void addAllowanceIdZero() + { + createAllowance(1, "Test Allowance 1", 1000, 1); + + given() + .contentType(ContentType.JSON) + .body(Map.of("amount", 10, "description", "Added to allowance 1")) + .when() + .post("/user/1/allowance/0/add") + .then() + .statusCode(200); + + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("[0].id", is(0)) + .body("[0].progress", closeTo(10.0, 0.01)); + + given() + .when() + .get("/user/1/history") + .then() + .statusCode(200) + .body("$.size()", is(1)) + .body("[0].allowance", closeTo(10.0, 0.01)) + .body("[0].description", is("Added to allowance 1")); + } + + @Test + void subtractAllowanceSimple() + { + int allowanceId = createAllowance(1, "Test Allowance 1", 1000, 1); + + given() + .contentType(ContentType.JSON) + .body(Map.of("amount", 10, "description", "Added to allowance 1")) + .when() + .post("/user/1/allowance/" + allowanceId + "/add") + .then() + .statusCode(200); + + given() + .contentType(ContentType.JSON) + .body(Map.of("amount", -2.5, "description", "Added to allowance 1")) + .when() + .post("/user/1/allowance/" + allowanceId + "/add") + .then() + .statusCode(200); + + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("[1].id", is(allowanceId)) + .body("[1].progress", closeTo(7.5, 0.01)); + + given() + .when() + .get("/user/1/history") + .then() + .statusCode(200) + .body("$.size()", is(2)) + .body("[0].allowance", closeTo(-2.5, 0.01)) + .body("[0].description", is("Added to allowance 1")) + .body("[1].allowance", closeTo(10.0, 0.01)) + .body("[1].description", is("Added to allowance 1")); + } + + @Test + void subtractAllowanceIdZero() + { + createAllowance(1, "Test Allowance 1", 1000, 1); + + given() + .contentType(ContentType.JSON) + .body(Map.of("amount", 10, "description", "Added to allowance 1")) + .when() + .post("/user/1/allowance/0/add") + .then() + .statusCode(200); + + given() + .contentType(ContentType.JSON) + .body(Map.of("amount", -2.5, "description", "Added to allowance 1")) + .when() + .post("/user/1/allowance/0/add") + .then() + .statusCode(200); + + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("[0].id", is(0)) + .body("[0].progress", closeTo(7.5, 0.01)); + + given() + .when() + .get("/user/1/history") + .then() + .statusCode(200) + .body("$.size()", is(2)) + .body("[0].allowance", closeTo(-2.5, 0.01)) + .body("[0].description", is("Added to allowance 1")) + .body("[1].allowance", closeTo(10.0, 0.01)) + .body("[1].description", is("Added to allowance 1")); + } + + // ---- Transfer Tests ---- + + @Test + void transferSuccessful() + { + int id1 = createAllowance(1, "From Allowance", 100, 1); + int id2 = createAllowance(1, "To Allowance", 100, 1); + + // Add 30 to allowance 1 + given() + .contentType(ContentType.JSON) + .body(Map.of("amount", 30, "description", "funds")) + .when() + .post("/user/1/allowance/" + id1 + "/add") + .then() + .statusCode(200); + + // Transfer 10 from 1 to 2 + given() + .contentType(ContentType.JSON) + .body(Map.of("from", id1, "to", id2, "amount", 10)) + .when() + .post("/transfer") + .then() + .statusCode(200) + .body("message", is("Transfer successful")); + + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("[1].progress", closeTo(20.0, 0.01)) + .body("[2].progress", closeTo(10.0, 0.01)); + } + + @Test + void transferCapsAtTarget() + { + int id1 = createAllowance(1, "From Allowance", 100, 1); + int id2 = createAllowance(1, "To Allowance", 5, 1); + + // Add 10 to allowance 1 + given() + .contentType(ContentType.JSON) + .body(Map.of("amount", 10, "description", "funds")) + .when() + .post("/user/1/allowance/" + id1 + "/add") + .then() + .statusCode(200); + + // Transfer 10, but to only needs 5 + given() + .contentType(ContentType.JSON) + .body(Map.of("from", id1, "to", id2, "amount", 10)) + .when() + .post("/transfer") + .then() + .statusCode(200); + + given() + .when() + .get("/user/1/allowance") + .then() + .statusCode(200) + .body("[1].progress", closeTo(5.0, 0.01)) + .body("[2].progress", closeTo(5.0, 0.01)); + } + + @Test + void transferDifferentUsersFails() + { + int id1 = createAllowance(1, "User1 Allowance", 100, 1); + + // Create allowance for user 2 + int id2 = createAllowance(2, "User2 Allowance", 100, 1); + + // Add to user1 allowance + given() + .contentType(ContentType.JSON) + .body(Map.of("amount", 10, "description", "funds")) + .when() + .post("/user/1/allowance/" + id1 + "/add") + .then() + .statusCode(200); + + // Transfer between different users + given() + .contentType(ContentType.JSON) + .body(Map.of("from", id1, "to", id2, "amount", 5)) + .when() + .post("/transfer") + .then() + .statusCode(400); + } + + @Test + void transferInsufficientFunds() + { + int id1 = createAllowance(1, "From Allowance", 100, 1); + int id2 = createAllowance(1, "To Allowance", 100, 1); + + given() + .contentType(ContentType.JSON) + .body(Map.of("from", id1, "to", id2, "amount", 10)) + .when() + .post("/transfer") + .then() + .statusCode(400) + .body("error", containsStringIgnoringCase("insufficient")); + } + + @Test + void transferNotFound() + { + given() + .contentType(ContentType.JSON) + .body(Map.of("from", 999, "to", 1000, "amount", 1)) + .when() + .post("/transfer") + .then() + .statusCode(404); + } + + // ---- Helpers ---- + + private int createTestTask(int reward) + { + return given() + .contentType(ContentType.JSON) + .body(Map.of("name", "Test Task", "reward", reward)) + .when() + .post("/tasks") + .then() + .statusCode(201) + .extract() + .path("id"); + } + + private int createAllowance(int userId, String name, double target, double weight) + { + return given() + .contentType(ContentType.JSON) + .body(Map.of("name", name, "target", target, "weight", weight)) + .when() + .post("/user/" + userId + "/allowance") + .then() + .statusCode(201) + .extract() + .path("id"); + } + + private int createAllowanceWithColour(int userId, String name, double target, double weight, String colour) + { + return given() + .contentType(ContentType.JSON) + .body(Map.of("name", name, "target", target, "weight", weight, "colour", colour)) + .when() + .post("/user/" + userId + "/allowance") + .then() + .statusCode(201) + .extract() + .path("id"); + } +} diff --git a/backend-spring/src/test/java/be/seeseepuff/allowanceplanner/ColourUtilTest.java b/backend-spring/src/test/java/be/seeseepuff/allowanceplanner/ColourUtilTest.java new file mode 100644 index 0000000..2e7766a --- /dev/null +++ b/backend-spring/src/test/java/be/seeseepuff/allowanceplanner/ColourUtilTest.java @@ -0,0 +1,33 @@ +package be.seeseepuff.allowanceplanner; + +import be.seeseepuff.allowanceplanner.util.ColourUtil; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class ColourUtilTest +{ + @Test + void convertStringToColourWithSign() + { + assertEquals(0x123456, ColourUtil.convertStringToColour("#123456")); + } + + @Test + void convertStringToColourWithoutSign() + { + assertEquals(0x123456, ColourUtil.convertStringToColour("123456")); + } + + @Test + void convertStringToColourWithSignThreeDigits() + { + assertEquals(0xA0B0C0, ColourUtil.convertStringToColour("#ABC")); + } + + @Test + void convertStringToColourWithoutSignThreeDigits() + { + assertEquals(0xA0B0C0, ColourUtil.convertStringToColour("ABC")); + } +}