From d3becdef7252d2e547d79722915f606642cd4cfd Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 10 Mar 2026 19:58:26 +0100 Subject: [PATCH] catmonthmodel --- .../webshop/controller/StatisticsController.java | 15 +++++++-------- .../webshop/cronjob/ExpiredSessionDeleteJob.java | 7 ------- ...CatMonthModel.java => CategoryMonthModel.java} | 2 +- .../webshop/service/StatisticsService.java | 8 +++----- .../service/impl/StatisticsServiceImpl.java | 14 +++++++------- 5 files changed, 18 insertions(+), 28 deletions(-) rename 00-backend/src/main/java/de/htwsaar/webshop/model/{CatMonthModel.java => CategoryMonthModel.java} (80%) diff --git a/00-backend/src/main/java/de/htwsaar/webshop/controller/StatisticsController.java b/00-backend/src/main/java/de/htwsaar/webshop/controller/StatisticsController.java index 4aa6334..e0c7133 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/controller/StatisticsController.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/controller/StatisticsController.java @@ -1,6 +1,6 @@ package de.htwsaar.webshop.controller; -import de.htwsaar.webshop.model.CatMonthModel; +import de.htwsaar.webshop.model.CategoryMonthModel; import de.htwsaar.webshop.model.OrderStatus; import de.htwsaar.webshop.service.SessionService; import de.htwsaar.webshop.service.StatisticsService; @@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.List; import java.util.Map; import java.util.UUID; @@ -34,9 +33,9 @@ public class StatisticsController { } @RequestMapping(value = STATISTICS_VOLUME, method = RequestMethod.GET, produces = "application/json") - public ResponseEntity> getMonthlySalesVolume(HttpServletRequest request, - @RequestParam(value = PARAM_SESSION) UUID session, - @RequestParam(value = PARAM_EMAIL) String email) { + public ResponseEntity> getMonthlySalesVolume(HttpServletRequest request, + @RequestParam(value = PARAM_SESSION) UUID session, + @RequestParam(value = PARAM_EMAIL) String email) { logRequest(request); if (!sessionService.isAdmin(session, email)) { log.warn("Invalid session requesting Admin {}", session); @@ -46,9 +45,9 @@ public class StatisticsController { } @RequestMapping(value = STATISTICS_REVENUE, method = RequestMethod.GET, produces = "application/json") - public ResponseEntity> getMonthlyRevenue(HttpServletRequest request, - @RequestParam(value = PARAM_SESSION) UUID token, - @RequestParam(value = PARAM_EMAIL) String email) { + public ResponseEntity> getMonthlyRevenue(HttpServletRequest request, + @RequestParam(value = PARAM_SESSION) UUID token, + @RequestParam(value = PARAM_EMAIL) String email) { logRequest(request); if (!sessionService.isAdmin(token, email)) { log.warn("Invalid session requesting Admin {}", token); diff --git a/00-backend/src/main/java/de/htwsaar/webshop/cronjob/ExpiredSessionDeleteJob.java b/00-backend/src/main/java/de/htwsaar/webshop/cronjob/ExpiredSessionDeleteJob.java index 8a00b40..4bf1820 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/cronjob/ExpiredSessionDeleteJob.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/cronjob/ExpiredSessionDeleteJob.java @@ -16,17 +16,10 @@ public class ExpiredSessionDeleteJob { private final SessionService sessionService; - /** - * Constructor of the class - * @param sessionService used in the class - */ public ExpiredSessionDeleteJob(SessionService sessionService) { this.sessionService = sessionService; } - /** - * Method running the job calling the referring service method - */ @Scheduled(fixedRate = MILLIS_TO_WEEK) public void runFixedRateTask() { log.info("Deleting expired sessions..."); diff --git a/00-backend/src/main/java/de/htwsaar/webshop/model/CatMonthModel.java b/00-backend/src/main/java/de/htwsaar/webshop/model/CategoryMonthModel.java similarity index 80% rename from 00-backend/src/main/java/de/htwsaar/webshop/model/CatMonthModel.java rename to 00-backend/src/main/java/de/htwsaar/webshop/model/CategoryMonthModel.java index 22b0c06..11a94bc 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/model/CatMonthModel.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/model/CategoryMonthModel.java @@ -9,6 +9,6 @@ import java.util.Map; @Getter @Setter @AllArgsConstructor -public class CatMonthModel { +public class CategoryMonthModel { Map> catMonthMap; } diff --git a/00-backend/src/main/java/de/htwsaar/webshop/service/StatisticsService.java b/00-backend/src/main/java/de/htwsaar/webshop/service/StatisticsService.java index b7ef384..f9daa9e 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/service/StatisticsService.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/service/StatisticsService.java @@ -1,16 +1,14 @@ package de.htwsaar.webshop.service; -import de.htwsaar.webshop.model.CatMonthModel; +import de.htwsaar.webshop.model.CategoryMonthModel; import de.htwsaar.webshop.model.OrderStatus; import java.util.Map; -import java.util.List; -import java.util.UUID; public interface StatisticsService { - CatMonthModel getSalesVolume(); + CategoryMonthModel getSalesVolume(); - CatMonthModel getSalesRevenue(); + CategoryMonthModel getSalesRevenue(); Map getOrderStatus(); diff --git a/00-backend/src/main/java/de/htwsaar/webshop/service/impl/StatisticsServiceImpl.java b/00-backend/src/main/java/de/htwsaar/webshop/service/impl/StatisticsServiceImpl.java index 02e352d..023382a 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/service/impl/StatisticsServiceImpl.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/service/impl/StatisticsServiceImpl.java @@ -1,7 +1,7 @@ package de.htwsaar.webshop.service.impl; import de.htwsaar.webshop.model.ArticleCategory; -import de.htwsaar.webshop.model.CatMonthModel; +import de.htwsaar.webshop.model.CategoryMonthModel; import de.htwsaar.webshop.model.OrderStatus; import de.htwsaar.webshop.repository.entities.OrderItem; import de.htwsaar.webshop.service.ArticleService; @@ -30,9 +30,9 @@ public class StatisticsServiceImpl implements StatisticsService { } //returns Map> - private CatMonthModel getMonthCategoryMap(Function mappingFunction, - BinaryOperator reduceFunction, - T defaultValue) { + private CategoryMonthModel getMonthCategoryMap(Function mappingFunction, + BinaryOperator reduceFunction, + T defaultValue) { Map> map = new TreeMap<>(); for (ArticleCategory value : ArticleCategory.values()) { map.put(value.loc, new TreeMap<>()); @@ -49,16 +49,16 @@ public class StatisticsServiceImpl implements StatisticsService { }) ); }); - return new CatMonthModel<>(map); + return new CategoryMonthModel<>(map); } @Override - public CatMonthModel getSalesVolume() { + public CategoryMonthModel getSalesVolume() { return getMonthCategoryMap(OrderItem::getAmount, Integer::sum, 0); } @Override - public CatMonthModel getSalesRevenue() { + public CategoryMonthModel getSalesRevenue() { return getMonthCategoryMap(item -> item.getArticle().getPrice100(), Integer::sum, 0); }