From 54c015e6a6abf3e50568c53cf0ac02b036082841 Mon Sep 17 00:00:00 2001 From: rivo Date: Thu, 28 Nov 2024 19:07:24 +0800 Subject: [PATCH] FEAT:setup api get summary analytics --- .../app/controller/AnalyticsController.java | 12 ++++++++++ .../impl/AnalyticsControllerImpl.java | 19 +++++++++++++++ .../response/ResponseAnalyticsSummary.java | 24 +++++++++++++++++++ .../com/pos/app/service/AnalyticsService.java | 8 +++++++ .../service/impl/AnalyticsServiceImpl.java | 13 ++++++++++ 5 files changed, 76 insertions(+) create mode 100644 src/main/java/com/pos/app/controller/AnalyticsController.java create mode 100644 src/main/java/com/pos/app/controller/impl/AnalyticsControllerImpl.java create mode 100644 src/main/java/com/pos/app/model/response/ResponseAnalyticsSummary.java create mode 100644 src/main/java/com/pos/app/service/AnalyticsService.java create mode 100644 src/main/java/com/pos/app/service/impl/AnalyticsServiceImpl.java diff --git a/src/main/java/com/pos/app/controller/AnalyticsController.java b/src/main/java/com/pos/app/controller/AnalyticsController.java new file mode 100644 index 0000000..dca1323 --- /dev/null +++ b/src/main/java/com/pos/app/controller/AnalyticsController.java @@ -0,0 +1,12 @@ +package com.pos.app.controller; + +import com.pos.app.annotations.BaseController; +import com.pos.app.model.response.BaseResponse; +import org.springframework.web.bind.annotation.GetMapping; + +@BaseController("analytics") +public interface AnalyticsController { + + @GetMapping("v1/summary") + BaseResponse getAnalyticsSummary(); +} diff --git a/src/main/java/com/pos/app/controller/impl/AnalyticsControllerImpl.java b/src/main/java/com/pos/app/controller/impl/AnalyticsControllerImpl.java new file mode 100644 index 0000000..7917c6a --- /dev/null +++ b/src/main/java/com/pos/app/controller/impl/AnalyticsControllerImpl.java @@ -0,0 +1,19 @@ +package com.pos.app.controller.impl; + +import com.pos.app.annotations.BaseControllerImpl; +import com.pos.app.controller.AnalyticsController; +import com.pos.app.model.response.BaseResponse; +import com.pos.app.service.AnalyticsService; +import com.pos.app.utils.ResponseHelper; +import lombok.RequiredArgsConstructor; + +@BaseControllerImpl +@RequiredArgsConstructor +public class AnalyticsControllerImpl implements AnalyticsController { + private final AnalyticsService analyticsService; + + @Override + public BaseResponse getAnalyticsSummary() { + return ResponseHelper.createBaseResponse(analyticsService.getAnalyticsSummary()); + } +} diff --git a/src/main/java/com/pos/app/model/response/ResponseAnalyticsSummary.java b/src/main/java/com/pos/app/model/response/ResponseAnalyticsSummary.java new file mode 100644 index 0000000..0addb23 --- /dev/null +++ b/src/main/java/com/pos/app/model/response/ResponseAnalyticsSummary.java @@ -0,0 +1,24 @@ +package com.pos.app.model.response; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigInteger; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonSerialize +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class ResponseAnalyticsSummary { + private BigInteger totalRevenue; + private BigInteger totalOrder; + private BigInteger totalItems; +} diff --git a/src/main/java/com/pos/app/service/AnalyticsService.java b/src/main/java/com/pos/app/service/AnalyticsService.java new file mode 100644 index 0000000..da18634 --- /dev/null +++ b/src/main/java/com/pos/app/service/AnalyticsService.java @@ -0,0 +1,8 @@ +package com.pos.app.service; + +import com.pos.app.model.response.ResponseAnalyticsSummary; + +public interface AnalyticsService { + + ResponseAnalyticsSummary getAnalyticsSummary(); +} diff --git a/src/main/java/com/pos/app/service/impl/AnalyticsServiceImpl.java b/src/main/java/com/pos/app/service/impl/AnalyticsServiceImpl.java new file mode 100644 index 0000000..d1f799f --- /dev/null +++ b/src/main/java/com/pos/app/service/impl/AnalyticsServiceImpl.java @@ -0,0 +1,13 @@ +package com.pos.app.service.impl; + +import com.pos.app.model.response.ResponseAnalyticsSummary; +import com.pos.app.service.AnalyticsService; +import org.springframework.stereotype.Service; + +@Service +public class AnalyticsServiceImpl implements AnalyticsService { + @Override + public ResponseAnalyticsSummary getAnalyticsSummary() { + return null; + } +}