Reformat Backend

This commit is contained in:
Tim
2025-06-11 12:37:04 +02:00
parent 9668f625a9
commit c023b720b2
21 changed files with 87 additions and 75 deletions

View File

@@ -15,7 +15,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import static de.htwsaar.webshop.config.ControllerPathConfig.*; import static de.htwsaar.webshop.config.ControllerPathConfig.IMAGE_ALL;
import static de.htwsaar.webshop.config.ControllerPathConfig.IMAGE_BASE;
import static de.htwsaar.webshop.config.ParameterConfig.*; import static de.htwsaar.webshop.config.ParameterConfig.*;
import static de.htwsaar.webshop.util.LoggerUtil.logRequest; import static de.htwsaar.webshop.util.LoggerUtil.logRequest;

View File

@@ -14,7 +14,8 @@ import java.util.List;
import static de.htwsaar.webshop.config.ControllerPathConfig.ORDER_BASE; import static de.htwsaar.webshop.config.ControllerPathConfig.ORDER_BASE;
import static de.htwsaar.webshop.config.ControllerPathConfig.ORDER_GET_ALL; import static de.htwsaar.webshop.config.ControllerPathConfig.ORDER_GET_ALL;
import static de.htwsaar.webshop.config.ParameterConfig.*; import static de.htwsaar.webshop.config.ParameterConfig.PARAM_CUSTOMER_ID;
import static de.htwsaar.webshop.config.ParameterConfig.PARAM_ID;
import static de.htwsaar.webshop.util.LoggerUtil.logRequest; import static de.htwsaar.webshop.util.LoggerUtil.logRequest;
@RestController @RestController

View File

@@ -13,7 +13,8 @@ import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import static de.htwsaar.webshop.config.ControllerPathConfig.*; import static de.htwsaar.webshop.config.ControllerPathConfig.REVIEW_BASE;
import static de.htwsaar.webshop.config.ControllerPathConfig.REVIEW_GET_ALL;
import static de.htwsaar.webshop.config.ParameterConfig.*; import static de.htwsaar.webshop.config.ParameterConfig.*;
import static de.htwsaar.webshop.util.LoggerUtil.logRequest; import static de.htwsaar.webshop.util.LoggerUtil.logRequest;

View File

@@ -1,9 +1,7 @@
package de.htwsaar.webshop.model; package de.htwsaar.webshop.model;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min; import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Null;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -23,5 +21,4 @@ public class SessionModel {
@Min(VALID_MIN_MILLIS_TIMESTAMP) @Min(VALID_MIN_MILLIS_TIMESTAMP)
long timeout; long timeout;
} }

View File

@@ -3,7 +3,6 @@ package de.htwsaar.webshop.repository;
import de.htwsaar.webshop.repository.entities.Article; import de.htwsaar.webshop.repository.entities.Article;
import lombok.NonNull; import lombok.NonNull;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Optional; import java.util.Optional;

View File

@@ -1,15 +1,14 @@
package de.htwsaar.webshop.repository; package de.htwsaar.webshop.repository;
import java.util.List;
import java.util.UUID;
import java.util.stream.Stream;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import de.htwsaar.webshop.repository.entities.Review; import de.htwsaar.webshop.repository.entities.Review;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive; import jakarta.validation.constraints.Positive;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.UUID;
import java.util.stream.Stream;
@Repository @Repository
public interface ReviewRepository extends JpaRepository<Review, Long> { public interface ReviewRepository extends JpaRepository<Review, Long> {

View File

@@ -3,11 +3,7 @@ package de.htwsaar.webshop.repository.entities;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min; import jakarta.validation.constraints.Min;
import lombok.AllArgsConstructor; import lombok.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View File

@@ -4,8 +4,12 @@ import de.htwsaar.webshop.repository.entities.Account;
public interface AccountService { public interface AccountService {
Account saveNew(Account account); Account saveNew(Account account);
Account save(Account account); Account save(Account account);
boolean deleteIfExists(Account account); boolean deleteIfExists(Account account);
Account isValidLogin(String email, String password); Account isValidLogin(String email, String password);
boolean existsWithEmail(String email); boolean existsWithEmail(String email);
} }

View File

@@ -4,6 +4,8 @@ import de.htwsaar.webshop.repository.entities.Customer;
public interface CustomerService { public interface CustomerService {
Customer save(Customer customer); Customer save(Customer customer);
void delete(Customer customer); void delete(Customer customer);
Customer findById(Long id); Customer findById(Long id);
} }

View File

@@ -6,7 +6,10 @@ import java.util.List;
public interface OrderService { public interface OrderService {
Order save(Order order); Order save(Order order);
void delete(Long orderId); void delete(Long orderId);
Order getOrderById(Long orderId); Order getOrderById(Long orderId);
List<Order> getAllOrders(Long customerId); List<Order> getAllOrders(Long customerId);
} }

View File

@@ -2,5 +2,6 @@ package de.htwsaar.webshop.service;
public interface PasswordService { public interface PasswordService {
String hashPassword(String password); String hashPassword(String password);
boolean verifyPassword(String password, String hashedPassword); boolean verifyPassword(String password, String hashedPassword);
} }

View File

@@ -1,16 +1,21 @@
package de.htwsaar.webshop.service; package de.htwsaar.webshop.service;
import java.util.List;
import java.util.UUID;
import de.htwsaar.webshop.model.ReviewModel; import de.htwsaar.webshop.model.ReviewModel;
import de.htwsaar.webshop.repository.entities.Review; import de.htwsaar.webshop.repository.entities.Review;
import java.util.List;
import java.util.UUID;
public interface ReviewService { public interface ReviewService {
Review save(Review review); Review save(Review review);
Review save(UUID articleUuid, int rating, String content); Review save(UUID articleUuid, int rating, String content);
void delete(Long reviewId); void delete(Long reviewId);
Review getReviewById(Long id); Review getReviewById(Long id);
List<Review> getAllByUUID(UUID uuid); List<Review> getAllByUUID(UUID uuid);
ReviewModel toModel(Review review); ReviewModel toModel(Review review);
} }

View File

@@ -1,6 +1,5 @@
package de.htwsaar.webshop.service; package de.htwsaar.webshop.service;
import de.htwsaar.webshop.model.SessionModel;
import de.htwsaar.webshop.repository.entities.Account; import de.htwsaar.webshop.repository.entities.Account;
import de.htwsaar.webshop.repository.entities.Session; import de.htwsaar.webshop.repository.entities.Session;
@@ -8,9 +7,14 @@ import java.util.UUID;
public interface SessionService { public interface SessionService {
Session create(Account account); Session create(Account account);
void delete(Session session); void delete(Session session);
Session findByAccount(Account account); Session findByAccount(Account account);
Session getByToken(UUID token); Session getByToken(UUID token);
boolean isValid(Session session, String email); boolean isValid(Session session, String email);
boolean isValid(UUID token, String email); boolean isValid(UUID token, String email);
} }

View File

@@ -1,6 +1,5 @@
package de.htwsaar.webshop.service.impl; package de.htwsaar.webshop.service.impl;
import de.htwsaar.webshop.model.SessionModel;
import de.htwsaar.webshop.repository.AccountRepository; import de.htwsaar.webshop.repository.AccountRepository;
import de.htwsaar.webshop.repository.SessionRepository; import de.htwsaar.webshop.repository.SessionRepository;
import de.htwsaar.webshop.repository.entities.Account; import de.htwsaar.webshop.repository.entities.Account;